Jump to content



Submitter

SUPPORT TOPIC File Information

  • Submitted: Sep 13 2019 02:35 AM
  • Last Updated: Sep 13 2019 02:35 AM
  • File Size: 219.09MB
  • Views: 27760
  • Downloads: 4,994
  • Author(s): Glxb
    Highlnder00
    Jpinsa
    Shaderbytes
    Javier
  • Permission to MOD?: Yes, without approval

Download The Goonies Pinball Adventure 1.03

* * * * * 24 Votes
Javier Goonies Original



Screenshots
The Goonies Pinball Adventure
Original Future Pinball table  created in 2012 for:
Glxb, Highlnder00, Jpinsa, Shaderbytes  ported to VPX by Javier.
 
 
 
Note: The table uses PinUPPlayer DMD for the use of FS users, I don't have much time to check the DMD for DT (sorry for this).
I release the table almost like a beta and later with a little more time try to improve and fix faults that appear.
 
 
 
Please, if you can help me with a small contribution to update my work team and continue to make more tables I will be eternally grateful.
Paypal
 
 
 
Rules:

Overall Goal of the game is to complete The Goonies Motto "Never Say Die"
 
Skill Shot:
 
When a new ball starts the 5 lights under the plunger ramp will flash in sequence.
Launch the ball and when it passes under the Skill Shot sign, the current light will be awarded as follows:
 
Sloth:
This starts Sloth 2x scoring for 30 seconds, can also be started by spelling sloth at his targets. (Adds "N")
 
Fratellis:
This start a hurry up mode where you have to get one of the balls in the Fratellis hideout into the kicker at the back  right of the hideout, can also be started by hitting the Fratellis hideout a few times. (Adds "E")
 
Data:
this lights the Data gadget award scoop, hit the scoop to get a randow reward. Can also be lit by spelling Data at his  targets.
 
Super Pops:
Starts the pop bumpers flashing for a higher value. Will end if a pop bumper is not hit for 10 seconds or you loose a  ball.
 
Open Trap:
This opens the captive ball trap to the right of Datas scoop. Lock 3 ball in here to start multiball. Can also be  opened by hitting the trap several times. Locking the first ball adds "E", Starting multiball adds "R"
 
--------------------------------------------------------------------------------------------------------------------------------
 
Chunk Loop: This is the left orbit, each orbit lights an arrow when they are all lit Truffle Shuffle starts.
 
Truffle Shuffle: Each target is worth 50,000 points and a Chunk loop scores a Jackpot. Ends after 30 seconds or you loose a ball. Starting truffle shuffle adds "S"
 
Mikey Loop: This is the right orbit, each loop adds a Marble Bonus, with more loops scoring more points. Points are added on at the end of the ball. Resets for each ball.
 
Key Spinner: each spin adds akey bonus, bonus collected at end of ball
 
Doubloon Spinner: each spin adds a doubloon bonus, collet at end of ball
 
BAD Targets: Spell BAD in the Fratellis hideout to increase the Jackpot for other modes.
 
RICH Lanes: Spell RICH to increase the bonus multiplier. Resets for each ball.
 
DATAs GADGET Awards:
 
Adds "V"
Spy Eyes: this set the bonus multiplier to max (10x)
Slick Shoes: this sets the jackpot score to max (10,000,000)
This is not a candle: shoot the ramp to score the current jackpot
Wings of Flight: Instant jackpot award
Sticky Dart: extra ball awarded
Pincers of peril: open trap
Bully Blinders: Starts Truffle shuffle
Bully Buster: adds 10,000 to marble bonus
 
Ramp Shot scores 5,000 for the first 10 shots, lights extra ball at 10 shots, worth 10,000 after that. Also adds a bonus award for the end of ball bonus.
 
Well Target (to the left of the bumpers, hit 3 times to add big points. Also adds time during timed modes.
 
Drop targets under bone organ, drop them all to open the wall under the bone organ. Get ball in there to start mode: (All modes light a letter towards NEVER SAY DIE)
 
Find the key, hit the left spinner to find the key (spinner must spin 20 times)
Boulders, hit loops to avoid the boulders.
Bone organ, hit the bone organ scoop 3 times to win.
Water slide, hit the ramp to slide.
Fight the Fratellis, hit the BAD targets to collect jackpots.
 




Bonjour

 

Peut t-il fonctionner hors PinUPPlayer svp?

 

Merci

Fantastic. Can't wait to play. There are sooo many good tables over at FP going to waste. I'd love to see Nightmare on Elm Street ported to VPX. It's a better take on the Gottlieb version. 3 Angels and MOTU rock on VPX. Maintain the rage Javier. You're doing a great job AND you included the rules. Sweet!.

 

Nursie

Because I don't have PinUPPplayer installed, and I run Desktop, I had to comment out the references to PinUPPlayer and it's DMD to play the table with text box scoring. I couldn't work out how to attached a text file with the edited script so I have pasted it below. This is for those in a similar position to me so they may readily play this remarkable table.

 

Option Explicit                ' Force explicit variable declaration
Randomize





Const BallSize = 49
Const BallMass = 1.1



' Load the FPVPX.vbs for Future Tables Comvert to VPX
On Error Resume Next
ExecuteGlobal GetTextFile("FPVPX.vbs")
If Err Then MsgBox "you need the fpvpx.vbs for the proper functioning of the table"
If FPVPXv> "" Then If FPVPXv < 1.01 or Err Then msgbox "FPVPX.vbs needs updated version for the proper functioning of the table"
On Error Goto 0

' Load the core.vbs for supporting Subs and functions
LoadCoreFiles

    Sub LoadCoreFiles
        On Error Resume Next
        ExecuteGlobal GetTextFile("core.vbs")
        If Err Then MsgBox "Can't open core.vbs"
        On Error Goto 0
    End Sub


if Table1.ShowDT Then
   hdisplay1.visible =1
   display1.visible = 1
   hdisplay2.visible = 1
  display2.visible = 1
   DispDmd1.visible = 1
 Else
   hdisplay1.visible = 0
   display1.visible = 0
   hdisplay2.visible = 0
  display2.visible = 0
   DispDmd1.visible = 0
End If

Const cGameName = "goonies"

' Define any Constants
Const TableName = "The Goonies"
Const myVersion = "1.03"
Const MaxPlayers = 1     ' from 1 to 4
Const BallSaverTime = 10 ' in seconds
Const MaxMultiplier = 10  ' limit to 10x in this game, both bonus multiplier and playfield multiplier
Const BallsPerGame = 5   ' usually 3 or 5
Const MaxMultiballs = 5  ' max number of balls during multiballs

turnonultradmd = 1 ' change to 1 to turn on ultradmd


Dim Credits
Dim BonusHeldPoints(4)
Dim PlayfieldMultiplier(4)
Dim bBonusHeld
Dim Score(4)
Dim HighScore(4)
Dim HighScoreName(4)
Dim specialhighscorename(4)
Dim specialhighscore(4)
Dim specialscore(4)
Dim replayscore
Dim replayscored
Dim Jackpot(4)
Dim SuperJackpot
Dim Tilt
Dim TiltSensitivity
Dim Tilted
Dim TotalGamesPlayed
Dim mBalls2Eject
Dim SkillshotValue(4)
Dim bAutoPlunger
Dim bInstantInfo
Dim bAttractMode

' HighScore
dim ScoreChecker
dim CheckAllScores
Dim HighScoreReward
Dim SpecialHighScoreReward
dim sortscores(4)
dim sortplayers(4)
Dim TextStr, TextStr2
Dim debugscore
Dim InProgress

' Define Game Control Variables
Dim BallsInHole

' Define Game Flags
Dim bGameInPlay
Dim bBallSaverReady
Dim bMusicOn
Dim bSkillshotReady
Dim bExtraBallWonThisBall
Dim bJustStarted
Dim bJackpot

' core.vbs variables
Dim plungerIM 'used mostly as an autofire plunger during multiballs

dim FastFlips
Dim BallsInDrain

' Define Game Flags
Dim bFreePlay                    ' Either in Free Play or Handling Credits
Dim bOnTheFirstBall            ' First Ball (player one). Used for Adding New Players
Dim bBallInPlungerLane        ' is there a ball in the plunger lane
Dim bBallSaverActive            ' is the ball saver active
Dim bMultiBallMode            ' multiball mode active ?
Dim bEnteringAHighScore        ' player is entering their name into the high score table
Dim turnonultradmd

Dim nvR1, nvR2, nvR3, nvR4, nvR5
Dim highscoreOn
Dim LevelBall
Dim mLevelMagnet




'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
' X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  
'/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/
'\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\
' X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  
'/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/
'  Controller VBS stuff, but with b2s not started
'\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\
' X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  
'/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/
'\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\
' X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  
'***Controller.vbs version 1.2***'
'


Const directory = "HKEY_CURRENT_USER\SOFTWARE\Visual Pinball\Controller\"
Dim objShell
Dim PopupMessage
Dim B2SController
Dim 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

Dim DOFeffects(9)
Dim B2SOn
Dim B2SOnALT

Sub LoadEM
    LoadController("EM")
End Sub

Sub LoadPROC(VPMver, VBSfile, VBSver)
    LoadVBSFiles VPMver, VBSfile, VBSver
    LoadController("PROC")
End Sub

Sub LoadVPM(VPMver, VBSfile, VBSver)
    LoadVBSFiles VPMver, VBSfile, VBSver
    LoadController("VPM")
End Sub

Sub LoadVPMALT(VPMver, VBSfile, VBSver)
    LoadVBSFiles VPMver, VBSfile, VBSver
    LoadController("VPMALT")
End Sub

Sub LoadVBSFiles(VPMver, VBSfile, VBSver)
    On Error Resume Next
    If ScriptEngineMajorVersion < 5 Then MsgBox "VB Script Engine 5.0 or higher required"
    ExecuteGlobal GetTextFile(VBSfile)
    If Err Then MsgBox "Unable to open " & VBSfile & ". Ensure that it is in the same folder as this table. " & vbNewLine & Err.Description    
    InitializeOptions
End Sub

Sub LoadVPinMAME
    Set Controller = CreateObject("VPinMAME.Controller")
    If Err Then MsgBox "Can't load VPinMAME." & vbNewLine & Err.Description
    If VPMver > "" Then If Controller.Version < VPMver Or Err Then MsgBox "VPinMAME ver " & VPMver & " required."
    If VPinMAMEDriverVer < VBSver Or Err Then MsgBox VBSFile & " ver " & VBSver & " or higher required."
    On Error Goto 0
End Sub

Sub LoadController(TableType)
    Dim FileObj
    Dim DOFConfig
    Dim TextStr2
    Dim tempC
    Dim count
    Dim ISDOF
    Dim Answer
    
    B2SOn = True
    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

    If TableType = "PROC" or TableType = "VPMALT" Then
        If TableType = "PROC" Then
            Set Controller = CreateObject("VPROC.Controller")
            If Err Then MsgBox "Can't load PROC"
        Else
            LoadVPinMAME
        End If        
        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
    Else
        If tempC = 0 Then
            On Error Resume Next
            Set Controller = CreateObject("B2S.Server")
            If Controller is Nothing Then
                Err.Clear
                If TableType = "VPM" Then
                    LoadVPinMAME
                End If
            Else
                Controller.B2SName = cGameName
                If TableType = "EM" Then
                    Controller.Run()
                End If
                On Error Goto 0
                B2SOn = True
            End If
        Else
            If TableType = "VPM" Then
                LoadVPinMAME
            End If
        End If
        Set DOFConfig=Nothing
        Set FileObj=Nothing
    End If
End sub

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





' *********************************************************************
' **                                                                 **
' **               Future Pinball Defined Script Events              **
' **                                                                 **
' *********************************************************************


' The Method Is Called Immediately the Game Engine is Ready to
' Start Processing the Script.
'
Sub Table1_Init()
    LoadEM

    Dim i
    Randomize

    'Animation Ball Level
    Set mLevelMagnet = New cvpmMagnet
    With mLevelMagnet
        .InitMagnet LevelMagnet, 5
        .GrabCenter = 0
        .CreateEvents "mLevelMagnet"
    End With
    mLevelMagnet.MagnetOn = 1

    Set LevelBall = BallLevel.Createsizedball(8):LevelBall.Image = "BolaAgua":BallLevel.Kick 0, 0
 
    'Impulse Plunger as autoplunger
    Const IMPowerSetting = 45 ' Plunger Power
    Const IMTime = 1.1        ' Time in seconds for Full Plunge
    Set plungerIM = New cvpmImpulseP
    With plungerIM
        .InitImpulseP swplunger, IMPowerSetting, IMTime
        .Random 1.5
        .InitExitSnd SoundFX("fx_kicker", DOFContactors), SoundFX("fx_solenoid", DOFContactors)
        .CreateEvents "plungerIM"
    End With

    'Boot Pinball
    BootE = True
    Boot.enabled = 1

    'Captive Balls
    kicker3.CreateSizedballWithMass Ballsize/2, BallMass
    kicker3.kick 0,0
    kicker4.CreateSizedballWithMass Ballsize/2, BallMass
    kicker4.kick 0,0
    kicker5.CreateSizedballWithMass Ballsize/2, BallMass
    kicker5.kick 0,0

    ' kill the last switch hit (this this variable is very usefull for game control)
    LastSwitchHit = ""'DummyTrigger

    'load saved values, highscore, names, jackpot
    Loadhs

    'Reset HighScore
    'Reseths

    HighScoreReward = 0
    SpecialHighScoreReward = 0


    ' freeplay or coins
    bFreePlay = False 'we dont want coins

    ' initialse any other flags
    bOnTheFirstBall = False
    bBallInPlungerLane = False
    bBallSaverActive = False
    bBallSaverReady = False
    bMultiBallMode = False
    bGameInPlay = False
    bAutoPlunger = False
    bMusicOn = True
    'BallsOnPlayfield = 0
    BallsInLock = 0
    BallsInHole = 0
    LastSwitchHit = ""
    Tilt = 0
    TiltSensitivity = 6
    Tilted = False
    bBonusHeld = False
    bJustStarted = True
    bInstantInfo = False
    BallsInDrain = 5

    'Replay
    replayscore = 7500000

    If Credits > 0 Then DOF 136, DOFOn
    
End Sub

Dim LevelB
Sub LevelAnim()
    LevelB = True
 If LevelB = True Then
    mLevelMagnet.MagnetOn = 0
    vpmtimer.addtimer 500, "mLevelMagnet.MagnetOn = 1 '"
 end If
End Sub

Sub BallLevelKick_Hit
    BallLevelKick.kick 0, 3
End Sub


Dim bootT
Dim BootE

Sub Boot_Timer
 bootT = bootT + 1
 Select Case bootT
        Case 0:
   hdisplay1.text = "********************************"
   DisplayB2SText "********************************"
   Playsound "fx_sys11_bootup"
        Case 1:
   hdisplay1.text = "////////////////////////////////"
   DisplayB2SText "////////////////////////////////"
   Playsound "fx_sys11_bootup"
        Case 2:
   hdisplay1.text = "********************************"
   DisplayB2SText "********************************"
   Playsound "fx_sys11_bootup"
        Case 3:
   bootT = 0
   BootE = False
   hdisplay1.text = " "
   DisplayB2SText " "
   boot.enabled = 0
   DoorUp 0, 60
   FuturePinball_BeginPlay
   'pDMDSplashBig "GAME OVER", 1, 33023
End Select
End Sub


dim ballindrain

Sub swPlunger_Hit
  bulb1.State = 2

End Sub



'******************************************************
'            STEPS 2-4 (FLIPPER POLARITY SETUP
'******************************************************

dim LF : Set LF = New FlipperPolarity
dim RF : Set RF = New FlipperPolarity

InitPolarity

Sub InitPolarity()
    dim x, a : a = Array(LF, RF)
    for each x in a
        'safety coefficient (diminishes polarity correction only)
        x.AddPoint "Ycoef", 0, RightFlipper.Y-65, 1    'disabled
        x.AddPoint "Ycoef", 1, RightFlipper.Y-11, 1

        x.enabled = True
        x.TimeDelay = 44
    Next

    '"Polarity" Profile
    AddPt "Polarity", 0, 0, 0
    AddPt "Polarity", 1, 0.368, -4
    AddPt "Polarity", 2, 0.451, -3.7
    AddPt "Polarity", 3, 0.493, -3.88
    AddPt "Polarity", 4, 0.65, -2.3
    AddPt "Polarity", 5, 0.71, -2
    AddPt "Polarity", 6, 0.785,-1.8
    AddPt "Polarity", 7, 1.18, -1
    AddPt "Polarity", 8, 1.2, 0

    '"Velocity" Profile
    addpt "Velocity", 0, 0,     1
    addpt "Velocity", 1, 0.16, 1.06
    addpt "Velocity", 2, 0.41,     1.05
    addpt "Velocity", 3, 0.53,     1'0.982
    addpt "Velocity", 4, 0.702, 0.968
    addpt "Velocity", 5, 0.95,  0.968
    addpt "Velocity", 6, 1.03,     0.945

    'LF.Object = LeftFlipper    
    LF.EndPoint = EndPointLp    'you can use just a coordinate, or an object with a .x property. Using a couple of simple primitive objects
    'RF.Object = RightFlipper
    RF.EndPoint = EndPointRp
End Sub

'Trigger Hit - .AddBall activeball
'Trigger UnHit - .PolarityCorrect activeball

Sub TriggerLF_Hit() : LF.Addball activeball : End Sub
Sub TriggerLF_UnHit() : LF.PolarityCorrect activeball : End Sub
Sub TriggerRF_Hit() : RF.Addball activeball : End Sub
Sub TriggerRF_UnHit() : RF.PolarityCorrect activeball : End Sub

'******************************************************
'        FLIPPER CORRECTION SUPPORTING FUNCTIONS
'******************************************************

Sub AddPt(aStr, idx, aX, aY)    'debugger wrapper for adjusting flipper script in-game
    dim a : a = Array(LF, RF)
    dim x : for each x in a
        x.addpoint aStr, idx, aX, aY
    Next
End Sub

'Methods:
'.TimeDelay - Delay before trigger shuts off automatically. Default = 80 (ms)
'.AddPoint - "Polarity", "Velocity", "Ycoef" coordinate points. Use one of these 3 strings, keep coordinates sequential. x = %position on the flipper, y = output
'.Object - set to flipper reference. Optional.
'.StartPoint - set start point coord. Unnecessary, if .object is used.

'Called with flipper -
'ProcessBalls - catches ball data.
' - OR -
'.Fire - fires flipper.rotatetoend automatically + processballs. Requires .Object to be set to the flipper.

Class FlipperPolarity
    Public DebugOn, Enabled
    Private FlipAt    'Timer variable (IE 'flip at 723,530ms...)
    Public TimeDelay    'delay before trigger turns off and polarity is disabled TODO set time!
    private Flipper, FlipperStart, FlipperEnd, LR, PartialFlipCoef
    Private Balls(20), balldata(20)
    
    dim PolarityIn, PolarityOut
    dim VelocityIn, VelocityOut
    dim YcoefIn, YcoefOut
    Public Sub Class_Initialize
        redim PolarityIn(0) : redim PolarityOut(0) : redim VelocityIn(0) : redim VelocityOut(0) : redim YcoefIn(0) : redim YcoefOut(0)
        Enabled = True : TimeDelay = 50 : LR = 1:  dim x : for x = 0 to uBound(balls) : balls(x) = Empty : set Balldata(x) = new SpoofBall : next
    End Sub
    
    Public Property let Object(aInput) : Set Flipper = aInput : StartPoint = Flipper.x : End Property
    Public Property Let StartPoint(aInput) : if IsObject(aInput) then FlipperStart = aInput.x else FlipperStart = aInput : end if : End Property
    Public Property Get StartPoint : StartPoint = FlipperStart : End Property
    Public Property Let EndPoint(aInput) : if IsObject(aInput) then FlipperEnd = aInput.x else FlipperEnd = aInput : end if : End Property
    Public Property Get EndPoint : EndPoint = FlipperEnd : End Property
    
    Public Sub AddPoint(aChooseArray, aIDX, aX, aY) 'Index #, X position, (in) y Position (out)
        Select Case aChooseArray
            case "Polarity" : ShuffleArrays PolarityIn, PolarityOut, 1 : PolarityIn(aIDX) = aX : PolarityOut(aIDX) = aY : ShuffleArrays PolarityIn, PolarityOut, 0
            Case "Velocity" : ShuffleArrays VelocityIn, VelocityOut, 1 :VelocityIn(aIDX) = aX : VelocityOut(aIDX) = aY : ShuffleArrays VelocityIn, VelocityOut, 0
            Case "Ycoef" : ShuffleArrays YcoefIn, YcoefOut, 1 :YcoefIn(aIDX) = aX : YcoefOut(aIDX) = aY : ShuffleArrays YcoefIn, YcoefOut, 0
        End Select
        if gametime > 100 then Report aChooseArray
    End Sub

    Public Sub Report(aChooseArray)     'debug, reports all coords in tbPL.text
        if not DebugOn then exit sub
        dim a1, a2 : Select Case aChooseArray
            case "Polarity" : a1 = PolarityIn : a2 = PolarityOut
            Case "Velocity" : a1 = VelocityIn : a2 = VelocityOut
            Case "Ycoef" : a1 = YcoefIn : a2 = YcoefOut
            case else :tbpl.text = "wrong string" : exit sub
        End Select
        dim str, x : for x = 0 to uBound(a1) : str = str & aChooseArray & " x: " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
        tbpl.text = str
    End Sub
    
    Public Sub AddBall(aBall) : dim x : for x = 0 to uBound(balls) : if IsEmpty(balls(x)) then set balls(x) = aBall : exit sub :end if : Next  : End Sub

    Private Sub RemoveBall(aBall)
        dim x : for x = 0 to uBound(balls)
            if TypeName(balls(x) ) = "IBall" then
                if aBall.ID = Balls(x).ID Then
                    balls(x) = Empty
                    Balldata(x).Reset
                End If
            End If
        Next
    End Sub
    
    Public Sub Fire()
        Flipper.RotateToEnd
        processballs
    End Sub

    Public Property Get Pos 'returns % position a ball. For debug stuff.
        dim x : for x = 0 to uBound(balls)
            if not IsEmpty(balls(x) ) then
                pos = pSlope(Balls(x).x, FlipperStart, 0, FlipperEnd, 1)
            End If
        Next        
    End Property

    Public Sub ProcessBalls() 'save data of balls in flipper range
        FlipAt = GameTime
        dim x : for x = 0 to uBound(balls)
            if not IsEmpty(balls(x) ) then
                balldata(x).Data = balls(x)
                if DebugOn then StickL.visible = True : StickL.x = balldata(x).x        'debug TODO
            End If
        Next
        PartialFlipCoef = ((Flipper.StartAngle - Flipper.CurrentAngle) / (Flipper.StartAngle - Flipper.EndAngle))
        PartialFlipCoef = abs(PartialFlipCoef-1)
        if abs(Flipper.currentAngle - Flipper.EndAngle) < 30 Then
            PartialFlipCoef = 0
        End If
    End Sub
    Private Function FlipperOn() : if gameTime < FlipAt+TimeDelay then FlipperOn = True : End If : End Function    'Timer shutoff for polaritycorrect
    
    Public Sub PolarityCorrect(aBall)
        if FlipperOn() then
            dim tmp, BallPos, x, IDX, Ycoef : Ycoef = 1
            dim teststr : teststr = "Cutoff"
            tmp = PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1)
            if tmp < 0.1 then 'if real ball position is behind flipper, exit Sub to prevent stucks    'Disabled 1.03, I think it's the Mesh that's causing stucks, not this
                if DebugOn then TestStr = "real pos < 0.1 ( " & round(tmp,2) & ")" : tbpl.text = Teststr
                'RemoveBall aBall
                'Exit Sub
            end if

            'y safety Exit
            if aBall.VelY > -8 then 'ball going down
                if DebugOn then teststr = "y velocity: " & round(aBall.vely, 3) & "exit sub" : tbpl.text = teststr
                RemoveBall aBall
                exit Sub
            end if
            'Find balldata. BallPos = % on Flipper
            for x = 0 to uBound(Balls)
                if aBall.id = BallData(x).id AND not isempty(BallData(x).id) then
                    idx = x
                    BallPos = PSlope(BallData(x).x, FlipperStart, 0, FlipperEnd, 1)
                    'TB.TEXT = balldata(x).id & " " & BALLDATA(X).X & VBNEWLINE & FLIPPERSTART & " " & FLIPPEREND
                    if ballpos > 0.65 then  Ycoef = LinearEnvelope(BallData(x).Y, YcoefIn, YcoefOut)                'find safety coefficient 'ycoef' data
                end if
            Next

            if not IsEmpty(VelocityIn(0) ) then
                Dim VelCoef
                if DebugOn then set tmp = new spoofball : tmp.data = aBall : End If
                if IsEmpty(BallData(idx).id) and aBall.VelY < -12 then 'if tip hit with no collected data, do vel correction anyway
                    if PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1) > 1.1 then 'adjust plz
                        VelCoef = LinearEnvelope(5, VelocityIn, VelocityOut)
                        if partialflipcoef < 1 then VelCoef = PSlope(partialflipcoef, 0, 1, 1, VelCoef)
                        if Enabled then aBall.Velx = aBall.Velx*VelCoef'VelCoef
                        if Enabled then aBall.Vely = aBall.Vely*VelCoef'VelCoef
                        if DebugOn then teststr = "tip protection" & vbnewline & "velcoef: " & round(velcoef,3) & vbnewline & round(PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1),3) & vbnewline
                        'debug.print teststr
                    end if
                Else
         :             VelCoef = LinearEnvelope(BallPos, VelocityIn, VelocityOut)
                    if Enabled then aBall.Velx = aBall.Velx*VelCoef
                    if Enabled then aBall.Vely = aBall.Vely*VelCoef
                end if
            End If

            'Polarity Correction (optional now)
            if not IsEmpty(PolarityIn(0) ) then
                If StartPoint > EndPoint then LR = -1    'Reverse polarity if left flipper
                dim AddX : AddX = LinearEnvelope(BallPos, PolarityIn, PolarityOut) * LR
                if Enabled then aBall.VelX = aBall.VelX + 1 * (AddX*ycoef*PartialFlipcoef)
            End If
            'debug
            if DebugOn then
                TestStr = teststr & "%pos:" & round(BallPos,2)
                if IsEmpty(PolarityOut(0) ) then
                    teststr = teststr & vbnewline & "(Polarity Disabled)" & vbnewline
                else
                    teststr = teststr & "+" & round(1 *(AddX*ycoef*PartialFlipcoef),3)
                    if BallPos >= PolarityOut(uBound(PolarityOut) ) then teststr = teststr & "(MAX)" & vbnewline else teststr = teststr & vbnewline end if    
                    if Ycoef < 1 then teststr = teststr &  "ycoef: " & ycoef & vbnewline
                    if PartialFlipcoef < 1 then teststr = teststr & "PartialFlipcoef: " & round(PartialFlipcoef,4) & vbnewline                
                end if

                teststr = teststr & vbnewline & "Vel: " & round(BallSpeed(tmp),2) & " -> " & round(ballspeed(aBall),2) & vbnewline
                teststr = teststr & "%" & round(ballspeed(aBall) / BallSpeed(tmp),2)
                tbpl.text = TestSTR
            end if
        Else
            'if DebugOn then tbpl.text = "td" & timedelay
        End If
        RemoveBall aBall
    End Sub
End Class

'================================
'Helper Functions


Sub ShuffleArray(ByRef aArray, byVal offset) 'shuffle 1d array
    dim x, aCount : aCount = 0
    redim a(uBound(aArray) )
    for x = 0 to uBound(aArray)    'Shuffle objects in a temp array
        if not IsEmpty(aArray(x) ) Then
            if IsObject(aArray(x)) then
                Set a(aCount) = aArray(x)
            Else
                a(aCount) = aArray(x)
            End If
            aCount = aCount + 1
        End If
    Next
    if offset < 0 then offset = 0
    redim aArray(aCount-1+offset)    'Resize original array
    for x = 0 to aCount-1        'set objects back into original array
        if IsObject(a(x)) then
            Set aArray(x) = a(x)
        Else
            aArray(x) = a(x)
        End If
    Next
End Sub

Sub ShuffleArrays(aArray1, aArray2, offset)
    ShuffleArray aArray1, offset
    ShuffleArray aArray2, offset
End Sub


Function BallSpeed(ball) 'Calculates the ball speed
    BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
End Function

Function PSlope(Input, X1, Y1, X2, Y2)    'Set up line via two points, no clamping. Input X, output Y
    dim x, y, b, m : x = input : m = (Y2 - Y1) / (X2 - X1) : b = Y2 - m*X2
    Y = M*x+b
    PSlope = Y
End Function

Function NullFunctionZ(aEnabled):End Function    '1 argument null function placeholder     TODO move me or replac eme

Class spoofball
    Public X, Y, Z, VelX, VelY, VelZ, ID, Mass, Radius
    Public Property Let Data(aBall)
        With aBall
            x = .x : y = .y : z = .z : velx = .velx : vely = .vely : velz = .velz
            id = .ID : mass = .mass : radius = .radius
        end with
    End Property
    Public Sub Reset()
        x = Empty : y = Empty : z = Empty  : velx = Empty : vely = Empty : velz = Empty
        id = Empty : mass = Empty : radius = Empty
    End Sub
End Class


Function LinearEnvelope(xInput, xKeyFrame, yLvl)
    dim y 'Y output
    dim L 'Line
    dim ii : for ii = 1 to uBound(xKeyFrame)    'find active line
        if xInput <= xKeyFrame(ii) then L = ii : exit for : end if
    Next
    if xInput > xKeyFrame(uBound(xKeyFrame) ) then L = uBound(xKeyFrame)    'catch line overrun
    Y = pSlope(xInput, xKeyFrame(L-1), yLvl(L-1), xKeyFrame(L), yLvl(L) )

    'Clamp if on the boundry lines
    'if L=1 and Y < yLvl(LBound(yLvl) ) then Y = yLvl(lBound(yLvl) )
    'if L=uBound(xKeyFrame) and Y > yLvl(uBound(yLvl) ) then Y = yLvl(uBound(yLvl) )
    'clamp 2.0
    if xInput <= xKeyFrame(lBound(xKeyFrame) ) then Y = yLvl(lBound(xKeyFrame) )     'Clamp lower
    if xInput >= xKeyFrame(uBound(xKeyFrame) ) then Y = yLvl(uBound(xKeyFrame) )    'Clamp upper

    LinearEnvelope = Y
End Function



'****************************************************************************
'PHYSICS DAMPENERS

'These are data mined bounce curves,
'dialed in with the in-game elasticity as much as possible to prevent angle / spin issues.
'Requires tracking ballspeed to calculate COR


Sub dPosts_Hit(idx)
    RubbersD.dampen Activeball
End Sub

Sub dSleeves_Hit(idx)
    SleevesD.Dampen Activeball
End Sub


dim RubbersD : Set RubbersD = new Dampener    'frubber
RubbersD.name = "Rubbers"
RubbersD.debugOn = False    'shows info in textbox "TBPout"
RubbersD.Print = False    'debug, reports in debugger (in vel, out cor)
'cor bounce curve (linear)
'for best results, try to match in-game velocity as closely as possible to the desired curve
'RubbersD.addpoint 0, 0, 0.935    'point# (keep sequential), ballspeed, CoR (elasticity)
RubbersD.addpoint 0, 0, 0.96    'point# (keep sequential), ballspeed, CoR (elasticity)
RubbersD.addpoint 1, 3.77, 0.96
RubbersD.addpoint 2, 5.76, 0.967    'dont take this as gospel. if you can data mine rubber elasticitiy, please help!
RubbersD.addpoint 3, 15.84, 0.874
RubbersD.addpoint 4, 56, 0.64    'there's clamping so interpolate up to 56 at least

dim SleevesD : Set SleevesD = new Dampener    'this is just rubber but cut down to 85%...
SleevesD.name = "Sleeves"
SleevesD.debugOn = False    'shows info in textbox "TBPout"
SleevesD.Print = False    'debug, reports in debugger (in vel, out cor)
SleevesD.CopyCoef RubbersD, 0.85

Class Dampener
    Public Print, debugOn 'tbpOut.text
    public name, Threshold     'Minimum threshold. Useful for Flippers, which don't have a hit threshold.
    Public ModIn, ModOut
    Private Sub Class_Initialize : redim ModIn(0) : redim Modout(0): End Sub

    Public Sub AddPoint(aIdx, aX, aY)
        ShuffleArrays ModIn, ModOut, 1 : ModIn(aIDX) = aX : ModOut(aIDX) = aY : ShuffleArrays ModIn, ModOut, 0
        if gametime > 100 then Report
    End Sub

    public sub Dampen(aBall)
        if threshold then if BallSpeed(aBall) < threshold then exit sub end if end if
        dim RealCOR, DesiredCOR, str, coef
        DesiredCor = LinearEnvelope(cor.ballvel(aBall.id), ModIn, ModOut )
        RealCOR = BallSpeed(aBall) / cor.ballvel(aBall.id)
        coef = desiredcor / realcor
        if debugOn then str = name & " in vel:" & round(cor.ballvel(aBall.id),2 ) & vbnewline & "desired cor: " & round(desiredcor,4) & vbnewline & _
        "actual cor: " & round(realCOR,4) & vbnewline & "ballspeed coef: " & round(coef, 3) & vbnewline
        if Print then debug.print Round(cor.ballvel(aBall.id),2) & ", " & round(desiredcor,3)

        aBall.velx = aBall.velx * coef : aBall.vely = aBall.vely * coef
        if debugOn then TBPout.text = str
    End Sub

    Public Sub CopyCoef(aObj, aCoef) 'alternative addpoints, copy with coef
        dim x : for x = 0 to uBound(aObj.ModIn)
            addpoint x, aObj.ModIn(x), aObj.ModOut(x)*aCoef
        Next
    End Sub


    Public Sub Report()     'debug, reports all coords in tbPL.text
        if not debugOn then exit sub
        dim a1, a2 : a1 = ModIn : a2 = ModOut
        dim str, x : for x = 0 to uBound(a1) : str = str & x & ": " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
        TBPout.text = str
    End Sub
    

End Class

'Tracks ball velocity for judging bounce calculations & angle
'apologies to JimmyFingers is this is what his script does. I know his tracks ball velocity too but idk how it works in particular
dim cor : set cor = New CoRTracker
cor.debugOn = False
'cor.update() - put this on a low interval timer
Class CoRTracker
    public DebugOn 'tbpIn.text
    public ballvel

    Private Sub Class_Initialize : redim ballvel(0) : End Sub
    'TODO this would be better if it didn't do the sorting every ms, but instead every time it's pulled for COR stuff
    Public Sub Update()    'tracks in-ball-velocity
        dim str, b, AllBalls, highestID : allBalls = getballs
        if uBound(allballs) < 0 then if DebugOn then str = "no balls" : TBPin.text = str : exit Sub else exit sub end if: end if
        for each b in allballs
            if b.id >= HighestID then highestID = b.id
        Next

        if uBound(ballvel) < highestID then redim ballvel(highestID)    'set bounds

        for each b in allballs
            ballvel(b.id) = BallSpeed(b)
            if DebugOn then
                dim s, bs 'debug spacer, ballspeed
                bs = round(BallSpeed(b),1)
                if bs < 10 then s = " " else s = "" end if
                str = str & b.id & ": " & s & bs & vbnewline
                'str = str & b.id & ": " & s & bs & "z:" & b.z & vbnewline
            end if
        Next
        if DebugOn then str = "ubound ballvels: " & ubound(ballvel) & vbnewline & str : if TBPin.text <> str then TBPin.text = str : end if
    End Sub
End Class

Sub RDampen_Timer()
    Cor.Update
End Sub






'*********
' TILT
'*********

'NOTE: The TiltDecreaseTimer Subtracts .01 from the "Tilt" variable every round

Sub CheckTilt                                    'Called when table is nudged

    Tilt = Tilt + TiltSensitivity                'Add to tilt count
    TiltDecreaseTimer.Enabled = True
    If(Tilt> TiltSensitivity) AND(Tilt <15) Then 'show a warning
        'DMDFlush
        hdisplay1.text = "CAREFUL!"
        'pDMDSplashBig "CAREFUL", 2, 33023
        Playsound "jycsfx26"
    End if
    If Tilt> 15 Then 'If more that 15 then TILT the table
        Tilted = True
        Playsound "tilt"
        PlaySong "mu_end"
        'display Tilt
        DMDUpdate.Enabled = 0
        hdisplay1.text = "TILT!"
        'pDMDSplashBig "TILT", 9999, 33023
        DisableTable True
        TiltRecoveryTimer.Enabled = True 'start the Tilt delay to check for all the balls to be drained
    End If
End Sub

Sub TiltDecreaseTimer_Timer
    ' DecreaseTilt
    If Tilt> 0 Then
        Tilt = Tilt - 0.1
    Else
        TiltDecreaseTimer.Enabled = False
    End If
End Sub

Sub DisableTable(Enabled)
    If Enabled Then
        'turn off GI and turn off all the lights
        GiOff
        LightSeqTilt.Play SeqAllOff
        'Disable slings, bumpers etc
        LeftFlipper.RotateToStart
        RightFlipper.RotateToStart
        DOF 101, DOFOff
        DOF 102, DOFOff
        Bumper1.Force = 0
        Bumper2.Force = 0
        Bumper3.Force = 0
        Bumper4.Force = 0
        LeftSlingshotRubber.Disabled = 1
        RightSlingshotRubber.Disabled = 1
        LeftSlingshotRubber1.Disabled = 1
        RightSlingShotRubber1.Disabled = 1
        skilltimer1.Enabled = false
        skilltimer2.Enabled = false
        skilltimer3.Enabled = false
        skilltimer4.Enabled = false
        skilltimer5.Enabled = false
    Else
        'turn back on GI and the lights
        GiOn
        LightSeqTilt.StopPlay
        Bumper1.Force = 8
        Bumper2.Force = 8
        Bumper3.Force = 8
        Bumper4.Force = 8
        LeftSlingshotRubber.Disabled = 0
        RightSlingshotRubber.Disabled = 0
        LeftSlingshotRubber1.Disabled = 0
        RightSlingShotRubber1.Disabled = 0
    End If
End Sub

Sub TiltRecoveryTimer_Timer()
    ' if all the balls have been drained then..
    If(BallsOnPlayfield = 0) Then
        ' do the normal end of ball thing (this doesn't give a bonus if the table is tilted)
        EndOfBall()
        TiltRecoveryTimer.Enabled = False
    End If
' else retry (checks again in another second or so)
End Sub







'**********************
'     GI effects
' independent routine
' it turns on the gi
' when there is a ball
' in play
'**********************

Dim OldGiState
OldGiState = -1   'start witht the Gi off

Sub ChangeGi(col) 'changes the gi color
    Dim bulb
    For each bulb in aGILights
        SetLightColor bulb, col, -1
    Next
End Sub

Sub GIUpdateTimer_Timer
    Dim tmp, obj
    tmp = Getballs
    If UBound(tmp) <> OldGiState Then
        OldGiState = Ubound(tmp)
        If UBound(tmp) = 3 Then 'we have 4 captive balls on the table (-1 means no balls, 0 is the first ball, 1 is the second..)
            GiOff               ' turn off the gi if no active balls on the table, we could also have used the variable ballsonplayfield.
        Else
            Gion
        End If
    End If
End Sub

Sub GiOn
    DOF 126, DOFOn
    Dim bulb
    For each bulb in aGiLights
        bulb.State = 1
    Next
    Table1.ColorGradeImage = "ColorGradeLUT256x16_ConSat"
    Luz_Mesh.visible = 1
End Sub

Sub GiOff
    DOF 126, DOFOff
    Dim bulb
    For each bulb in aGiLights
        bulb.State = 0
    Next
    Table1.ColorGradeImage = "ColorGradeLUT256x16_ConSatDark"
    Luz_Mesh.visible = 0
End Sub



' GI & light sequence effects

Sub GiEffect(n)
    Dim ii
    Select Case n
        Case 0 'all off
            LightSeqGi.Play SeqAlloff
        Case 1 'all blink
            LightSeqGi.UpdateInterval = 10
            LightSeqGi.Play SeqBlinking, , 10, 10
        Case 2 'random
            LightSeqGi.UpdateInterval = 10
            LightSeqGi.Play SeqRandom, 50, , 1000
        Case 3 'upon
            LightSeqGi.UpdateInterval = 4
            LightSeqGi.Play SeqUpOn, 5, 1
        Case 4 ' left-right-left
            LightSeqGi.UpdateInterval = 5
            LightSeqGi.Play SeqLeftOn, 10, 1
            LightSeqGi.UpdateInterval = 5
            LightSeqGi.Play SeqRightOn, 10, 1
    End Select
End Sub

Sub LightEffect(n)
    Select Case n
        Case 0 ' all off
            LightSeqInserts.Play SeqAlloff
        Case 1 'all blink
            LightSeqInserts.UpdateInterval = 10
            LightSeqInserts.Play SeqBlinking, , 10, 10
        Case 2 'random
            LightSeqInserts.UpdateInterval = 10
            LightSeqInserts.Play SeqRandom, 50, , 1000
        Case 3 'upon
            LightSeqInserts.UpdateInterval = 4
            LightSeqInserts.Play SeqUpOn, 10, 1
        Case 4 ' left-right-left
            LightSeqInserts.UpdateInterval = 5
            LightSeqInserts.Play SeqLeftOn, 10, 1
            LightSeqInserts.UpdateInterval = 5
            LightSeqInserts.Play SeqRightOn, 10, 1
    End Select
End Sub

' Flasher Effects using lights

Dim FEStep, FEffect
FEStep = 0
FEffect = 0

Sub FlashEffect(n)
    Dim ii
    Select case n
        Case 0 ' all off
            LightSeqFlasher.Play SeqAlloff
        Case 1 'all blink
            LightSeqFlasher.UpdateInterval = 10
            LightSeqFlasher.Play SeqBlinking, , 10, 10
        Case 2 'random
            LightSeqFlasher.UpdateInterval = 10
            LightSeqFlasher.Play SeqRandom, 50, , 1000
        Case 3 'upon
            LightSeqFlasher.UpdateInterval = 4
            LightSeqFlasher.Play SeqUpOn, 10, 1
        Case 4 ' left-right-left
            LightSeqFlasher.UpdateInterval = 5
            LightSeqFlasher.Play SeqLeftOn, 10, 1
            LightSeqFlasher.UpdateInterval = 5
            LightSeqFlasher.Play SeqRightOn, 10, 1
    End Select
End Sub


'****************************************
' Real Time updatess using the GameTimer
'****************************************
'used for all the real time updates

Sub GameTimer_Timer
    RollingUpdate
    BallShadowUpdate

    'leftdiverterP.objRotZ = leftdiverter.CurrentAngle
   ' rightdiverterP.objRotZ = rightdiverter.CurrentAngle


End Sub


'********************************************************************************************
' Only for VPX 10.2 and higher.
' FlashForMs will blink light or a flasher for TotalPeriod(ms) at rate of BlinkPeriod(ms)
' When TotalPeriod done, light or flasher will be set to FinalState value where
' Final State values are:   0=Off, 1=On, 2=Return to previous State
'********************************************************************************************

    Sub FlashForMs(MyLight, TotalPeriod, BlinkPeriod, FinalState) 'thanks gtxjoe for the first version

        If TypeName(MyLight) = "Light" Then

            If FinalState = 2 Then
                FinalState = MyLight.State 'Keep the current light state
            End If
            MyLight.BlinkInterval = BlinkPeriod
            MyLight.Duration 2, TotalPeriod, FinalState
        ElseIf TypeName(MyLight) = "Flasher" Then

            Dim steps

            ' Store all blink information
            steps = Int(TotalPeriod / BlinkPeriod + .5) 'Number of ON/OFF steps to perform
            If FinalState = 2 Then                      'Keep the current flasher state
                FinalState = ABS(MyLight.Visible)
            End If
            MyLight.UserValue = steps * 10 + FinalState 'Store # of blinks, and final state

            ' Start blink timer and create timer subroutine
            MyLight.TimerInterval = BlinkPeriod
            MyLight.TimerEnabled = 0
            MyLight.TimerEnabled = 1
            ExecuteGlobal "Sub " & MyLight.Name & "_Timer:" & "Dim tmp, steps, fstate:tmp=me.UserValue:fstate = tmp MOD 10:steps= tmp\10 -1:Me.Visible = steps MOD 2:me.UserValue = steps *10 + fstate:If Steps = 0 then Me.Visible = fstate:Me.TimerEnabled=0:End if:End Sub"
        End If
    End Sub

'******************************************
    ' Change light color - simulate color leds
    ' changes the light color and state
    ' 10 colors: red, orange, amber, yellow...
    '******************************************
    ' in this table this colors are use to keep track of the progress during the acts and battles

    'colors
    Dim red, orange, amber, yellow, darkgreen, green, blue, darkblue, purple, white, base

    red = 10
    orange = 9
    amber = 8
    yellow = 7
    darkgreen = 6
    green = 5
    blue = 4
    darkblue = 3
    purple = 2
    white = 1
    base = 11

    Sub SetLightColor(n, col, stat)
        Select Case col
            Case red
                n.color = RGB(18, 0, 0)
                n.colorfull = RGB(255, 0, 0)
            Case orange
                n.color = RGB(18, 3, 0)
                n.colorfull = RGB(255, 64, 0)
            Case amber
                n.color = RGB(193, 49, 0)
                n.colorfull = RGB(255, 153, 0)
            Case yellow
                n.color = RGB(18, 18, 0)
                n.colorfull = RGB(255, 255, 0)
            Case darkgreen
                n.color = RGB(0, 8, 0)
                n.colorfull = RGB(0, 64, 0)
            Case green
                n.color = RGB(0, 18, 0)
                n.colorfull = RGB(0, 255, 0)
            Case blue
                n.color = RGB(0, 18, 18)
                n.colorfull = RGB(0, 255, 255)
            Case darkblue
                n.color = RGB(0, 8, 8)
                n.colorfull = RGB(0, 64, 64)
            Case purple
                n.color = RGB(128, 0, 128)
                n.colorfull = RGB(255, 0, 255)
            Case white
                n.color = RGB(255, 252, 224)
                n.colorfull = RGB(193, 91, 0)
            Case base
                n.color = RGB(255, 197, 143)
                n.colorfull = RGB(255, 255, 236)
        End Select
        If stat <> -1 Then
            n.State = 0
            n.State = stat
        End If
    End Sub

    Sub ResetAllLightsColor ' Called at a new game
        SetLightColor toplane1l, green, -1    
        SetLightColor toplane2l, green, -1    
        SetLightColor toplane3l, green, -1

        SetLightColor topbank1l, red, -1
        SetLightColor topbank2l, red, -1
        SetLightColor topbank3l, red, -1

        SetLightColor locollect, amber, -1
        SetLightColor lojackpot, amber, -1

        SetLightColor rocollect, amber, -1
        SetLightColor rojackpot, amber, -1

        SetLightColor tavernstashl, red, -1
        SetLightColor tavern1l, red, -1

        SetLightColor rain1, red, -1
        SetLightColor rain2, orange, -1
        SetLightColor rain3, yellow, -1
        SetLightColor rain4, green, -1
        SetLightColor rain5, blue, -1
        SetLightColor rain6, purple, -1

        SetLightColor findkey, amber, -1
        SetLightColor keyl, amber, -1

        SetLightColor pointsbank, green, -1
        SetLightColor pointsbanka, green, -1
        SetLightColor points10, darkgreen, -1
        SetLightColor points20, darkgreen, -1
        SetLightColor points30, darkgreen, -1
        SetLightColor points40, darkgreen, -1
        SetLightColor points50, darkgreen, -1
        SetLightColor points60, darkgreen, -1
        SetLightColor points70, darkgreen, -1
        SetLightColor points80, darkgreen, -1
        SetLightColor points90, darkgreen, -1

        SetLightColor lep51l, white, -1
        SetLightColor lep52l, amber, -1

        SetLightColor lep41l, white, -1
        SetLightColor lep42l, amber, -1

        SetLightColor lep31l, white, -1
        SetLightColor lep32l, amber, -1

        SetLightColor lep21l, white, -1
        SetLightColor lep22l, amber, -1

        SetLightColor lep11l, white, -1
        SetLightColor lep12l, amber, -1

        SetLightColor twoxl, red, -1
        SetLightColor threexl, red, -1

        SetLightColor score1l, yellow, -1
        SetLightColor score2l, yellow, -1
        SetLightColor score3l, yellow, -1
        SetLightColor score4l, yellow, -1
        SetLightColor score5l, yellow, -1

        SetLightColor ebl, green, -1
        SetLightColor ebr, green, -1

        SetLightColor lane1l, orange, -1
        SetLightColor lane2l, orange, -1
        SetLightColor lane3l, orange, -1
        SetLightColor lane4l, orange, -1

        SetLightColor kickbackll, darkgreen, -1
        SetLightColor kickbackrl, darkgreen, -1

        SetLightColor LightShootAgain, red, -1
        
    End Sub

    Sub UpdateBonusColors
    End Sub

    '*************************
    ' Rainbow Changing Lights
    '*************************

    Dim RGBStep, RGBFactor, rRed, rGreen, rBlue, RainbowLights

    Sub StartRainbow(n)
        set RainbowLights = n
        RGBStep = 0
        RGBFactor = 5
        rRed = 255
        rGreen = 0
        rBlue = 0
        RainbowTimer.Enabled = 1
    End Sub

    Dim RGBStep2, RGBFactor2, rRed2, rGreen2, rBlue2, RainbowLights2
    Sub StartRainbow2(n)
        set RainbowLights2 = n
        RGBStep2 = 0
        RGBFactor2 = 5
        rRed2 = 255
        rGreen2 = 0
        rBlue2 = 0
        RainbowTimer1.Enabled = 1
    End Sub


    Dim RGBStep3, RGBFactor3, rRed3, rGreen3, rBlue3, RainbowLights3
    Sub StartRainbow3(n)
        set RainbowLights3 = n
        RGBStep3 = 0
        RGBFactor3 = 5
        rRed3 = 255
        rGreen3 = 0
        rBlue3 = 0
        RainbowTimer2.Enabled = 1
    End Sub

    Sub StopRainbow(n)
        Dim obj
        RainbowTimer.Enabled = 0
        RainbowTimer.Enabled = 0
            For each obj in RainbowLights
                SetLightColor obj, "white", 0
            Next
    End Sub

    Sub StopRainbow2(n)
        Dim obj
        RainbowTimer1.Enabled = 0
            For each obj in RainbowLights2
                SetLightColor obj, "white", 0
                obj.state = 1
                obj.Intensity = 12
            Next
    End Sub

    Sub RainbowTimer_Timer 'rainbow led light color changing
        Dim obj
        Select Case RGBStep
            Case 0 'Green
                rGreen = rGreen + RGBFactor
                If rGreen > 255 then
                    rGreen = 255
                    RGBStep = 1
                End If
            Case 1 'Red
                rRed = rRed - RGBFactor
                If rRed < 0 then
                    rRed = 0
                    RGBStep = 2
                End If
            Case 2 'Blue
                rBlue = rBlue + RGBFactor
                If rBlue > 255 then
                    rBlue = 255
                    RGBStep = 3
                End If
            Case 3 'Green
                rGreen = rGreen - RGBFactor
                If rGreen < 0 then
                    rGreen = 0
                    RGBStep = 4
                End If
            Case 4 'Red
                rRed = rRed + RGBFactor
                If rRed > 255 then
                    rRed = 255
                    RGBStep = 5
                End If
            Case 5 'Blue
                rBlue = rBlue - RGBFactor
                If rBlue < 0 then
                    rBlue = 0
                    RGBStep = 0
                End If
        End Select
            For each obj in RainbowLights
                obj.color = RGB(rRed \ 10, rGreen \ 10, rBlue \ 10)
                obj.colorfull = RGB(rRed, rGreen, rBlue)
            Next
    End Sub

    Sub RainbowTimer1_Timer 'rainbow led light color changing
        Dim obj
        Select Case RGBStep2
            Case 0 'Green
                rGreen2 = rGreen2 + RGBFactor2
                If rGreen2 > 255 then
                    rGreen2 = 255
                    RGBStep2 = 1
                End If
            Case 1 'Red
                rRed2 = rRed2 - RGBFactor2
                If rRed2 < 0 then
                    rRed2 = 0
                    RGBStep2 = 2
                End If
            Case 2 'Blue
                rBlue2 = rBlue2 + RGBFactor2
                If rBlue2 > 255 then
                    rBlue2 = 255
                    RGBStep2 = 3
                End If
            Case 3 'Green
                rGreen2 = rGreen2 - RGBFactor2
                If rGreen2 < 0 then
                    rGreen2 = 0
                    RGBStep2 = 4
                End If
            Case 4 'Red
                rRed2 = rRed2 + RGBFactor2
                If rRed2 > 255 then
                    rRed2 = 255
                    RGBStep2 = 5
                End If
            Case 5 'Blue
                rBlue2 = rBlue2 - RGBFactor2
                If rBlue2 < 0 then
                    rBlue2 = 0
                    RGBStep2 = 0
                End If
        End Select
            For each obj in RainbowLights2
                obj.color = RGB(rRed2 \ 10, rGreen2 \ 10, rBlue2 \ 10)
                obj.colorfull = RGB(rRed2, rGreen2, rBlue2)
            Next
    End Sub


    Sub RainbowTimer2_Timer 'rainbow led light color changing
        Dim obj
        Select Case RGBStep3
            Case 0 'Green
                rGreen3 = rGreen3 + RGBFactor3
                If rGreen3 > 255 then
                    rGreen3 = 255
                    RGBStep3 = 1
                End If
            Case 1 'Red
                rRed3 = rRed3 - RGBFactor3
                If rRed3 < 0 then
                    rRed3 = 0
                    RGBStep3 = 2
                End If
            Case 2 'Blue
                rBlue3 = rBlue3 + RGBFactor3
                If rBlue3 > 255 then
                    rBlue3 = 255
                    RGBStep3 = 3
                End If
            Case 3 'Green
                rGreen3 = rGreen3 - RGBFactor3
                If rGreen3 < 0 then
                    rGreen3 = 0
                    RGBStep3 = 4
                End If
            Case 4 'Red
                rRed3 = rRed3 + RGBFactor3
                If rRed3 > 255 then
                    rRed3 = 255
                    RGBStep3 = 5
                End If
            Case 5 'Blue
                rBlue3 = rBlue3 - RGBFactor3
                If rBlue3 < 0 then
                    rBlue3 = 0
                    RGBStep3 = 0
                End If
        End Select
            For each obj in RainbowLights3
                obj.color = RGB(rRed3 \ 10, rGreen3 \ 10, rBlue3 \ 10)
                obj.colorfull = RGB(rRed3, rGreen3, rBlue3)
            Next
    End Sub








' *********************************************************************
'               Funciones para los sonidos de la mesa
' *********************************************************************

Function Vol(ball) ' Calcula el volumen del sonido basado en la velocidad de la bola
    Vol = Csng(BallVel(ball) ^2 / 2000)
End Function

Function Pan(ball) ' Calculala posición estéreo de la bola (izquierda a derecha)
    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 Pitch(ball) ' Calcula el tono según la velocidad de la bola
    Pitch = BallVel(ball) * 20
End Function

Function BallVel(ball) 'Calcula la velocidad de la bola
    BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2)))
End Function

Function AudioFade(ball) 'Solo para VPX 10.4 y siguentes: calcula la posición de arriba/abajo de la bola, para mesas con el sonido dolby
    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 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

Sub PlaySoundAt(soundname, tableobj) ' Hace sonar un sonido en la posición de un objeto, como bumpers y flippers
    PlaySound soundname, 0, 1, Pan(tableobj), 0, 0, 0, 0, AudioFade(tableobj)
End Sub

Sub PlaySoundAtBall(soundname) ' hace sonar un sonido en la posición de la bola
    PlaySound soundname, 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
End Sub

Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
    PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
End Sub

'*****************************************
'      Los sonidos de la bola/s rodando
'*****************************************

Const tnob = 18 ' número total de bola
Const lob = 4  'número de bola encerradas
ReDim rolling(tnob)
InitRolling

Sub InitRolling
    Dim i
    For i = 0 to tnob
        rolling(i) = False
    Next
End Sub

Sub RollingUpdate()
    Dim BOT, b, ballpitch
    BOT = GetBalls

    ' para el sonido de bolas perdidas
    For b = UBound(BOT) + 1 to tnob
        rolling(b) = False
        StopSound("fx_ballrolling" & b)
    Next

    ' sale de la rutina si no hay más bolas en la mesa
    If UBound(BOT) = lob - 1 Then Exit Sub

    ' hace sonar el sonido de la bola rodando para cada bola
    For b = lob to UBound(BOT)
        If BallVel(BOT(b)) > 1 Then
            If BOT(b).z < 30 Then
                ballpitch = Pitch(BOT(b))
            Else
                ballpitch = Pitch(BOT(b)) + 20000 'aumenta el tono del sonido si la bola está sobre una rampa
            End If
            rolling(b) = True
            PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), Pan(BOT(b)), 0, ballpitch, 1, 0, AudioFade(BOT(b))
        Else
            If rolling(b) = True Then
                StopSound("fx_ballrolling" & b)
                rolling(b) = False
            End If
        End If

        '***Sonido de Bola Rebotando***
        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

'*****************************
' Sonido de las bolas chocando
'*****************************

Sub OnBallBallCollision(ball1, ball2, velocity)
    PlaySound "fx_collide", 0, Csng(velocity) ^2 / 2000, Pan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
End Sub





'*********** BALL SHADOW *********************************
Dim BallShadow
BallShadow = Array (BallShadow1, BallShadow2, BallShadow3, BallShadow4, BallShadow5, BallShadow6, BallShadow7, BallShadow8, BallShadow9, BallShadow10, BallShadow11, BallShadow12)

Sub BallShadowUpdate()
    Dim BOT, b
    BOT = GetBalls
    ' 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))/10)) + 10
        Else
            BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/10)) - 10
        End If
        ballShadow(b).Y = BOT(b).Y + 15
        If BOT(b).Z > 20 Then
            BallShadow(b).visible = 1
        Else
            BallShadow(b).visible = 0
        End If
    Next
End Sub



'*****************************************
'    ninuzzu's    FLIPPER SHADOWS
'*****************************************

sub FlipperTimer_Timer()
    FlipperLSh.RotZ = LeftFlipper.currentangle
    FlipperRSh.RotZ = RightFlipper.currentangle

End Sub



'******************************
' Diverse Collection Hit Sounds
'******************************

Sub aMetals_Hit(idx):PlaySound "fx_MetalHit", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
Sub aRubber_Bands_Hit(idx):PlaySound "fx_rubber", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
Sub aRubber_Posts_Hit(idx):PlaySound "fx_rubber", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
Sub aRubber_Pins_Hit(idx):PlaySound "fx_rubber", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
Sub aPlastics_Hit(idx):PlaySound "fx_plastichit", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
Sub aDropTargets_Hit(idx):PlaySound "fx_target", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
Sub aGates_Hit(idx):PlaySound "fx_Gate", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
Sub aWoods_Hit(idx):PlaySound "fx_Woodhit", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub

Sub TriggerRamp_Hit
    StopSound "fx_metalrolling"
    PlaySound "fx_metalrolling", 0, 1, pan(ActiveBall)
End Sub

Sub RHelp2_Hit()
    StopSound "fx_metalrolling"
    PlaySound "fx_ballrampdrop", 0, 1, pan(ActiveBall)
End Sub

Sub LHelp1_Hit()
    StopSound "fx_metalrolling"
    PlaySound "fx_ballrampdrop", 0, 1, pan(ActiveBall)
End Sub



'Sub Trigger2_hit()
'    PlaySound "fx_metalrolling", 0, 1, pan(ActiveBall)
'End Sub

' *********************************************************************
'                        User Defined Script Events
' *********************************************************************

' Initialise the Table for a new Game
'

Sub StopGameOverSong
    PlaySong "mu_end"
    StopSound Song:Song = ""
    StopAllSounds
End Sub






'******
' Keys
'******

Sub Table1_KeyDown(ByVal Keycode)

  If BootE = True Then Exit Sub
    If Keycode = AddCreditKey Then
        Credits = Credits + 1
        DOF 126, DOFOn
        If(Tilted = False) Then
            PlaySound "fx_coin"
              'startB2S (31)
           ' DisplayB2SText2 " CREDITS " &credits
            hdisplay1.Text = " CREDITS " &credits
'            PuPlayer.playlistplayex pDMD,"DMDBackground","backdmd.jpg",0,1
'            pDMDSplashBonus "CREDITS " & credits ,"PRESS START BUTTON",10,33023
'            PuPlayer.playlistplayex pDMD,"DMDBackground","GooniesLogoDMD.png",0,1
            PlaySound "go"
       '     If NOT bGameInPlay Then ShowTableInfo:
        End If
    End If

    If keycode = PlungerKey Then
        PlungerIM.AutoFire
       If bBallInPlungerLane Then DOF 125, DOFPulse: DOF 114, DOFPulse
    End If

    If bGameInPlay AND NOT Tilted Then
        If keycode = LeftTiltKey Then Nudge 90, 6:PlaySound "fx_nudge", 0, 1, -0.1, 0.25:CheckTilt
        If keycode = RightTiltKey Then Nudge 270, 6:PlaySound "fx_nudge", 0, 1, 0.1, 0.25:CheckTilt
        If keycode = CenterTiltKey Then LevelAnim :Nudge 0, 7:PlaySound "fx_nudge", 0, 1, 1, 0.25:CheckTilt

        If keycode = LeftFlipperKey Then SolLFlipper 1
        If keycode = RightFlipperKey Then SolRFlipper 1


        If keycode = StartGameKey And bAttractMode = True Then
            If((PlayersPlayingGame < MaxPlayers) AND(bOnTheFirstBall = True) ) Then

                If(bFreePlay = True) Then
                    PlayersPlayingGame = PlayersPlayingGame + 1
                    TotalGamesPlayed = TotalGamesPlayed + 1
                Else

                    If(Credits > 0) then
                        PlayersPlayingGame = PlayersPlayingGame + 1
                        TotalGamesPlayed = TotalGamesPlayed + 1
                        Credits = Credits - 1
                        If Credits < 1 Then DOF 126, DOFOff
                    Else
                        ' Not Enough Credits to start a game.

                        'DMD CenterLine(0, "CREDITS " & Credits), CenterLine(1, "INSERT COIN"), 0, eNone, eBlink, eNone, 500, True, ""
                    End If
                End If
            End If
        End If
        Else ' If (GameInPlay)

            If keycode = StartGameKey And bAttractMode = True Then

                If(bFreePlay = True) Then
                    If(BallsOnPlayfield = 0) Then
                        ResetForNewGame()
                    End If
                Else
                    If(Credits > 0) Then
                        If(BallsOnPlayfield = 0) Then
                            Credits = Credits - 1
                            If Credits < 1 Then DOF 126, DOFOff
                            ResetForNewGame()
                        End If
                    Else
                        ' Not Enough Credits to start a game.
                        hdisplay1.Text = " CREDITS " &credits&"   INSERT COIN"
'                        PuPlayer.playlistplayex pDMD,"DMDBackground","backdmd.jpg",0,1
'                        pDMDSplashBonus "CREDITS " & credits ,"INSERT COIN",10,33023
'                        PuPlayer.playlistplayex pDMD,"DMDBackground","GooniesLogoDMD.png",0,1
                        
                    End If
                End If
            End If
    End If ' If (GameInPlay)


    If hsbModeActive Then EnterHighScoreKey(keycode)

    If SpecialhsbModeActive Then EnterSpecialHighScoreKey(keycode)

' Table specific
End Sub

Sub Table1_KeyUp(ByVal keycode)
    If bGameInPLay AND NOT Tilted Then
        If keycode = LeftFlipperKey Then SolLFlipper 0
        If keycode = RightFlipperKey Then SolRFlipper 0
    End If
End Sub




'********************
'     Flippers
'********************

Sub SolLFlipper(Enabled)
'    startB2S(4)
    If Enabled Then
        'PlaySound SoundFXDOF("fx_flipperup", 101, DOFOn, DOFFlippers), 0, 1, -0.05, 0.15
        PlaySound SoundFX("fx_flipperup",DOFFlippers), 0, .67, AudioPan(LeftFlipper), 0.05,0,0,1,AudioFade(LeftFlipper)
        LeftFlipper.RotateToEnd
        leftlight
    Else
        'PlaySound SoundFXDOF("fx_flipperdown", 101, DOFOff, DOFFlippers), 0, 1, -0.05, 0.15
        PlaySound SoundFX("fx_flipperdown",DOFFlippers), 0, 1, AudioPan(LeftFlipper), 0.05,0,0,1,AudioFade(LeftFlipper)
        LeftFlipper.RotateToStart
    End If
End Sub

Sub SolRFlipper(Enabled)
'    startB2S(4)
    If Enabled Then
      '  PlaySound SoundFXDOF("fx_flipperup", 102, DOFOn, DOFFlippers), 0, 1, 0.05, 0.15
        PlaySound SoundFX("fx_flipperup",DOFFlippers), 0, .67, AudioPan(RightFlipper), 0.05,0,0,1,AudioFade(RightFlipper)
        RightFlipper.RotateToEnd
        rightlight      
    Else
        'PlaySound SoundFXDOF("fx_flipperdown", 102, DOFOff, DOFFlippers), 0, 1, 0.05, 0.15
        PlaySound SoundFX("fx_flipperdown",DOFFlippers), 0, 1, AudioPan(RightFlipper), 0.05,0,0,1,AudioFade(RightFlipper)
        RightFlipper.RotateToStart
    End If
End Sub

' flippers hit Sound

Sub LeftFlipper_Collide(parm)
    PlaySound "fx_rubber_flipper", 0, parm / 10, -0.05, 0.25
End Sub

Sub RightFlipper_Collide(parm)
    PlaySound "fx_rubber_flipper", 0, parm / 10, 0.05, 0.25
End Sub






Sub InstantInfoTimer_Timer
    InstantInfoTimer.Enabled = False
    bInstantInfo = True
'    DMDFlush
'    UltraDMDTimer.Enabled = 1
End Sub

Sub InstantInfo
     hdisplay1.Text = " POW " &POWBonusCount
 '   Jackpot = 1000000 + Round(Score(CurrentPlayer) / 10, 0)
 '   DMD "black.jpg", "", "INSTANT INFO", 500
 '   DMD "black.jpg", "JACKPOT", Jackpot, 800
 '   DMD "black.jpg", "LEVEL", Level(CurrentPlayer), 800
 '   DMD "black.jpg", "BONUS MULT", BonusMultiplier(CurrentPlayer), 800
 '   DMD "black.jpg", "ORBIT BONUS", OrbitHits, 800
  '  DMD "black.jpg", "LANE BONUS", LaneBonus, 800
   ' DMD "black.jpg", "TARGET BONUS", TargetBonus, 800
  '  DMD "black.jpg", "RAMP BONUS", RampBonus, 800
 '   DMD "black.jpg", "MONSTERS KILLED", Monsters(CurrentPlayer), 800
End Sub



'*************
' Pause Table
'*************

Sub table1_Paused
End Sub

Sub table1_unPaused
End Sub

Sub table1_Exit
    Savehs
    If B2SOn Then Controller.Stop
End Sub

Sub AwardSpecial()
    'DMD " ", "EXTRA GAME", 2000
    hdisplay1.text = "EXTRA GAME"& "    CREDITS:  "& Credits
    'PlaySound SoundFXDOF("fx_knocker",124,DOFPulse,DOFKnocker)

    DOF 140, DOFOn
    PlaySound SoundFXDOF("fx_knocker",136,DOFPulse,DOFKnocker)        
    DOF 115, DOFPulse

    Credits = Credits + 1
    DisplayB2SText2 "   EXTRA GAME   " & "    CREDITS:  "& Credits
    LightEffect 2
    FlashEffect 2
End Sub

'*****************************
'    Load / Save / Highscore
'*****************************

Sub Loadhs
    Dim x
    x = LoadValue(TableName, "HighScore1")
    If(x <> "") Then HighScore(0) = CDbl(x) Else HighScore(0) = 9000000 End If

    x = LoadValue(TableName, "HighScore1Name")
    If(x <> "") Then HighScoreName(0) = x Else HighScoreName(0) = "AAA" End If

    x = LoadValue(TableName, "HighScore2")
    If(x <> "") then HighScore(1) = CDbl(x) Else HighScore(1) = 8500000 End If

    x = LoadValue(TableName, "HighScore2Name")
    If(x <> "") then HighScoreName(1) = x Else HighScoreName(1) = "BBB" End If

    x = LoadValue(TableName, "HighScore3")
    If(x <> "") then HighScore(2) = CDbl(x) Else HighScore(2) = 8000000 End If

    x = LoadValue(TableName, "HighScore3Name")
    If(x <> "") then HighScoreName(2) = x Else HighScoreName(2) = "CCC" End If

    x = LoadValue(TableName, "HighScore4")
    If(x <> "") then HighScore(3) = CDbl(x) Else HighScore(3) = 7500000 End If

    x = LoadValue(TableName, "HighScore4Name")
    If(x <> "") then HighScoreName(3) = x Else HighScoreName(3) = "DDD" End If



    x = LoadValue(TableName, "SpecialHighScore1")
    If(x <> "") Then SpecialHighScore(0) = CDbl(x) Else SpecialHighScore(0) = 4 End If

    x = LoadValue(TableName, "SpecialHighScore1Name")
    If(x <> "") Then SpecialHighScoreName(0) = x Else SpecialHighScoreName(0) = "AAA" End If

    x = LoadValue(TableName, "SpecialHighScore2")
    If(x <> "") then SpecialHighScore(1) = CDbl(x) Else SpecialHighScore(1) = 3 End If

    x = LoadValue(TableName, "SpecialHighScore2Name")
    If(x <> "") then SpecialHighScoreName(1) = x Else SpecialHighScoreName(1) = "BBB" End If

    x = LoadValue(TableName, "SpecialHighScore3")
    If(x <> "") then SpecialHighScore(2) = CDbl(x) Else SpecialHighScore(2) = 2 End If

    x = LoadValue(TableName, "SpecialHighScore3Name")
    If(x <> "") then SpecialHighScoreName(2) = x Else SpecialHighScoreName(2) = "CCC" End If

    x = LoadValue(TableName, "SpecialHighScore4")
    If(x <> "") then SpecialHighScore(3) = CDbl(x) Else SpecialHighScore(3) = 1 End If

    x = LoadValue(TableName, "SpecialHighScore4Name")
    If(x <> "") then SpecialHighScoreName(3) = x Else SpecialHighScoreName(3) = "DDD" End If



    x = LoadValue(TableName, "Credits")
    If(x <> "") then Credits = CInt(x) Else Credits = 0 End If

    x = LoadValue(TableName, "TotalGamesPlayed")
    If(x <> "") then TotalGamesPlayed = CInt(x) Else TotalGamesPlayed = 0 End If

  '  x = LoadValue(TableName, "Score")
  '  If(x <> "") then Score(CurrentPlayer) = CInt(x) Else Score(CurrentPlayer) = 0 End If
End Sub

Sub Savehs
    SaveValue TableName, "HighScore1", HighScore(0)
    SaveValue TableName, "HighScore1Name", HighScoreName(0)
    SaveValue TableName, "HighScore2", HighScore(1)
    SaveValue TableName, "HighScore2Name", HighScoreName(1)
    SaveValue TableName, "HighScore3", HighScore(2)
    SaveValue TableName, "HighScore3Name", HighScoreName(2)
    SaveValue TableName, "HighScore4", HighScore(3)
    SaveValue TableName, "HighScore4Name", HighScoreName(3)


    SaveValue TableName, "SpecialHighScore1", SpecialHighScore(0)
    SaveValue TableName, "SpecialHighScore1Name", SpecialHighScoreName(0)
    SaveValue TableName, "SpecialHighScore2", SpecialHighScore(1)
    SaveValue TableName, "SpecialHighScore2Name", SpecialHighScoreName(1)
    SaveValue TableName, "SpecialHighScore3", SpecialHighScore(2)
    SaveValue TableName, "SpecialHighScore3Name", SpecialHighScoreName(2)
    SaveValue TableName, "SpecialHighScore4", SpecialHighScore(3)
    SaveValue TableName, "SpecialHighScore4Name", SpecialHighScoreName(3)

    SaveValue TableName, "Credits", Credits
    SaveValue TableName, "TotalGamesPlayed", TotalGamesPlayed
   ' SaveValue TableName, "Score(CurrentPlayer)", Score(CurrentPlayer)

End Sub

Sub Reseths
    HighScoreName(0) = "AAA"
    HighScoreName(1) = "BBB"
    HighScoreName(2) = "CCC"
    HighScoreName(3) = "DDD"
    HighScore(0) = 90000
    HighScore(1) = 85000
    HighScore(2) = 80000
    HighScore(3) = 75000

    SpecialHighScoreName(0) = "AAA"
    SpecialHighScoreName(1) = "BBB"
    SpecialHighScoreName(2) = "CCC"
    SpecialHighScoreName(3) = "DDD"
    SpecialHighScore(0) = 4
    SpecialHighScore(1) = 3
    SpecialHighScore(2) = 2
    SpecialHighScore(3) = 1
    Savehs
End Sub

' ***********************************************************
'  High Score Initals Entry Functions - based on Black's code
' ***********************************************************

Dim hsbModeActive, SpecialhsbModeActive
Dim hsEnteredName, hsSpecialEnteredName
Dim hsEnteredDigits(3)
Dim hsSpecialEnteredDigits(3)
Dim hsCurrentDigit, hsSpecialCurrentDigit
Dim hsValidLetters, hsSpecialValidLetters
Dim hsCurrentLetter, hsSpecialCurrentLetter
Dim hsLetterFlash, hsSpecialLetterFlash


Sub CheckHighscore()
    DMDUpdate.enabled = 0
    display2.Text = " "
    display1.Text = " "
'    PuPlayer.LabelShowPage pDMD,1,0,""
'    pDMDSplashLines " " , " ", 2,  33023
    Dim tmp
    tmp = Score(1)

    If Score(2)> tmp Then tmp = Score(2)
    If Score(3)> tmp Then tmp = Score(3)
    If Score(4)> tmp Then tmp = Score(4)

    If tmp> HighScore(1) Then 'add 1 credit for beating the highscore
       HighScoreReward = 1
    End If

    If tmp> HighScore(3) Then
        PlaySound "spchkittenme"
        HighScore(3) = tmp
        display1.text = "  GREAT SCORE   " & "       "
       ' pDMDSplash3Lines "  GREAT SCORE   " , " ", " "& Score(CurrentPlayer), 3,  33023
        'enter player's name
        GiOff
        vpmtimer.addtimer 2000, "HighScoreEntryInit '"
       ' HighScoreEntryInit()
    Else
        'EndOfBallComplete()
        CheckSpecialHighscore
    End If
End Sub



Sub HighScoreEntryInit()
    hsbModeActive = True
    PlaySound "mu_jychighscore"
    hsLetterFlash = 0

    hsEnteredDigits(0) = "A"
    hsEnteredDigits(1) = "-"
    hsEnteredDigits(2) = "-"
    hsCurrentDigit = 0

    hsValidLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ<+-0123456789" ' < is used to delete the last letter
    hsCurrentLetter = 1
   ' DMDFlush
    display1.text = "YOUR NAME:" & " "
     'pDMDSplashHighScore "YOUR NAME" , " ", 2,  33023
    'DMDId "hsc", "", "YOUR NAME:", " ", 999999
    HighScoreDisplayName()
End Sub


Sub EnterHighScoreKey(keycode)
    If keycode = LeftFlipperKey Then
        Playsound "jycsfx12"
        hsCurrentLetter = hsCurrentLetter - 1
        if(hsCurrentLetter = 0) then
            hsCurrentLetter = len(hsValidLetters)
        end if
        HighScoreDisplayName()
    End If

    If keycode = RightFlipperKey Then
        Playsound "jycsfx12"
        hsCurrentLetter = hsCurrentLetter + 1
        if(hsCurrentLetter> len(hsValidLetters) ) then
            hsCurrentLetter = 1
        end if
        HighScoreDisplayName()
    End If

    If keycode = StartGameKey OR keycode = PlungerKey Then
        if(mid(hsValidLetters, hsCurrentLetter, 1) <> "<") then
            playsound "jycsfx9"
            hsEnteredDigits(hsCurrentDigit) = mid(hsValidLetters, hsCurrentLetter, 1)
            hsCurrentDigit = hsCurrentDigit + 1
            if(hsCurrentDigit = 3) then
                HighScoreCommitName()
            else
                HighScoreDisplayName()
            end if
        else
            playsound "fx_Esc"
            hsEnteredDigits(hsCurrentDigit) = " "
            if(hsCurrentDigit> 0) then
                hsCurrentDigit = hsCurrentDigit - 1
            end if
            HighScoreDisplayName()
        end if
    end if
End Sub

Sub HighScoreDisplayName()
    DMDUpdate.enabled = 0
    Dim i, TempStr
    display1.text = TempStr
     'pDMDSplashHighScore "ENTER YOUR NAME" , " " & TempStr, 2,  33023
    TempStr = " >"
    if(hsCurrentDigit> 0) then TempStr = TempStr & hsEnteredDigits(0)
    if(hsCurrentDigit> 1) then TempStr = TempStr & hsEnteredDigits(1)
    if(hsCurrentDigit> 2) then TempStr = TempStr & hsEnteredDigits(2)

    if(hsCurrentDigit <> 3) then
        if(hsLetterFlash <> 0) then
            TempStr = TempStr & "_"
            'DisplayB2SText TempStr & "_"
            display2.TEXT = TempStr & "_"
            'pDMDSplashHighScore " " , TempStr & "_", 2,  33023
        else
            TempStr = TempStr & mid(hsValidLetters, hsCurrentLetter, 1)
            'DisplayB2SText TempStr & mid(hsValidLetters, hsCurrentLetter, 1)
            display2.TEXT = TempStr & mid(hsValidLetters, hsCurrentLetter, 1)
            'pDMDSplashHighScore " " , " " & TempStr & mid(hsValidLetters, hsCurrentLetter, 1), 99,  33023
        end if
    end if

    if(hsCurrentDigit <1) then TempStr = TempStr & hsEnteredDigits(1)
    if(hsCurrentDigit <2) then TempStr = TempStr & hsEnteredDigits(2)

    TempStr = TempStr & "< "
     DMDMod "hsc", "YOUR NAME:", Mid(TempStr, 2, 5), 999999
    ' pDMDSplashHighScore "ENTER HIGHSCORE NAME" , " " & Mid(TempStr, 2, 5), 99,  33023
    display1.TEXT = "ENTER HIGHSCORE NAME "
    display2.TEXT = "    " & Mid(TempStr, 2, 5)
End Sub

Sub HighScoreCommitName()
    hsbModeActive = False
    'PlaySong "m_end"
    hsEnteredName = hsEnteredDigits(0) & hsEnteredDigits(1) & hsEnteredDigits(2)
    if(hsEnteredName = "   ") then
        hsEnteredName = "YOU"
    end if

    HighScoreName(3) = hsEnteredName
    SortHighscore
   ' DMDFlush
    DMDUpdate.enabled = 1
    'EndOfBallComplete()
    CheckSpecialHighscore()
End Sub

Sub SortHighscore
    Dim tmp, tmp2, i, j
    For i = 0 to 3
        For j = 0 to 2
            If HighScore(j) <HighScore(j + 1) Then
                tmp = HighScore(j + 1)
                tmp2 = HighScoreName(j + 1)
                HighScore(j + 1) = HighScore(j)
                HighScoreName(j + 1) = HighScoreName(j)
                HighScore(j) = tmp
                HighScoreName(j) = tmp2
            End If
        Next
    Next
End Sub



'*****************
' Claw Special HighScore
'*****************


Sub CheckSpecialHighscore()

    DMDUpdate.enabled = 0
    display1.Text = " "
    display2.Text = " "
    'pDMDSplashHighScore " " , " ", 2,  33023
    Dim tmp
    tmp = SpecialScore(1)

    If SpecialScore(2)> tmp Then tmp = SpecialScore(2)
    If SpecialScore(3)> tmp Then tmp = SpecialScore(3)
    If SpecialScore(4)> tmp Then tmp = SpecialScore(4)

    If tmp> SpecialHighScore(1) Then 'add 1 credit for beating the highscore
       SpecialHighScoreReward = 1
    End If

    If tmp> SpecialHighscore(3) Then
        SpecialHighscore(3) = tmp
        'enter player's name
        PlaySound "spchnotoveryet"
        display1.text = "  GOOD GAME  "
        display2.text = " PUSSY CAT  "
       ' pDMDSplashHighScore "SPECIAL HIGHSCORE " , " ", 2,  33023
        vpmtimer.addtimer 2000, "SpecialHighScoreEntryInit '"  
        'SpecialHighScoreEntryInit()
    Else
        SolLFlipper 0
        SolRFlipper 0
        CreditsHighScoreReward.Enabled = 1
        'EndOfBallComplete()
    End If
End Sub


Sub SpecialHighScoreEntryInit()
    SpecialhsbModeActive = True
    StopSound "mu_jychighscore"
    PlaySound "mu_jychighscore"
    hsSpecialLetterFlash = 0


    hsSpecialEnteredDigits(0) = "A"
    hsSpecialEnteredDigits(1) = "-"
    hsSpecialEnteredDigits(2) = "-"
    hsSpecialCurrentDigit = 0

    hsSpecialValidLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ<+-0123456789" ' < is used to delete the last letter
    hsSpecialCurrentLetter = 1
   ' DMDFlush
    'display1.text = "YOUR NAME:" & " "
    'DMDId "hsc", "", "YOUR NAME:", " ", 999999
    SpecialHighScoreDisplayName()
End Sub


Sub EnterSpecialHighScoreKey(keycode)
    If keycode = LeftFlipperKey Then
        Playsound "jycsfx12"
        hsSpecialCurrentLetter = hsSpecialCurrentLetter - 1
        if(hsSpecialCurrentLetter = 0) then
            hsSpecialCurrentLetter = len(hsSpecialValidLetters)
        end if
        SpecialHighScoreDisplayName()
    End If

    If keycode = RightFlipperKey Then
        Playsound "jycsfx12"
        hsSpecialCurrentLetter = hsSpecialCurrentLetter + 1
        if(hsSpecialCurrentLetter> len(hsSpecialValidLetters) ) then
            hsSpecialCurrentLetter = 1
        end if
        SpecialHighScoreDisplayName()
    End If

    If keycode = StartGameKey OR keycode = PlungerKey Then
        if(mid(hsSpecialValidLetters, hsSpecialCurrentLetter, 1) <> "<") then
            playsound "jycsfx9"
            hsSpecialEnteredDigits(hsSpecialCurrentDigit) = mid(hsSpecialValidLetters, hsSpecialCurrentLetter, 1)
            hsSpecialCurrentDigit = hsSpecialCurrentDigit + 1
            if(hsSpecialCurrentDigit = 3) then
                SpecialHighScoreCommitName()
            else
                SpecialHighScoreDisplayName()
            end if
        else
            playsound "fx_Esc"
            hsSpecialEnteredDigits(hsSpecialCurrentDigit) = " "
            if(hsSpecialCurrentDigit> 0) then
                hsSpecialCurrentDigit = hsSpecialCurrentDigit - 1
            end if
            SpecialHighScoreDisplayName()
        end if
    end if
End Sub

Sub SpecialHighScoreDisplayName()
    DMDUpdate.enabled = 0
    Dim i, TempStr
    display2.text = TempStr
    'pDMDSplashHighScore " " , " " & TempStr, 2,  33023
    TempStr = " >"
    if(hsSpecialCurrentDigit> 0) then TempStr = TempStr & hsSpecialEnteredDigits(0)
    if(hsSpecialCurrentDigit> 1) then TempStr = TempStr & hsSpecialEnteredDigits(1)
    if(hsSpecialCurrentDigit> 2) then TempStr = TempStr & hsSpecialEnteredDigits(2)

    if(hsSpecialCurrentDigit <> 3) then
        if(hsSpecialLetterFlash <> 0) then
            TempStr = TempStr & "_"
            'DisplayB2SText TempStr & "_"
            display2.TEXT = TempStr & "_"
            'pDMDSplashHighScore " " , "_" & TempStr, 2,  33023
        else
            TempStr = TempStr & mid(hsSpecialValidLetters, hsSpecialCurrentLetter, 1)
            'DisplayB2SText TempStr & mid(hsSpecialValidLetters, hsSpecialCurrentLetter, 1)
            display2.TEXT = TempStr & mid(hsSpecialValidLetters, hsSpecialCurrentLetter, 1)
            'pDMDSplashHighScore " " , " " & TempStr & mid(hsSpecialValidLetters, hsSpecialCurrentLetter, 1), 2,  33023
        end if
    end if

    if(hsSpecialCurrentDigit <1) then TempStr = TempStr & hsSpecialEnteredDigits(1)
    if(hsSpecialCurrentDigit <2) then TempStr = TempStr & hsSpecialEnteredDigits(2)

    TempStr = TempStr & "< "
    DMDMod "hsc", "YOUR NAME:", Mid(TempStr, 2, 5), 999999
    'pDMDSplashHighScore "MASTER NAME" , " " & Mid(TempStr), 2,  33023
    display1.TEXT = "CLAW MASTER NAME: "
    display2.TEXT = "    " & Mid(TempStr, 2, 5)
End Sub

Sub SpecialHighScoreCommitName()
    SpecialhsbModeActive = False
    'PlaySong "m_end"
    hsSpecialEnteredName = hsSpecialEnteredDigits(0) & hsSpecialEnteredDigits(1) & hsSpecialEnteredDigits(2)
    if(hsSpecialEnteredName = "   ") then
        hsSpecialEnteredName = "YOU"
    end if

    SpecialHighScoreName(3) = hsSpecialEnteredName
    SortSpecialHighscore
    DMDUpdate.enabled = 1
    SpecialReward = True
    CreditsHighScoreReward.Enabled = True
    'EndOfBallComplete()
End Sub

Sub SortSpecialHighscore
    Dim tmp, tmp2, i, j
    For i = 0 to 3
        For j = 0 to 2
            If SpecialHighScore(j) <SpecialHighScore(j + 1) Then
                tmp = SpecialHighScore(j + 1)
                tmp2 = SpecialHighScoreName(j + 1)
                SpecialHighScore(j + 1) = SpecialHighScore(j)
                SpecialHighScoreName(j + 1) = SpecialHighScoreName(j)
                SpecialHighScore(j) = tmp
                SpecialHighScoreName(j) = tmp2
            End If
        Next
    Next
End Sub



Dim SpecialReward
Sub CreditsHighScoreReward_Timer()
    CreditsHighScoreReward.Enabled = False
    SolLFlipper 0
    SolRFlipper 0
 If SpecialReward = True Then
    SpecialReward = False              

  If HighScoreReward = 1 And SpecialHighScoreReward = 1  Then
     Credits = Credits + 1
    'PlaySound SoundFXDOF("fx_knocker",124,DOFPulse,DOFKnocker)

    DOF 140, DOFOn
    PlaySound SoundFXDOF("fx_knocker",136,DOFPulse,DOFKnocker)        
    DOF 115, DOFPulse
     display1.text = "     CREDITS" & "  "&(Credits) &"  " & "      "
     HighScoreReward = 0: SpecialHighScoreReward = 0
     'pDMDSplashLines "CREDITS " , " "&(Credits), 3,  33023
     vpmtimer.addtimer 1000, "UnCreditoMas '"
  End If


   If HighScoreReward = 1 And SpecialHighScoreReward = 0 Then
      Credits = Credits + 1
    'PlaySound SoundFXDOF("fx_knocker",124,DOFPulse,DOFKnocker)

    DOF 140, DOFOn
    PlaySound SoundFXDOF("fx_knocker",136,DOFPulse,DOFKnocker)        
    DOF 115, DOFPulse
      display1.text = "     CREDITS" & "  "&(Credits) &"  " & "      "
      HighScoreReward = 0:     ' pDMDSplashLines "CREDITS " , " "&(Credits), 2,  33023
     vpmtimer.addtimer 1000, "EndOfBallComplete() '"
   End If

   If HighScoreReward = 0 And SpecialHighScoreReward = 1 Then
      Credits = Credits + 1
    'PlaySound SoundFXDOF("fx_knocker",124,DOFPulse,DOFKnocker)

    DOF 140, DOFOn
    PlaySound SoundFXDOF("fx_knocker",136,DOFPulse,DOFKnocker)        
    DOF 115, DOFPulse
      display1.text = "     CREDITS" & "  "&(Credits) &"  " & "      "
      SpecialHighScoreReward = 0
      'pDMDSplashLines "CREDITS " , " "&(Credits), 2,  33023
      vpmtimer.addtimer 2500, "EndOfBallComplete() '"
   End If

 ' If HighScoreReward = 0 And SpecialHighScoreReward = 0 Then

 ' End If

 End If
     Playsound "spchyeahthatsit"
     EndOfBallComplete()
End Sub
 
Sub UnCreditoMas
    Credits = Credits + 1
    'PlaySound SoundFXDOF("fx_knocker",124,DOFPulse,DOFKnocker)

    DOF 140, DOFOn
    PlaySound SoundFXDOF("fx_knocker",136,DOFPulse,DOFKnocker)        
    DOF 115, DOFPulse
    display1.text = "     CREDITS" & "  "&(Credits) &"  " & "      "
   ' pDMDSplashLines "CREDITS " , " "&(Credits), 2,  33023
    vpmtimer.addtimer 2000, "EndOfBallComplete() '"
End Sub


'********************
' Music sounds
'********************

Dim Song
Song = ""

Sub PlaySong(name)
    If bMusicOn Then
        If Song <> name Then
            StopSound Song
            Song = name
            If Song = "mu_end" Then
                PlaySound Song, 0, 0.1  'this last number is the volume, from 0 to 1
            Else
                PlaySound Song, -1, 0.1 'this last number is the volume, from 0 to 1
            End If
        End If
    End If
End Sub



'-----------------------------
'-----  FS Display Code  -----
'-----------------------------

'If You want to hide a display, set the reel value of every reel to 44. This picture is transparent
'This is best done using collection:
'
'    If HideDisplay then
'        For Each obj in ReelsCollection:obj.setvalue(44):next
'    end if
 

 Dim Char(32),i,TempText                    'increase dimension if You need larger displays



'-----------------------------------------------
'-----  B2S section, not used in the demo  -----
'-----------------------------------------------

Sub DisplayB2SText(TextPar)                            'Procedure to display Text on a 32 digit B2S LED reel. Assuming that it is display 1 with internal digit numbers 1-32
  If B2SOn Then
    TempText = TextPar        
    for i = 1 to 32
        if i <= len(TextPar) then
            Char(i) = left(TempText,1)
            TempText = right(Temptext,len(TempText)-1)        
        else
            Char(i) = " "
        end if
    next
    if B2SOn Then
    for i = 1 to 32
        controller.B2SSetLED i,B2SLEDValue(Char(i))
    next
    end if
  End If
End Sub


Sub DisplayB2SText2(TextPar)                            'Procedure to display Text on a 30 digit B2S LED reel. Assuming that it is display 1 with internal digit numbers 1-32
 If B2SOn Then
    TempText = TextPar        
    for i = 1 to 32
        if i <= len(TextPar) then
            Char(i) = left(TempText,1)
            TempText = right(Temptext,len(TempText)-1)        
        else
            Char(i) = " "
        end if
    next

    for i = 1 to 32
        controller.B2SSetLED i,B2SLEDValue(Char(i))

    next
End If

DMDUpdate.interval = 2000
DMDUpdate.enabled = 1

End Sub



Function B2SLEDValue(CharPar)                        'to be used with dB2S 15-segments-LED used in Herweh's Designer
    B2SLEDValue = 0                                    'default for unknown characters
    select case CharPar
        Case "","":    B2SLEDValue = 0
        Case "0":    B2SLEDValue = 63    
        Case "1":    B2SLEDValue = 8704
        Case "2":    B2SLEDValue = 2139
        Case "3":    B2SLEDValue = 2127    
        Case "4":    B2SLEDValue = 2150
        Case "5":    B2SLEDValue = 2157
        Case "6":    B2SLEDValue = 2172
        Case "7":    B2SLEDValue = 7
        Case "8":    B2SLEDValue = 2175
        Case "9":    B2SLEDValue = 2159
        Case "A":    B2SLEDValue = 2167
        Case "B":    B2SLEDValue = 10767
        Case "C":    B2SLEDValue = 57
        Case "D":    B2SLEDValue = 8719
        Case "E":    B2SLEDValue = 121
        Case "F":    B2SLEDValue = 2161
        Case "G":    B2SLEDValue = 2109
        Case "H":    B2SLEDValue = 2166
        Case "I":    B2SLEDValue = 8713
        Case "J":    B2SLEDValue = 31
        Case "K":    B2SLEDValue = 5232
        Case "L":    B2SLEDValue = 56
        Case "M":    B2SLEDValue = 1334
        Case "N":    B2SLEDValue = 4406
        Case "O":    B2SLEDValue = 63
        Case "P":    B2SLEDValue = 2163
        Case "Q":    B2SLEDValue = 4287
        Case "R":    B2SLEDValue = 6259
        Case "S":    B2SLEDValue = 2157
        Case "T":    B2SLEDValue = 8705
        Case "U":    B2SLEDValue = 62
        Case "V":    B2SLEDValue = 17456
        Case "W":    B2SLEDValue = 20534
        Case "X":    B2SLEDValue = 21760
        Case "Y":    B2SLEDValue = 9472
        Case "Z":    B2SLEDValue = 17417
        Case "<":    B2SLEDValue = 5120
        Case ">":    B2SLEDValue = 16640
        Case "^":    B2SLEDValue = 17414
        Case ".":    B2SLEDValue = 8
        Case "!":    B2SLEDValue = 0
        Case ".":    B2SLEDValue = 128
        Case "*":    B2SLEDValue = 32576
        Case "/":    B2SLEDValue = 17408
        Case "\":    B2SLEDValue = 4352
        Case "|":    B2SLEDValue = 8704
        Case "=":    B2SLEDValue = 2120
        Case "+":    B2SLEDValue = 10816
        Case "-":    B2SLEDValue = 2112
    end select            
    B2SLEDValue = cint(B2SLEDValue)
End Function



Dim Ball
Sub DMDScore
     DisplayB2SText Score(1) & "" & "                  BALL " & Ball & " "
     D1.text = Score(CurrentPlayer) &"                "                   
     D2.text = "           BALL " & Ball
     DMDUpdate.enabled = 1
End Sub


Sub DMDUpdate_Timer
    DMDUpdate.enabled = 0
 If PlayersPlayingGame = 1 And BallsOnPlayfield >= 1 Then
    DisplayB2SText " "
    D1.text = " "
    D2.text = " "
    DMDScore
    AddScore (0)
    DMDUpdate.interval = 1000
    DMDUpdate.enabled = 1
  Else
    DisplayB2SText " "
    D1.text = " "
    D2.text = " "
    DMDUpdate.interval = 1500
    DMDUpdate.enabled = 1
 End If
End Sub



Function Balls
    Dim tmp
    tmp = BallsPerGame - BallsRemaining(CurrentPlayer) + 1
    If tmp> BallsPerGame Then
        Balls = BallsPerGame
    Else
        Balls = tmp
    End If
End Function



'**************************
'   PinUp Player Config
'   Change HasPuP = True if using PinUp Player Videos
'**************************

'Const HasPuP = False
'
'if HasPuP Then
'
'    Const pTopper=0
'       Const pDMD=1
'      Const pBackglass=2
'       Const pPlayfield=3
'       Const pMusic=4
'    Const pAudio=7
'    Const pCallouts=8
'
'    Dim PuPlayer
'    Set PuPlayer = CreateObject("PinUpPlayer.PinDisplay")   
'
'    PuPlayer.Init pDMD,"TheGoonies"
'    PuPlayer.Init pBackglass,"TheGoonies"
'    PuPlayer.Init pMusic,"TheGoonies"
'    PuPlayer.Init pAudio,"TheGoonies"
'    PuPlayer.Init pCallouts,"TheGoonies"
'
'    PuPlayer.playlistadd pDMD,"DMDBackground", 1 , 0
'    PuPlayer.playlistadd pBackglass,"BackglassBackground", 1 , 0
'    PuPlayer.playlistadd pMusic,"MusicGamePlay", 1 , 0
'    PuPlayer.playlistadd pMusic,"MusicMultiball", 1 , 0
'    PuPlayer.playlistadd pAudio,"Musicintro", 1 , 0
'    'PuPlayer.playlistadd pAudio,"pCallouts", 1 , 0
'
'
'    PuPlayer.setScreenEx pDMD,0,0,0,0,0  'lets show the DMD at default position.
'    PuPlayer.SetScreenex pBackglass,0,0,0,0,0       'Set PuPlayer DMD TO Always ON    <screen number> , xpos, ypos, width, height, POPUP
'
'    'Set Background video on DMD
'    PuPlayer.playlistplayex pBackglass,"BackglassBackground","backglass4.jpg",0,1  'should be an attract background (no text is displayed)
'    PuPlayer.SetBackground pBackglass,1
'
'    'Set Background video on DMD
'    PuPlayer.playlistplayex pDMD,"DMDBackground","backdmd.jpg",0,1  'should be an attract background (no text is displayed)
'    PuPlayer.SetBackground pDMD,1
'
'
'    PuPlayer.SetScreenex pAudio,0,0,0,0,2
'    PuPlayer.hide pAudio
'    PuPlayer.SetScreenex pMusic,0,0,0,0,2
'    PuPlayer.hide pMusic
'    PuPlayer.SetScreenex pCallouts,0,0,0,0,2
'    PuPlayer.hide pCallouts
'    
'    'Init TextOverlay on PUP Screen
'
'    PuPlayer.LabelInit pDMD
'
'End if
'
'
'dim usePUPDMDDriver   'En lugar de UltraDMD para hardware, podemos reflejar el DMD al hardware DMD.  
'
'usePUPDMDDriver=False
'
'if usePUPDMDDriver = true then
'
'dim PUPDMDObject
'Set PUPDMDObject = CreateObject("PUPDMDControl.DMD")
'PUPDMDObject.DMDOpen
''PUPDMDObject.DMDPlay "C:\Visual Pinball\Tables\PinUPPlayer\PUPMenu\DMD\elvis.gif"
'PUPDMDObject.DMDPuPMirror
'PUPDMDObject.DMDPuPTextMirror
'END IF








'*********************************
'    PinUp Player DMD
'
'
'
'*********************************





'Setup Pages.  Note if you use fonts they must be in FONTS folder of the pupVideos\tablename\FONTS

'Page 1 (default score display)
'PuPlayer.LabelNew pDMD,"Credits" ,"Pinball Fantasies",20,33023   ,0,2,2,95,0,1,0
'PuPlayer.LabelNew pDMD,"Play1"   ,"Pinball Fantasies",20,33023   ,0,2,2,60,0,1,0
'PuPlayer.LabelNew pDMD,"Ball"    ,"Pinball Fantasies",20,33023   ,0,2,2,25,0,1,0
'PuPlayer.LabelNew pDMD,"MsgScore","Pinball Fantasies",45,33023   ,0,1,0, 0,30,1,0
'PuPlayer.LabelNew pDMD,"CurScore","Pinball Fantasies",45,33023   ,0,1,1, 0,30,1,1
'PuPlayer.LabelNew pDMD,"CurImage","Pinball Fantasies",50,33023 ,0,1,1,0, 0,1,1  'new image type
'
'
''Page 2 (default Text Splash 1 Big Line)
'PuPlayer.LabelNew pDMD,"Splash"  ,"Pinball Fantasies",27,33023,0,1,1,0,0,2,0
'
''Page 3 (default Text Splash 2 and 3 Lines)
'PuPlayer.LabelNew pDMD,"Splash2a","Pinball Fantasies",30,33023,0,1,1,0,20,3,0
'PuPlayer.LabelNew pDMD,"Splash2b","Pinball Fantasies",24,33023,0,1,1,0,50,3,0
'PuPlayer.LabelNew pDMD,"Splash2c","Pinball Fantasies",20,33023,0,1,1,0,80,3,0
'
'
''Page 4 (Bonus DMD)
'PuPlayer.LabelNew pDMD,"Splash3a","Pinball Fantasies",25,33023,0,1,1,0,20,3,0
'PuPlayer.LabelNew pDMD,"Splash3b","Pinball Fantasies",28,33023,0,1,1,0,60,3,0
'
''set Msg on scoreboard to empty
'
''Page 5 (3 layer large text for overlay targets function,  must you fixed width font!
'PuPlayer.LabelNew pDMD,"Back5"    ,"FixedSYS",40,33023,0,1,1,0,0,5,0
'PuPlayer.LabelNew pDMD,"Middle5"  ,"FixedSYS",40,33023,0,1,1,0,0,5,0
'PuPlayer.LabelNew pDMD,"Flash5"   ,"FixedSYS",40,33023,0,1,1,0,0,5,0
'
''Page 6 (HighScore DMD)
'PuPlayer.LabelNew pDMD,"Splash4a","Pinball Fantasies",27,33023,0,1,1,0,30,3,0
'PuPlayer.LabelNew pDMD,"Splash4b","Pinball Fantasies",32,33023,0,1,1,0,80,3,0
'
'
'pDMDLabelHide "MsgScore"


'normally our attract background video will have text (insert Q's) or (press Start)...etc
'but in this demo we'll show a splash for 10 seconds,  could use timer to repeat if nec
'pDMDSplashBig "Press Start To Begin",30,16777088



'PinUP Player DMD Helper Functions

'Sub pUpdateScores
'If turnonultradmd = 0 then
'    dmdscoretime
'end if
'puPlayer.LabelSet pDMD,"CurScore","" & Score(CurrentPlayer),1,""
'puPlayer.LabelSet pDMD,"Credits","CREDITS " & ""& Credits ,1,""
'puPlayer.LabelSet pDMD,"Play1","PLAYER " & CurrentPlayer,1,""
'puPlayer.LabelSet pDMD,"Ball","BALL " & ""& balls ,1,""
'PuPlayer.playlistplayex pDMD,"DMDBackground","backdmd.jpg",0,1
'PuPlayer.SetBackground pDMD,1
'end Sub
'
'
'Sub pDMDLabelHide(labName)
'PuPlayer.LabelSet pDMD,labName,"",0,""   
'end sub
'
'
'Sub pDMDSplashBig(msgText,timeSec, mColor)
'PuPlayer.LabelShowPage pDMD,2,timeSec,""
'PuPlayer.LabelSet pDMD,"Splash",msgText,0,"{'mt':1,'at':1,'fq':250,'len':" & (timeSec*1000000) & ",'fc':" & mColor & "}"   
'end sub
'
'Sub pDMDScrollBig(msgText,timeSec,mColor)
'PuPlayer.LabelShowPage pDMD,2,timeSec,""
'PuPlayer.LabelSet pDMD,"Splash",msgText,0,"{'mt':1,'at':2,'xps':1,'xpe':-1,'len':" & (timeSec*1000000) & ",'mlen':" & (timeSec*1000) & ",'tt':0,'fc':" & mColor & "}"
'end sub
'
'Sub pDMDScrollBigV(msgText,timeSec,mColor)
'PuPlayer.LabelShowPage pDMD,2,timeSec,""
'PuPlayer.LabelSet pDMD,"Splash",msgText,0,"{'mt':1,'at':2,'yps':1,'ype':-1,'len':" & (timeSec*1000000) & ",'mlen':" & (timeSec*1000) & ",'tt':0,'fc':" & mColor & "}"
'end sub
'
'Sub pDMDBlinkLines(msgText,msgText2,timeSec,mColor)
'PuPlayer.LabelShowPage pDMD,3,timeSec,""
'PuPlayer.LabelSet pDMD,"Splash2a",msgText,0,"{'mt':1,'at':2,'fq':250,'len':" & (timeSec*1000) & ",'fc':" & mColor & "}"
'PuPlayer.LabelSet pDMD,"Splash2b",msgText2,0,"{'mt':1,'at':2,'fq':250,'len':" & (timeSec*1000) & ",'fc':" & mColor & "}"   
'end Sub
'
'Sub pDMDSplashLines(msgText,msgText2,timeSec,mColor)'Para uso normal del DMD
'PuPlayer.LabelShowPage pDMD,3,timeSec,""
'PuPlayer.LabelSet pDMD,"Splash2a",msgText,0,"{'mt':1,'at':2,'fq':250,'len':" & (timeSec*1000000) & ",'fc':" & mColor & "}"
'PuPlayer.LabelSet pDMD,"Splash2b",msgText2,0,"{'mt':1,'at':2,'fq':250,'len':" & (timeSec*1000000) & ",'fc':" & mColor & "}"   
'end Sub
'
'Sub pDMDSplash3Lines(msgText,msgText2,msgText3,timeSec,mColor)'Para uso normal del DMD
'PuPlayer.LabelShowPage pDMD,3,timeSec,""
'PuPlayer.LabelSet pDMD,"Splash2a",msgText,0,"{'mt':1,'at':2,'fq':250,'len':" & (timeSec*1000000) & ",'fc':" & mColor & "}"
'PuPlayer.LabelSet pDMD,"Splash2b",msgText2,0,"{'mt':1,'at':2,'fq':250,'len':" & (timeSec*1000000) & ",'fc':" & mColor & "}"  
'PuPlayer.LabelSet pDMD,"Splash2c",msgText3,0,"{'mt':1,'at':2,'fq':250,'len':" & (timeSec*1000000) & ",'fc':" & mColor & "}"  
'end Sub
'
'
'Sub pDMDSplashBonus(msgText,msgText2,timeSec,mColor)'Para uso de los Bonus
'PuPlayer.LabelShowPage pDMD,3,timeSec,""
'PuPlayer.LabelSet pDMD,"Splash3a",msgText,0,"{'mt':1,'at':2,'fq':250,'len':" & (timeSec*1000000) & ",'fc':" & mColor & "}"
'PuPlayer.LabelSet pDMD,"Splash3b",msgText2,0,"{'mt':1,'at':2,'fq':250,'len':" & (timeSec*1000000) & ",'fc':" & mColor & "}"
'end Sub
'
'Sub pDMDSplashHighScore(msgText,msgText2,timeSec,mColor)'Para uso de los Records
'PuPlayer.LabelShowPage pDMD,3,timeSec,""
'PuPlayer.LabelSet pDMD,"Splash4a",msgText,0,"{'mt':1,'at':2,'fq':250,'len':" & (timeSec*1000000) & ",'fc':" & mColor & "}"
'PuPlayer.LabelSet pDMD,"Splash4b",msgText2,0,"{'mt':1,'at':2,'fq':250,'len':" & (timeSec*1000000) & ",'fc':" & mColor & "}"   
'end Sub
'
'Sub pDMDSplashScore(msgText,timeSec,mColor)
'PuPlayer.LabelSet pDMD,"MsgScore",msgText,0,"{'mt':1,'at':1,'fq':250,'len':"& (timeSec*1000) &",'fc':" & mColor & "}"
'end Sub
'
'Sub pDMDSplashScoreScroll(msgText,timeSec,mColor)
'PuPlayer.LabelSet pDMD,"MsgScore",msgText,0,"{'mt':1,'at':2,'xps':1,'xpe':-1,'len':"& (timeSec*1000) &", 'mlen':"& (timeSec*1000) &",'tt':0, 'fc':" & mColor & "}"
'end Sub
'
'Sub pDMDTargetLetters(backText,middleText,flashText, timeSec, mColor)  
'PuPlayer.LabelShowPage pDMD,5,timeSec,""  'show page 5
'PuPlayer.LabelSet pDMD,"Back5"  ,backText  ,1,""
'PuPlayer.LabelSet pDMD,"Middle5",middleText,1,""
'PuPlayer.LabelSet pDMD,"Flash5" ,flashText ,0,"{'mt':1,'at':1,'fq':250,'len':" & (timeSec*1000) & ",'fc':" & mColor & "}"   
'end Sub
'
'
'Sub pDMDZoomBig(msgText,timeSec,mColor)  'new Zoom
'PuPlayer.LabelShowPage pDMD,2,timeSec,""
'PuPlayer.LabelSet pDMD,"Splash",msgText,0,"{'mt':1,'at':3,'hstart':5,'hend':80,'len':" & (timeSec*1000) & ",'mlen':" & (timeSec*500) & ",'tt':5,'fc':" & mColor & "}"
'end sub
'
'
'Sub pD1Set(msgText)
''puPlayer.LabelSet pDMD,"MsgScore","" & msgText ,1,""
''pDMDSplashLines D1.Text, D2.Text, 3, 432342334
'end sub
'
'Sub pSplashDMD
'pDMDSplashLines debug.print, 3, 33023
'end Sub
'
'
'
'Sub pDMDTargetLettersInfo(msgText,msgInfo, timeSec, mColor)  'msgInfo = '0211'  0= layer 1, 1=layer 2, 2=top layer3.
'PuPlayer.LabelShowPage pDMD,5,timeSec,""  'show page 5
'Dim backText
'Dim middleText
'Dim flashText
'Dim curChar
'Dim i
'
'For i=1 To Len(msgInfo)
'    curChar="" & Mid(msgInfo,i,1)
'    if curChar="0" Then
'            backText=backText & Mid(msgText,i,1)
'            middleText=middleText & " "
'            flashText=flashText & " "          
'    End If
'    if curChar="1" Then
'            backText=backText & " "
'            middleText=middleText & Mid(msgText,i,1)
'            flashText=flashText & " "          
'    End If
'    if curChar="2" Then
'            backText=backText & " "
'            middleText=middleText & " "
'            flashText=flashText & Mid(msgText,i,1)
'    End If   
'Next
'
'PuPlayer.LabelSet pDMD,"Back5"  ,backText  ,1,""
'PuPlayer.LabelSet pDMD,"Middle5",middleText,1,""
'PuPlayer.LabelSet pDMD,"Flash5" ,flashText ,0,"{'mt':1,'at':1,'fq':250,'len':" & (timeSec*1000) & ",'fc':" & mColor & "}"   
'end Sub






'**********
' UltraDMD
'**********

    Dim UltraDMD

    ' DMD using UltraDMD calls

    Sub DMD(background, toptext, bottomtext, duration)
        If turnonultradmd = 0 then exit sub
        UltraDMD.DisplayScene00 background, toptext, 15, bottomtext, 15, 14, duration, 14
        UltraDMDTimer.Enabled = 1 'to show the score after the animation/message
    End Sub

    Sub DMDScore
    End Sub

    sub dmdscoretime
        If turnonultradmd = 0 then exit sub
        UltraDMD.SetScoreboardBackgroundImage "scoreboard-DMD.jpg", 15, 7
        UltraDMD.DisplayScoreboard PlayersPlayingGame, CurrentPlayer, Score(1), Score(2), Score(3), Score(4), "Player " & CurrentPlayer, "Ball " & Balls
    end sub

    Sub DMDScoreNow
        If turnonultradmd = 0 then exit sub
        DMDFlush
        DMDScore
    End Sub

    Sub DMDFLush
        If turnonultradmd = 0 then exit sub
        UltraDMDTimer.Enabled = 1
        UltraDMD.CancelRendering
    End Sub

    Sub DMDScrollCredits(background, text, duration)
        If turnonultradmd = 0 then exit sub
        UltraDMD.ScrollingCredits background, text, 15, 14, duration, 14
    End Sub

    Sub DMDId(id, background, toptext, bottomtext, duration)
        If turnonultradmd = 0 then exit sub
        UltraDMD.DisplayScene00ExwithID id, False, background, toptext, 15, 0, bottomtext, 15, 0, 14, duration, 14
    End Sub

    Sub DMDMod(id, toptext, bottomtext, duration)
        If turnonultradmd = 0 then exit sub
        UltraDMD.ModifyScene00Ex id, toptext, bottomtext, duration
    End Sub

    Sub UltraDMDTimer_Timer 'used for the attrackmode and the instant info.
        If turnonultradmd = 0 then exit sub
        If bInstantInfo Then
            InstantInfo
        ElseIf bAttractMode Then
        ElseIf NOT UltraDMD.IsRendering Then
            DMDScoreNow
        ElseIf bromconfig Then
            romconfig
        End If
    End Sub

    Sub DMD_Init
        If turnonultradmd = 0 then exit sub
        Set UltraDMD = CreateObject("UltraDMD.DMDObject")
        If UltraDMD is Nothing Then
            MsgBox "No UltraDMD found.  This table will NOT run without it."
            Exit Sub
        End If

        UltraDMD.Init
        If turnonultradmd = 0 then exit sub
        If Not UltraDMD.GetMajorVersion = 1 Then
            MsgBox "Incompatible Version of UltraDMD found."
            Exit Sub
        End If

        If UltraDMD.GetMinorVersion <1 Then
        If turnonultradmd = 0 then exit sub
            MsgBox "Incompatible Version of UltraDMD found. Please update to version 1.1 or newer."
            Exit Sub
        End If

        Dim fso:Set fso = CreateObject("Scripting.FileSystemObject")
        Dim curDir:curDir = fso.GetAbsolutePathName(".")

        Dim DirName
        DirName = curDir& "\" &TableName& ".UltraDMD"

        If Not fso.FolderExists(DirName) Then _
                Msgbox "UltraDMD userfiles directory '" & DirName & "' does not exist." & CHR(13) & "No graphic images will be displayed on the DMD"
        UltraDMD.SetProjectFolder DirName

        ' wait for the animation to end
        While UltraDMD.IsRendering = True
        WEnd

    End Sub




Sub StartAttractMode()
    bGameInPLay = False
    bAttractMode = true
    StartLightSeq
    nevertimer1.Interval = 2500
    nevertimer1.Enabled = true
    attractmessage = attractmessage - attractmessage
    messagetimer.enabled=true
End Sub

Sub StopAttractMode()
    messagetimer.enabled=False
    ShowHighScores.Enabled = 0
    bAttractMode = False
    addscore(0)
    LightSeqAttract.StopPlay
    LightSeqFlasher.StopPlay
End Sub

Sub StartLightSeq()
    'lights sequences
    LightSeqFlasher.UpdateInterval = 150
    LightSeqFlasher.Play SeqRandom, 10, , 50000
    LightSeqAttract.UpdateInterval = 25
    LightSeqAttract.Play SeqBlinking, , 5, 150
    LightSeqAttract.Play SeqRandom, 40, , 4000
    LightSeqAttract.Play SeqAllOff
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqUpOn, 50, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqDownOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqCircleOutOn, 15, 2
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqUpOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqDownOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqUpOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqDownOn, 25, 1
    LightSeqAttract.UpdateInterval = 10
    LightSeqAttract.Play SeqCircleOutOn, 15, 3
    LightSeqAttract.UpdateInterval = 5
    LightSeqAttract.Play SeqRightOn, 50, 1
    LightSeqAttract.UpdateInterval = 5
    LightSeqAttract.Play SeqLeftOn, 50, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqRightOn, 50, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqLeftOn, 50, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqRightOn, 40, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqLeftOn, 40, 1
    LightSeqAttract.UpdateInterval = 10
    LightSeqAttract.Play SeqRightOn, 30, 1
    LightSeqAttract.UpdateInterval = 10
    LightSeqAttract.Play SeqLeftOn, 30, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqRightOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqLeftOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqRightOn, 15, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqLeftOn, 15, 1
    LightSeqAttract.UpdateInterval = 10
    LightSeqAttract.Play SeqCircleOutOn, 15, 3
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqLeftOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqRightOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqLeftOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqUpOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqDownOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqUpOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqDownOn, 25, 1
    LightSeqAttract.UpdateInterval = 5
    LightSeqAttract.Play SeqStripe1VertOn, 50, 2
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqCircleOutOn, 15, 2
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqStripe1VertOn, 50, 3
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqLeftOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqRightOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqLeftOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqUpOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqDownOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqCircleOutOn, 15, 2
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqStripe2VertOn, 50, 3
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqLeftOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqRightOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqLeftOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqUpOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqDownOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqUpOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqDownOn, 25, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqStripe1VertOn, 25, 3
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqStripe2VertOn, 25, 3
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqUpOn, 15, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqDownOn, 15, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqUpOn, 15, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqDownOn, 15, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqUpOn, 15, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqDownOn, 15, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqRightOn, 15, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqLeftOn, 15, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqRightOn, 15, 1
    LightSeqAttract.UpdateInterval = 8
    LightSeqAttract.Play SeqLeftOn, 15, 1

End Sub

Sub LightSeqAttract_PlayDone()
    StartLightSeq()
End Sub

Sub LightSeqTilt_PlayDone()
    LightSeqTilt.Play SeqAllOff
End Sub






dim attractmessage

sub messagetimer_Timer()
    attractmessage = attractmessage + 1
    If attractmessage = 1 then
    DispDmd1.text = "Game Over"
    'player2reel.text = "Over"
    DispDmd1.text = "score  "&(score(currentplayer))
    'player4reel.text = (score(currentplayer))
'    If score(currentplayer) > 0 Then
'    pDMDSplash3Lines "GAME OVER" , "", "LAST SCORE "&(score(currentplayer)), 22, 33023
'    Else
'    pDMDSplashBig "GAME OVER", 22, 33023   
 '    end if
     end if

    If attractmessage = 2 then
    if Credits = 0 then
    DispDmd1.text = "Credits 0"
    DispDmd1.text = "Insert Coin"
    'pDMDSplash3Lines "CREDITS 0" , "", "INSERT COIN", 22, 33023
    Else
    DispDmd1.text = "Credits: "&Credits
    'player2reel.text = " "&Credits
    DispDmd1.text = "Press Start"
   ' player4reel.text = "Start"
    'pDMDSplash3Lines "CREDITS "&(Credits) , "", "PRESS START", 22, 33023  
    End If
    end if


    If attractmessage = 3 then
    DispDmd1.text = ""
    'player2reel.text = "the"
    DispDmd1.text = "The Goonies"
    'player4reel.text = "hog 2"
    'pDMDSplash3Lines " ", "", "", 22, 33023
    'PuPlayer.playlistplayex pDMD,"DMDBackground","GooniesLogoDMD.mp4",0,1  
    end if

    If attractmessage = 4 then
    DispDmd1.text = " "
    'player2reel.text = "by"
    DispDmd1.text = " "
    'PuPlayer.playlistplayex pDMD,"DMDBackground","backdmd.png",0,1
    'PuPlayer.SetBackground pDMD,1
    'pDMDSplashHighScore " ", " " , 22, 33023
    end if

    If attractmessage = 5 then
    'pDMDSplashHighScore "HIGHSCORES", " " , 22, 33023
    ShowHighScores.Enabled = 1
    end if

    If attractmessage = 6 then
    DispDmd1.text = "extra ball at"
    'player2reel.text = "ball at"
    DispDmd1.text = "750000 / 1500000"
    'player4reel.text = "1500000"
    'pDMDSplash3Lines "REPLAY AT" , "", "7500000", 22, 33023
    end if

    If attractmessage = 7 then
    DispDmd1.text = "Created by"
    'player2reel.text = "by"
    DispDmd1.text = "Brendan Bailey"
    'player4reel.text = "Bailey"
    'pDMDSplash3Lines "FP TABLE BY" , "GLXB - HIGHLNDER00", "JPINSA - SHADERBYTES", 22, 33023
    end if

    If attractmessage = 8 then
    DispDmd1.text = "Winners Don't"
    'player2reel.text = "Don't"
    DispDmd1.text = "Use Drugs"
   ' player4reel.text = "Drugs"
    'pDMDSplash3Lines "WINNERS DONT" , "", "USE DRUGS", 22, 33023
    end if

    If attractmessage = 9 then
    if Credits = 0 then
    DispDmd1.text = "Credits 0"
    DispDmd1.text = "Insert Coin"
    'pDMDSplash3Lines "CREDITS 0" , "", "INSERT COIN", 22, 33023
    Else
    DispDmd1.text = "Credits: "&Credits
    'player2reel.text = " "&Credits
    DispDmd1.text = "Press Start"
   ' player4reel.text = "Start"
    'pDMDSplash3Lines "CREDITS "&(Credits) , "", "PRESS START", 22, 33023
    End If
    End If


    If attractmessage = 10 then
    'puplayer.playlistplayex pDMD,"DMDBackground","backdmd.jpg",0,1  'should be an attract background (no text is displayed)
    'puplayer.SetBackground pDMD,1
    DispDmd1.text = "COMVERSION BY"
    'player2reel.text = " "&Credits
    DispDmd1.text = "JAVIER"
   ' player4reel.text = "Start"
    'pDMDSplash3Lines "VPX COMVERSION" , "", "BY JAVIER" , 22, 33023
    attractmessage = attractmessage - attractmessage
    End If
    
end sub


Dim HSmessage
Sub ShowHighScores_Timer
    messagetimer.enabled = 0
    HSmessage = HSmessage + 1
    'PuPlayer.playlistplayex pDMD,"DMDBackground","backdmd.jpg",0,1  'should be an attract background (no text is displayed)
    'PuPlayer.SetBackground pDMD,1
    Select Case HSmessage
    Case 1:
    ShowHighScores.interval = 3000

    DispDmd1.text = " 1> " & HighScoreName(0) & "  " & HighScore(0)', seScrollRightOver
    DispDmd1.text = " 2> " & HighScoreName(1) & "  " & HighScore(1)', seScrollRightOver, , 20

    'pDMDSplashHighScore "HIGHSCORES", "1-" & HighScoreName(0) & " " & HighScore(0), 22, 33023

    Case 2:               

    'pDMDSplashHighScore "HIGHSCORES", "2-" & HighScoreName(1) & " " & HighScore(1), 22, 33023                

    DispDmd1.text = " 1> " & HighScoreName(0) & "  " & HighScore(0)', seScrollRightOver
    DispDmd1.text = " 2> " & HighScoreName(1) & "  " & HighScore(1)', seScrollRightOver, , 20


    Case 3:


    DispDmd1.text = " 3> " & HighScoreName(2) & "  " & HighScore(2)', seScrollRightOver
    DispDmd1.text = " 4> " & HighScoreName(3) & "  " & HighScore(3)', seScrollRightOver, , 20

    'pDMDSplashHighScore "HIGHSCORES", "3-" & HighScoreName(2) & " " & HighScore(2), 22, 33023                

    Case 4:

    'pDMDSplashHighScore "HIGHSCORES", "4-" & HighScoreName(3) & " " & HighScore(3), 22, 33023                

    DispDmd1.text = " 3> " & HighScoreName(2) & "  " & HighScore(2)', seScrollRightOver
    DispDmd1.text = " 4> " & HighScoreName(3) & "  " & HighScore(3)', seScrollRightOver, , 20


    Case 5
     HSmessage = 0
     attractmessage = 5
     ShowHighScores.Enabled = 0
    messagetimer.Interval = 3000
    messagetimer.enabled = 1
    End Select
End Sub














' *********************************************************************
' **                                                                 **
' **                        FUTURE PINBALL                           **
' **                                                                 **
' **                   Generic Table Script v1.0                     **
' **                                                                 **
' **     © 2007 Chris Leathley - BSP Software Design Solutions     **
' **                                                                 **
' ** This script should provide a simple frame work you can use in   **
' ** your own tables as a starting point.                            **
' **                                                                 **
' *********************************************************************

'Option Explicit                ' Force explicit variable declaration
  ' DispDmd1.AddFont 1, "dmd05x05p"
'    DispDmd1.AddFont 2, "dmd06x07p"
'    DispDmd1.AddFont 3, "dmd08x09p"
'    DispDmd1.AddFont 4, "dmd08x13p"
'    DispDmd1.AddFont 5, "dmd09x11po"
'    DispDmd1.AddFont 6, "dmd09x15po"
'    DispDmd1.AddFont 7, "indyfont"
'    DispDmd1.AddFont 8, "isdmdfont1"
'    DispDmd1.AddFont 9, "gooniesf1"
'    DispDmd1.AddFont 10, "gooniesf2"
'    DispDmd1.AddFont 11, "gooniesf3"
'    DispDmd1.AddFont 12, "gooniesf4"
'    DispDmd1.AddFont 13, "gooniesf5"
'    DispDmd1.AddFont 14, "gooniesf6"

' Define any Constants
Const constMaxPlayers         = 4         ' Maximum number of players per game (between 1 and 4)
Const constBallSaverTime    = 7000    ' Time in which a free ball is given if it lost very quickly
                                                ' Set this to 0 if you don't want this feature
Const constMaxMultiplier    = 6        ' Defines the maximum bonus multiplier level

' Define Global Variables
'
Dim PlayersPlayingGame        ' number of players playing the current game
Dim CurrentPlayer                ' current player (1-4) playing the game
Dim BonusPoints(4)            ' Bonus Points for the current player
Dim BonusMultiplier(4)        ' Bonus Multiplier for the current player
Dim BallsRemaining(4)        ' Balls remaining to play (inclusive) for each player
Dim ExtraBallsAwards(4)        ' number of EB's out-standing (for each player)

' Define Game Control Variables
Dim LastSwitchHit                ' Id of last switch hit
Dim BallsOnPlayfield            ' number of balls on playfield (multiball exclusive)
Dim BallsInLock                ' number of balls in multi-ball lock

' Define Game Flags
'Dim bFreePlay                    ' Either in Free Play or Handling Credits
'Dim bOnTheFirstBall            ' First Ball (player one). Used for Adding New Players
'Dim bBallInPlungerLane        ' is there a ball in the plunger lane
'Dim bBallSaverActive            ' is the ball saver active
'Dim bMultiBallMode            ' multiball mode active ?
'Dim bEnteringAHighScore        ' player is entering their name into the high score table
dim liftno
dim ballno
dim scoreupdate
dim lastscore
dim spellarkframe
dim organhitsleft
dim tempsound
dim dataD
dim dataA
dim dataT
dim dataA2
dim slothS
dim slothL
dim slothO
dim slothT
dim slothH
dim oframestart
dim oframeend
dim ospeed
dim raidersjp
dim templejp
dim crusadejp
dim crystaljp
dim modename
dim mapmulti
dim swordhit
dim swordneeded
dim dmdfont
dim dmdspeed
dim currentframe
dim startframe
dim endframe
dim repeatdmd
dim jpscore
dim nextscenescore
dim indyscoring
dim jonesscoring
dim indyhitsleft
dim joneshitsleft
dim ballbonus
dim swordscore
dim totalbonus
dim arkhit
dim templehit
dim grailhit
dim skullhit
dim hitskull
dim mysterymode
dim hurrytotal
dim endtext
dim xmarks
dim xmarkshits
dim stonesleft
dim traphitsleft
dim stonekicker
dim indymatch
dim playermatch
dim rjackpothits
dim rjackpothitsleft
dim jackpotanim
dim templeopen
dim stonescollected
dim rampshots
dim rampshotsleft
dim loopd
dim keytotal
dim doubloon
dim slothmulti
dim jackpotscore
dim marbles
dim ballslocked
dim autoball
dim wellhit
dim wellsound
dim modetime
dim keysearch
dim boneplay
dim datachr
dim tchr
'dim temptext
dim comboon
dim combovalue
dim matchchr
dim endmatchchr
dim modejp
' ************************
'*********************************************
' **                                                                 **
' **               Future Pinball Defined Script Events              **
' **                                                                 **
' *********************************************************************


' The Method Is Called Immediately the Game Engine is Ready to
' Start Processing the Script.
'
Sub FuturePinball_BeginPlay()
    ' seed the randomiser (rnd(1) function)
    Randomize
nevertimer1.Interval = 2500
nevertimer1.Enabled = true' , 2500
lastscore =0
'LightSeq1.Play SeqRandomEffect,20,9999990
'dispdmd1.text = "[f9][xc][yc]" &chr(32)
 'overlay1.fadeout()

'Overlay1.Frame 1, 1395,1


' initalise the player display reel to the last known player scores
    'Player1Reel.SetValue(nvScore1)
    'Player2Reel.SetValue(nvScore2)
    'Player3Reel.SetValue(nvScore3)
    'Player4Reel.SetValue(nvScore4)

    ' We want the player to put in credits (Change this
    'bFreePlay = FALSE

    ' kill the last switch hit (this this variable is very usefull for game control)
    'set LastSwitchHit = DummyTrigger

    ' initialse any other flags
    bOnTheFirstBall = FALSE
    bEnteringAHighScore    = FALSE
    BallsOnPlayfield = 0
    BallsInLock    = 0
      SolLFlipper 0
      SolRFlipper 0
'matchgame()
    EndOfGame()
End Sub







' *********************************************************************
' **                                                                 **
' **                     User Defined Script Events                  **
' **                                                                 **
' *********************************************************************

' Initialise the Table for a new Game
'
Sub ResetForNewGame()
    Dim    i
    StopAttractMode
    bGameInPLay = True
    'AddDebugText "ResetForNewGame"

    ' get Future Pinball to zero out the nvScore (and nvSpecialScore) Variables
    ' aswell and ensure the camera is looking in the right direction.
    ' this also Sets the fpGameInPlay flag

    'BeginGame()

    'Player1Reel.ResetToZero
    'Player2Reel.ResetToZero
    'Player3Reel.ResetToZero
    'Player4Reel.ResetToZero

    ' increment the total number of games played
   TotalGamesPlayed = TotalGamesPlayed + 1

    ' Start with player 1
    CurrentPlayer = 1

    ' Single player (for now, more can be added in later)
    PlayersPlayingGame = 1

    ' We are on the First Ball (for Player One)
    bOnTheFirstBall = TRUE

    ' initialise all the variables which are used for the duration of the game
    ' (do all players incase any new ones start a game)
    For i = 1 To constMaxPlayers
        Score(i) = 0
        ' Bonus Points for the current player
        BonusPoints(i)    = 0
        ' Initial Bonus Multiplier
        BonusMultiplier(i) = 1
        ' Balls Per Game
        BallsRemaining(i) = BallsPerGame
        ' Number of EB's out-standing
        ExtraBallsAwards(i) = 0
    Next


    ' initialise any other flags
    bMultiBallMode = FALSE


    Game_Init
    ' you may wish to start some music, play a sound, do whatever at this point

    ' set up the start delay to handle any Start of Game Attract Sequence
    FirstBallDelayTimer.Interval = 500
    FirstBallDelayTimer.Enabled = TRUE
'    PuPlayer.playlistplayex pDMD,"DMDBackground","backdmd.jpg",0,1
'    PuPlayer.SetBackground pDMD,1
'    PuPlayer.LabelShowPage pDMD,1,0,""
'    pUpdateScores

End Sub

Sub Game_Init
modejp = false
PlaySong "mu_end"
target10.Isdropped = 0
target11.Isdropped = 0
target12.Isdropped = 0
target13.Isdropped = 0
target14.Isdropped = 0
target15.Isdropped = 0
target16.Isdropped = 0
tchr = 34
modetime = 0
keysearch = 0
wellsound = true
wellhit = 0
autoball = false
ballslocked = 0
loopd = ""
titletimer.Enabled = false
dmdanimtimer.Enabled = false
slothmulti = 1
jackpotscore = 1000000
marbles = 0
comboon = false
combovalue = 50000

if captiveP.RotX > 15 then
stonetarget.Isdropped = false
stonetarget1.Isdropped = false
stonetarget2.Isdropped = false
'stonetarget.render = false
'captiveP.RotX = 0
captiveDown 35, 0
end if

resetxmarks.Enabled = false
resetlights()
LightSeq1.stopplay()
nevertimer1.Enabled = false
nevertimer2.Enabled = false
nevertimer3.Enabled = false
nevertimer4.Enabled = false
nevertimer5.Enabled = false
nevertimer6.Enabled = false
nevertimer7.Enabled = false
nevertimer8.Enabled = false
nevertimer9.Enabled = false
nevertimer10.Enabled = false
nevertimer11.Enabled = false

neverreset.Enabled = false
nevern.state = 0: NeverNP.visible = 0
nevere1.state = 0: NeverEP.visible = 0
neverv.state = 0: NeverVP.visible = 0
nevere2.state = 0: NeverE2P.visible = 0
neverr.state = 0: NeverRP.visible = 0
nevers.state= 0: NeverSP.visible = 0
nevera.state = 0: NeverAP.visible = 0
nevery.state = 0: NeverYP.visible = 0
neverd.state = 0: NeverDP.visible = 0
neveri.state = 0: NeverIP.visible = 0
nevere3.state = 0: NeverEP3.visible = 0
playSound "ballready"',true
light27.state = 2
light28.state = 2
light29.state = 2
light30.state = 2
light31.state = 2
light32.state = 2
light33.state = 2
light34.state = 2
light35.state = 2
light51.state = 2
light48.state = 2
liftno = 1
scoreupdate = true
lastscore =0
spellarkframe = 42
organhitsleft = 7
tempsound = ""
raidersjp = 1000000
templejp = 1000000
crystaljp = 1000000
crusadejp = 1000000
modename = ""
mapmulti = 1
swordhit = 0
swordneeded = 5
nextscenescore = 1000000
replayscored = false
indyscoring = false
jonesscoring = false
indyhitsleft = 0
joneshitsleft = 0
ballbonus = 0
totalbonus = 0
arkhit = 0
templehit = 0
grailhit = 0
skullhit = 0
hitskull = true
mysterymode = ""
xmarks = 1
xmarkshits = 3
traphitsleft = 2
stonesleft = 3
stonekicker = false
jackpotanim = false
templeopen = false
stonescollected = 0
rampshots = 0
rampshotsleft = 5
dataD = " "
dataA = " "
dataT = " "
dataA2 = " "
slothS = " "
slothL = " "
slothO = " "
slothT = " "
slothH = " "
if fakedoor.isdropped = true then
resetdoor.Enabled = true ', 100
end if

End Sub


sub checkreplay()

        if (Score(CurrentPlayer) > replayscore) and (replayscored = false) then
            'pDMDSplashBig "REPLAY", 4, 33023
            scorereplay()
        end if

end sub

sub scorereplay()
    'PlaySound SoundFXDOF("fx_knocker",124,DOFPulse,DOFKnocker)

    DOF 140, DOFOn
    PlaySound SoundFXDOF("fx_knocker",136,DOFPulse,DOFKnocker)        
    DOF 115, DOFPulse
    replayscored = true
    Credits = Credits + 1
end sub


' This Timer is used to delay the start of a game to allow any attract sequence to
' complete.  When it expires it creates a ball for the player to start playing with
'
Sub FirstBallDelayTimer_Timer()
    ' stop the timer
    FirstBallDelayTimer.Enabled = FALSE

    ' reset the table for a new ball
    ResetForNewPlayerBall()

    ' create a new ball in the shooters lane
    CreateNewBall()
End Sub


' (Re-)Initialise the Table for a new ball (either a new ball after the player has
' lost one or we have moved onto the next player (if multiple are playing))
'
Sub ResetForNewPlayerBall()
combovalue = 50000
autoball = false
AddScore(0)
light49.state = 0
arkhit = 0
templehit = 0
grailhit = 0
skullhit = 0
hitskull = true
scoreupdate = true
marbles = 0
light50.state = 2
light40.state = 0
light37.state = 0
light26.state = 0
totalbonus = 0
AddScore(0)
PlaySong "plungerloop"
mapmulti = 1
light20.state = 0
light21.state = 0
light22.state = 0
xmarks = 1
xmarkshits = 3
jackpotanim = false
    ' set the current players bonus multiplier back down to 1X
    SetBonusMultiplier(1)
startskill()
    ' reset any drop targets, lights, game modes etc..
    ShootAgainLight.State = 0
keytotal = 0
doubloon = 0
rampshots = 0
if currentplayer = 1 then
ballbonus = ballbonus + 125000
end if
End Sub



' Create a new ball on the Playfield
'
Sub CreateNewBall()
    ' create a ball in the plunger lane kicker.
    PlungerKicker.CreateBall
    LastSwitchHit  = ""
    ' There is a (or another) ball on the playfield
    BallsOnPlayfield = BallsOnPlayfield + 1
    'Ballsindrain = Ballsindrain - 1

    'ballindrain = false

    ' kick it out..
    PlungerKicker.kick 90, 8
    'Playsound "BallRelease"
    'PlaySound SoundFXDOF("BallRelease",122,DOFPulse,DOFContactors), 0, 1, 0.1, 0.1
    PlaySoundAt SoundFXDOF("BallRelease", 114, DOFPulse, DOFContactors), PlungerKicker
End Sub


' The Player has lost his ball (there are no more balls on the playfield).
' Handle any bonus points awarded
'
Sub EndOfBall()
    Dim BonusDelayTime

    'AddDebugText "EndOfBall"

    ' the first ball has been lost. From this point on no new players can join in
    bOnTheFirstBall = FALSE

    ' only process any of this if the table is not tilted.  (the tilt recovery
    ' mechanism will handle any extra balls or end of game)
    If (Tilted = FALSE) Then
        Dim AwardPoints

        ' add in any bonus points (multipled by the bunus multiplier)
        AwardPoints = BonusPoints(CurrentPlayer) * BonusMultiplier(CurrentPlayer)
        AddScore(AwardPoints)
        'AddDebugText "Bonus Points = " & AwardPoints

        ' you may wish to do some sort of display effects which the bonus is
        ' being added to the players score

        ' add a bit of a delay to allow for the bonus points to be added up
        BonusDelayTime = 4500
      if keytotal > 0 then
        bonusdelaytime = bonusdelaytime + 1500
        end if
if doubloon > 0 then
        bonusdelaytime = bonusdelaytime + 1500
        end if

if grailhit > 0 then
        bonusdelaytime = bonusdelaytime + 1500
        end if
      starteob()
      if rampshots > 0 then
        bonusdelaytime = bonusdelaytime + 1500
        end if

if marbles > 0 then
        bonusdelaytime = bonusdelaytime + 1500
end if


      starteob()


    Else
        ' no bonus, so move to the next state quickly
        BonusDelayTime = 20
    End If

    ' start the end of ball timer which allows you to add a delay at this point
    EndOfBallTimer.Interval = BonusDelayTime
    EndOfBallTimer.Enabled = TRUE
End Sub


' The Timer which delays the machine to allow any bonus points to be added up
' has expired.  Check to see if there are any extra balls for this player.
' if not, then check to see if this was the last ball (of the currentplayer)
'
Sub EndOfBallTimer_Timer()
    ' disable the timer
    EndOfBallTimer.Enabled = FALSE
dim skilldelay
skilldelay = 100
    ' if were tilted, reset the internal tilted flag (this will also
    ' set fpTiltWarnings back to zero) which is useful if we are changing player LOL
    Tilted = FALSE

    ' has the player won an extra-ball ? (might be multiple outstanding)
    If (ExtraBallsAwards(CurrentPlayer) <> 0) Then

        'AddDebugText "Extra Ball"


        ' yep got to give it to them
        ExtraBallsAwards(CurrentPlayer) = ExtraBallsAwards(CurrentPlayer) - 1
dispdmd1.text = "SHOOT AGAIN!"
'pDMDSplashBig "SHOOT AGAIN!", 3, 33023

skilldelay = skilldelay +2000
        ' if no more EB's then turn off any shoot again light
        If (ExtraBallsAwards(CurrentPlayer) = 0) Then
            ShootAgainLight.State = 0


        End If
PlaySong "plungerloop"',true
startskilltimer.Enabled = skilldelay
        ' You may wish to do a bit of a song and dance at this point

        ' Create a new ball in the shooters lane
        

    Else    ' no extra balls

        BallsRemaining(CurrentPlayer) = BallsRemaining(CurrentPlayer) - 1

        ' was that the last ball ?
        If (BallsRemaining(CurrentPlayer) <= 0) Then

            'AddDebugText "No More Balls, High Score Entry"

            ' Submit the currentplayers score to the High Score system built into Future Pinball
            ' if they have gotten a high score then it will ask them for their initials.  If not
            ' it will call the FuturePinball_NameEntryComplete right away
            'bEnteringAHighScore = TRUE
            'EnterHighScore(CurrentPlayer)
            CheckHighscore
            ' you may wish to play some music at this point

        Else

            ' not the last ball (for that player)
            ' if multiple players are playing then move onto the next one
            EndOfBallComplete()

        End If
    End If
End Sub

sub startskilltimer_Timer()
startskilltimer.Enabled = false
startskill()
CreateNewBall()
end sub

' This function is called when the end of bonus display
' (or high score entry finished) and it either end the game or
' move onto the next player (or the next ball of the same player)
'
Sub EndOfBallComplete()
  Dim NextPlayer

    'AddDebugText "EndOfBall - Complete"

    ' are there multiple players playing this game ?
    If (PlayersPlayingGame > 1) Then
        ' then move to the next player
        NextPlayer = CurrentPlayer + 1
        ' are we going from the last player back to the first
        ' (ie say from player 4 back to player 1)
        If (NextPlayer > PlayersPlayingGame) Then
            NextPlayer = 1
        End If
    Else
        NextPlayer = CurrentPlayer
    End If

    'AddDebugText "Next Player = " & NextPlayer

   ' is it the end of the game ? (all balls been lost for all players)
    If ((BallsRemaining(CurrentPlayer) <= 0) And (BallsRemaining(NextPlayer) <= 0)) Then
        ' you may wish to do some sort of Point Match free game award here
        ' generally only done when not in free play mode

        ' set the machine into game over mode

      matchgame()
     ' EndOfGame()      

        ' you may wish to put a Game Over message on the

    Else
        ' set the next player
        CurrentPlayer = NextPlayer

        ' make sure the correct display is upto date
        AddScore(0)

        ' reset the playfield for the new player (or new ball)
        ResetForNewPlayerBall()

        ' and create a new ball
        CreateNewBall()

    End If
End Sub


' This frunction is called at the End of the Game, it should reset all
' Drop targets, and eject any 'held' balls, start any attract sequences etc..
Sub EndOfGame()
    'AddDebugText "End Of Game"
    ' let Future Pinball know that the game has finished.  
    ' This also clear the fpGameInPlay flag.
    'EndGame()

Select case (RandomNumber(4))
case 1: PlaySong  "intro"
case 2: PlaySong  "goodenough"
case 3: PlaySong  "intro"
case 4: PlaySong  "goodenough"
end select

'LightSeq1.Play SeqRandom,20,9999990
nevertimer1.interval = 2000
nevertimer1.Enabled = true
'dispdmd1.text = "[f9][xc][yc]" &chr(32)
matchchr = 32
endmatchchr = 89
dmdfont = " "
dmdspeed = 80
'dmdanimtimer.set true , 100
'endtext = "[f1] "
    ' ensure that the flippers are down
'    LeftFlipper.RotateToStart
'    RightFlipper.RotateToStart

if ballslocked > 0 then
SolLFlipper 0
SolRFlipper 0
LeftFlipper.RotateToStart
RightFlipper.RotateToStart
ballsonplayfield = ballslocked
popup1.IsDropped = 1
Popup.TransY = -25
PlaySound "DiverterOn"
end if

    ' turn off the reel bulbs
    'Player1Reel.State = BulbOff
    'Player2Reel.State = BulbOff
    'Player3Reel.State = BulbOff
    'Player4Reel.State = BulbOff

    ' set any lights for the attract mode
    SetAllLightsForAttractMode()
StartAttractMode
    ' you may wish to light any Game Over Light you may have
End Sub


' The tilt recovery timer waits for all the balls to drain before continuing on
' as per normal
'
Sub TiltRecoveryTimer_Timer()
    ' disable the timer
    TiltRecoveryTimer.Enabled    = FALSE
    ' if all the balls have been drained then..
    If (BallsOnPlayfield = 0) Then
        ' do the normal end of ball thing (this dosn't give a bonus if the table is tilted)
        EndOfBall()
    Else
        ' else retry (checks again in another second)
        TiltRecoveryTimer.Interval = 1000
        TiltRecoveryTimer.Enabled = TRUE
    End If
End Sub


' Set any lights for the Attract Mode.
'
Sub SetAllLightsForAttractMode()
    'ShootAgainLight.State = BulbBlink
   
End Sub

Sub Endattractmode()
    bAttractMode = False   
End Sub

' *********************************************************************
' **                                                                 **
' **                   Drain / Plunger Functions                     **
' **                                                                 **
' *********************************************************************

' lost a ball ;-( check to see how many balls are on the playfield.
' if only one then decrement the remaining count and test for End of game
' if more than 1 ball (multi-ball) then kill of the ball but don't create
' a new one
'
Sub Drain_Hit()
    ' Destroy the ball
    Drain.DestroyBall
    BallsOnPlayfield = BallsOnPlayfield - 1
    ' pretend to knock the ball into the ball storage mech
    PlaySound "fx_drain2"
if (BallsRemaining(CurrentPlayer) <= 0) then
exit sub
end if

    ' if there is a game in progress and
    If (bGameInPlay = TRUE) And (Tilted = FALSE) Then

        ' is the ball saver active,
        If (bBallSaverActive = TRUE) Then

            ' yep, create a new ball in the shooters lane
            CreateNewBall()
         'plunger.pull()
         plungertimer.Interval = 1000
         plungertimer.Enabled = true', 1000
            ' you may wish to put something on a display or play a sound at this point
         dispdmd1.text = "BALL SAVED"
         'pDMDSplashBig "BALL SAVED", 3, 33023
         'pNote "BALL SAVED", ""
         playsound "wait"
        Else

            ' cancel any multiball if on last ball (ie. lost all other balls)
            '
            If (BallsOnPlayfield = 1) Then
                ' and in a multi-ball??
                If (bMultiBallMode = True) then
if modename = "trapmulti" then

light39.state = 0
light49.state = 0
light44.state = 0
end if
if modename = "wizard" then
endwizard
end if
                restartmusic.Interval = 500
                restartmusic.Enabled = true', 500
                flushdmdtimer.Interval = 500
                flushdmdtimer.Enabled = true' ,500


                modename = ""
                resetrjackpot.Enabled = false
                    ' not in multiball mode any more
                    bMultiBallMode = False
               light36.state = 0
light37.state = 0
'light38.state = bulboff
light39.state = 0
light50.state = 0
light51.state = 0
                    ' you may wish to change any music over at this point and
                    ' turn off any multiball specific lights
                End If
            End If

            ' was that the last ball on the playfield
            If (BallsOnPlayfield = 0) Then
MainSeq.play seqalloff
if modename = "key" or modename = "boulder" or modename = "water" or modename = "fight" then
endmode
end if
if modename = "bone" then
resetdoor.Interval = 1000
resetdoor.Enabled = true ', 1000
endmode
end if
if slothmulti = 2 then


endsloth
end if
if modename = "truffle" then
endtruffle
modename = ""
end if


if modename = "sword" then
modename = ""
swordmodetimer.Enabled = false

light47.state = 0
swordmodetimer2.Enabled = false

swordneeded = swordneeded + 3
swordhit = 0

end if

if modename = "rats" or modename = "ants" or modename = "snakes" then
snakestimer1.Enabled = false
ratstimer1.Enabled = false
antstimer1.Enabled = false
snakestimer2.Enabled = false
snakesendtimer.Enabled = false
light50.state = 0
light51.state = 0
ratsendtimer.Enabled = false
ratstimer2.Enabled = false
antstimer2.Enabled = false
antsendtimer.Enabled = false

scoreupdate = true
modename = ""
restartmusic.Enabled = true' , 200
end if

if indyscoring = true then
endindy()
end if
if jonesscoring = true then
endjones()
end if


                ' handle the end of ball (change player, high score entry etc..)
                EndOfBall()
            End If

        End If
    End If
End Sub


' A ball is pressing down the trigger in the shooters lane
'
Sub PlungerLaneTrigger_Hit()
    bBallInPlungerLane = TRUE
    Bulb1.State = 2
    ' remember last trigger hit by the ball
    LastSwitchHit = "PlungerLaneTrigger"
End Sub


' A Ball may of rolled into the Plunger Lane Kicker, if so then kick it
' back out again
'
'Sub PlungerKicker_Hit()
'    PlungerKicker.Kick 90, 15
'playsound "fx_kicker"
'End Sub


' The Ball has rolled out of the Plunger Lane.  Check to see if a ball saver machanisim
' is needed and if so fire it up.
'
Sub PlungerLaneGate_Hit()
    ' if there is a need for a ball saver, then start off a timer
    ' only start if it is currently not running, else it will reset the time period
    If (constBallSaverTime <> 0) And (bBallSaverActive <> TRUE) Then
        ' and only if the last trigger hit was the plunger wire.
        ' (ball in the shooters lane)
        If (LastSwitchHit.Name = "PlungerLaneTrigger") Then
            ' set our game flag
            bBallSaverActive = TRUE
            ' start the timer
            BallSaverTimer.Enabled = FALSE
            BallSaverTimer.Interval = constBallSaverTime
            BallSaverTimer.Enabled = TRUE
            ' if you have a ball saver light you might want to turn it on at this
            ' point (or make it flash)
        End If
    End If
End Sub


' The ball saver timer has expired.  Turn it off and reset the game flag
'
Sub BallSaverTimer_Timer()
    ' stop the timer from repeating
    BallSaverTimer.Enabled = FALSE
    ' clear the flag
    bBallSaverActive = FALSE
    ' if you have a ball saver light then turn it off at this point

if (ExtraBallsAwards(CurrentPlayer) > 0) Then
shootagainlight.state = 1
Else
shootagainlight.state = 0
End If
End Sub



' *********************************************************************
' **                                                                 **
' **                   Supporting Score Functions                    **
' **                                                                 **
' *********************************************************************

' Add points to the score and update the score board
'
Sub AddScore(points)
    If (Tilted = FALSE) Then

        ' add the points to the current players score variable
        Score(CurrentPlayer) = Score(CurrentPlayer) + ((points)*slothmulti)
lastscore = points
        ' update the score displays

if scoreupdate = true and modename <> "truffle" then
        ' add the points to the correct display and light the current players display
            DispDmd1.Text = "[f7][xc][y3]" & formatscore(score(currentplayer)) & "BALL:" & (6 -BallsRemaining(CurrentPlayer)) & " PLAYER:" & currentplayer & "CREDITS:" & credits  & " "
                        'DispDmd1.State = BulbOn


    End if
if scoreupdate = true and modename = "truffle" then
        ' add the points to the correct display and light the current players display
            DispDmd1.Text = "[f2][x5][y12]" & formatscore(score(currentplayer)) & "TRUFFLE SHUFFLE" & "TARGETS WORTH 50,000" & " " & chr(tchr) & " "
            'pDMDSplashLines "TRUFFLE SHUFFLE" , "TARGETS WORTH 50,000" & " ", 4, 33023
                        'DispDmd1.State = BulbOn
    End if
if scoreupdate = true and slothmulti = 2 then
        ' add the points to the correct display and light the current players display
DispDmd1.Text =  "2X SCORING" & " " & chr(42) & " " & formatscore(score(currentplayer))
'pDMDSplashLines  "2X SCORING" , " "  , chr(42) & " "& formatscore(score(currentplayer)), 2, 33023
                        'DispDmd1.State = BulbOn
    End if
end if
        DMDScore
        'pUpdateScores
        checkreplay()
    ' you may wish to check to see if the player has gotten a replay
End Sub


' Add some points to the current Jackpot.
'
Sub AddJackpot(points)
    ' Jackpots only generally increment in multiball mode and not tilted
    ' but this dosn't have to tbe the case
    If (Tilted = False) Then

        If (bMultiBallMode = TRUE) Then
            Jackpot = Jackpot + points
            ' you may wish to limit the jackpot to a upper limit, ie..
            '    If (nvJackpot >= 6000) Then
            '        nvJackpot = 6000
            '     End if
        End if
    End if
End Sub


' Will increment the Bonus Multiplier to the next level
'
Sub IncrementBonusMultiplier()
    Dim NewBonusLevel

    ' if not at the maximum bonus level
    if (BonusMultiplier(CurrentPlayer) < constMaxMultiplier) then
        ' then set it the next next one and set the lights
        NewBonusLevel = BonusMultiplier(CurrentPlayer) + 1
        SetBonusMultiplier(NewBonusLevel)
   End if
End Sub


' Set the Bonus Multiplier to the specified level and set any lights accordingly
'
Sub SetBonusMultiplier(Level)
    ' Set the multiplier to the specified level
    BonusMultiplier(CurrentPlayer) = Level

    ' If the multiplier is 1 then turn off all the bonus lights
    If (BonusMultiplier(CurrentPlayer) = 1) Then
        ' insert your own code here
    Else
        ' there is a bonus, turn on all the lights upto the current level
        If (BonusMultiplier(CurrentPlayer) >= 2) Then
            ' insert your own code here
        End If
        ' etc..
    End If
End Sub



' *********************************************************************
' **                                                                 **
' **                     Table Object Script Events                  **
' **                                                                 **
' *********************************************************************

' The Left Slingshot has been Hit, Add Some Points and Flash the Slingshot Lights
'
Dim LStep,  LStep1, RStep,  RStep1
Sub LeftSlingshotRubber_Slingshot()
    ' add some points
playsound "unknownnotneeded4"
if modename = "rscene1" or modename = "rscene2" then
raidershit()
exit sub
end if
    AddScore(1000)
    ' flash the lights around the slingshot
    FlashForMs LeftSlingshotBulb1, 100, 50, 1
    FlashForMs LeftSlingshotBulb2, 100, 50, 1

    'flasher3.FlashForMs 200, 50, BulbOff
'flasher3b.FlashForMs 200, 50, BulbOff
'if light17.state = bulbon then
'light17.state = bulboff
'light19.state = bulbon
'exit sub
'end if
'if light19.state = bulbon then
'light19.state = bulboff
'light17.state = bulbon
'end if
    LeftSling4.Visible = 1
    Lemk.RotX = 26
    LStep = 0
    LeftSlingshotRubber.TimerEnabled = True
    DOF 140, DOFPulse
End Sub

Sub LeftSlingshotRubber_Timer
    Select Case LStep
        Case 1:LeftSLing4.Visible = 0:LeftSLing3.Visible = 1:Lemk.RotX = 14: PlaySoundAt SoundFXDOF("fx_slings", 103, DOFPulse, DOFContactors), LeftInLaneTrigger
        Case 2:LeftSLing3.Visible = 0:LeftSLing2.Visible = 1:Lemk.RotX = 2
        Case 3:LeftSLing2.Visible = 0:Lemk.RotX = -10:LeftSlingshotRubber.TimerEnabled = 0
    End Select

    LStep = LStep + 1
End Sub



Sub LeftSlingshotRubber1_Slingshot()
    ' add some points
    LeftSling004.Visible = 1
    Lemk001.RotX = 26
    LStep1 = 0
    LeftSlingshotRubber1.TimerEnabled = True
    DOF 140, DOFPulse
End Sub

Sub LeftSlingshotRubber1_Timer
    Select Case LStep1
        Case 1:LeftSLing004.Visible = 0:LeftSLing003.Visible = 1:Lemk001.RotX = 14: PlaySoundAt SoundFXDOF("fx_slings", 103, DOFPulse, DOFContactors), Trigger3
        Case 2:LeftSLing003.Visible = 0:LeftSLing002.Visible = 1:Lemk001.RotX = 2
        Case 3:LeftSLing002.Visible = 0:Lemk001.RotX = -10:LeftSlingshotRubber1.TimerEnabled = 0
    End Select

    LStep1 = LStep1 + 1
End Sub

' The Right Slingshot has been Hit, Add Some Points and Flash the Slingshot Lights
'
Sub RightSlingshotRubber_Slingshot()
    ' add some points
playsound "unknownnotneeded3"
if modename = "rscene1" or modename = "rscene2" then
raidershit()
exit sub
end if
    AddScore(1000)
    ' flash the lights around the slingshot
    FlashForMs RightSlingshotBulb1, 100, 50, 1
    FlashForMs RightSlingshotBulb2, 100, 50, 1
    'flasher2.FlashForMs 200, 50, BulbOff
'flasher2b.FlashForMs 200, 50, BulbOff
'if light17.state = bulbon then
'light17.state = bulboff
'light19.state = bulbon
'exit sub
'end if
'if light19.state = bulbon then
'light19.state = bulboff
'light17.state = bulbon
'end if

    DOF 121, DOFPulse
    RightSling4.Visible = 1
    Remk.RotX = 26
    RStep = 0
    RightSlingShotRubber.TimerEnabled = True
    DOF 141, DOFPulse

End Sub

Sub RightSlingshotRubber_Timer
    Select Case RStep
        Case 1:RightSLing4.Visible = 0:RightSLing3.Visible = 1:Remk.RotX = 14: PlaySoundAt SoundFXDOF("fx_slings", 103, DOFPulse, DOFContactors), RightInLaneTrigger
        Case 2:RightSLing3.Visible = 0:RightSLing2.Visible = 1:Remk.RotX = 2
        Case 3:RightSLing2.Visible = 0:Remk.RotX = -10:RightSlingShotRubber.TimerEnabled = 0
    End Select

    RStep = RStep + 1
End Sub


Sub RightSlingshotRubber1_Slingshot()
    ' add some points
    DOF 121, DOFPulse
    RightSling004.Visible = 1
    Remk001.RotX = 26
    RStep1 = 0
    RightSlingShotRubber1.TimerEnabled = True
    DOF 141, DOFPulse

End Sub

Sub RightSlingshotRubber1_Timer
    Select Case RStep1
        Case 1:RightSling004.Visible = 0:RightSLing003.Visible = 1:Remk001.RotX = 14: PlaySoundAt SoundFXDOF("fx_slings", 103, DOFPulse, DOFContactors), Trigger003
        Case 2:RightSLing003.Visible = 0:RightSLing002.Visible = 1:Remk001.RotX = 2
        Case 3:RightSLing002.Visible = 0:Remk001.RotX = -10:RightSlingShotRubber1.TimerEnabled = 0
    End Select

    RStep1 = RStep1 + 1
End Sub


'
' The Left InLane trigger has been Hit
'
Sub LeftInLaneTrigger_Hit()
 PlaySoundAt SoundFXDOF("fx_sensor", 103, DOFPulse, DOFContactors), LeftInLaneTrigger
if light42.state = 0 then
light42.state = 1
checkrich
end if

if modename = "rscene1" or modename = "rscene2" then
raidershit()
exit sub
end if
    ' add some points
    AddScore(1000)
    ' remember last trigger hit by the ball
    set LastSwitchHit = LeftInLaneTrigger
End Sub


' The Right InLane trigger has been Hit
'
Sub RightInLaneTrigger_Hit()
 PlaySoundAt SoundFXDOF("fx_sensor", 103, DOFPulse, DOFContactors), RightInLaneTrigger
    ' add some points
'if modename = "rscene1" or modename = "rscene2" then
'raidershit()
'exit sub
'end if
    AddScore(1000)
if light18.state = 0 then
light18.state = 1
checkrich
exit sub
end if
'if light18.state = bulbon then
'light18.state = bulboff
'bulb1.state = bulbon
'lightseq1.Play Seqblinking, , 5,50
'mystery lit
'playsound "unknownnotneeded10"
'exit sub
'end if
    ' remember last trigger hit by the ball
    set LastSwitchHit = RightInLaneTrigger
End Sub


' The Left OutLane trigger has been Hit
'
Sub LeftOutLaneTrigger_Hit()

Select case (RandomNumber(2))
case 1: PlaySoundAt SoundFXDOF("jerkalert", 103, DOFPulse, DOFContactors), LeftOutLaneTrigger
case 2: PlaySoundAt SoundFXDOF("chunkawshit", 103, DOFPulse, DOFContactors), LeftOutLaneTrigger
end select

'playsound "ballrollinga"
    ' add some points
if light17.state = 0 then
light17.state = 1
checkrich
end if

'if modename = "rscene1" or modename = "rscene2" then
'raidershit()
'exit sub
'end if
    AddScore(10000)
'if light17.state = bulbon then
'collectspecial()
'exit sub
'end if

select case (randomnumber(7))
case 1: PlaySoundAt SoundFXDOF("adiossenoir", 103, DOFPulse, DOFContactors), LeftOutLaneTrigger
case 2: PlaySoundAt SoundFXDOF("aghhaghh", 103, DOFPulse, DOFContactors), LeftOutLaneTrigger
case 3: PlaySoundAt SoundFXDOF("andwhosgonnacometosaveyou", 103, DOFPulse, DOFContactors), LeftOutLaneTrigger
case 4: PlaySoundAt SoundFXDOF("dontcallmejunior", 103, DOFPulse, DOFContactors), LeftOutLaneTrigger
case 5: PlaySoundAt SoundFXDOF("fxthenscream", 103, DOFPulse, DOFContactors), LeftOutLaneTrigger
case 6: PlaySoundAt SoundFXDOF("youcallthisarcheaology", 103, DOFPulse, DOFContactors), LeftOutLaneTrigger
case 7: PlaySoundAt SoundFXDOF("thisidhowwesaygoodbye", 103, DOFPulse, DOFContactors), LeftOutLaneTrigger
end select
    ' remember last trigger hit by the ball
    set LastSwitchHit = LeftOutLaneTrigger
End Sub


' The Right OutLane trigger has been Hit
'
Sub RightOutLaneTrigger_Hit()


Select case (RandomNumber(4))
case 1: PlaySoundAt SoundFXDOF("jerkalert", 103, DOFPulse, DOFContactors), RightOutLaneTrigger
case 2: PlaySoundAt SoundFXDOF("chunkawshit", 103, DOFPulse, DOFContactors), RightOutLaneTrigger
end select


if light19.state = 0 then
light19.state = 1
checkrich
end if

'if modename = "rscene1" or modename = "rscene2" then
'raidershit()
'exit sub
'end if
    ' add some points
    AddScore(10000)
'if light19.state = bulbon then
'collectspecial()
'exit sub
'end if
select case (randomnumber(7))
case 1: PlaySoundAt SoundFXDOF("adiossenoir", 103, DOFPulse, DOFContactors), RightOutLaneTrigger
case 2: PlaySoundAt SoundFXDOF("aghhaghh", 103, DOFPulse, DOFContactors), RightOutLaneTrigger
case 3: PlaySoundAt SoundFXDOF("andwhosgonnacometosaveyou", 103, DOFPulse, DOFContactors), RightOutLaneTrigger
case 4: PlaySoundAt SoundFXDOF("dontcallmejunior", 103, DOFPulse, DOFContactors), RightOutLaneTrigger
case 5: PlaySoundAt SoundFXDOF("fxthenscream", 103, DOFPulse, DOFContactors), RightOutLaneTrigger
case 6: PlaySoundAt SoundFXDOF("youcallthisarcheaology", 103, DOFPulse, DOFContactors), RightOutLaneTrigger
case 7: PlaySoundAt SoundFXDOF("thisidhowwesaygoodbye", 103, DOFPulse, DOFContactors), RightOutLaneTrigger
end select
    ' remember last trigger hit by the ball
    set LastSwitchHit = RightOutLaneTrigger
End Sub



'kicker3.createball  255,255,159
'kicker4.createball 255,255,159
'kicker5.createball 255,255,159
'kicker7.createball()
'kicker8.createball()
'kicker9.createball()
'kicker10.createball()



function FormatScore(num)
    Dim n, f, s
    n = CStr(num)
    f = ""
        
    do while len(n)>3
        if len(f)>0 then
            f = Right(n, 3) & "," & f
        else
            f = Right(n, 3)
        end if
        n = Left(n, Len(n)-3)
    loop
    if len(n)>0 then
        if len(f) > 0 then
            f = n & "," & f
        else
            f = n
        end if
    end if
    FormatScore = f
End Function

function RandomNumber(ByVal max)
    RandomNumber = Int(max * Rnd + 1)
end function
sub delayintro_Timer()
delayintro.Enabled = false
intro()
end sub


'Skill shot gate

sub trigger5_hit()
'fakegate1hit
If Tilted Then exit sub            
'playsound "fx_wire"
balldropsound.Enabled = true ', 500
if modename <>"" Or Tilted then
exit sub
end if
if modename = "" and autoball = false then
restartmusic.Enabled = true',200


skilltimer1.Enabled = false
skilltimer2.Enabled = false
skilltimer3.Enabled = false
skilltimer4.Enabled = false
skilltimer5.Enabled = false
addscore(1020)
end if
autoball = false
            bBallSaverActive = TRUE
            ' start the timer
            BallSaverTimer.Enabled = FALSE
            BallSaverTimer.Interval = constBallSaverTime
            BallSaverTimer.Enabled = TRUE
         shootagainlight.state = 2
if light52.state = 1 then
'indy jones scoring

startsloth
light52.state = 0

lightseq1.Play Seqblinking, , 5,50
end if

if light53.state = 1 then
startsword()

lightseq1.Play Seqblinking, , 5,50
light53.state = 0
end if
if light54.state = 1 then
' light mystery
playsound "unknownnotneeded10"
light41.state = 2
scoreupdate = false
flushdmdtimer.Interval = 2000
flushdmdtimer.Enabled = true' , 2000

lightseq1.Play Seqblinking, , 5,50
DispDmd1.Text = " DATA GADGET" & " LIT" & " " & chr(36)
'pDMDSplashBig "DATA GADGET LIT", 3, 33023
light54.state = 0
light27.state = 1
light28.state = 1
light29.state = 1
light30.state = 1

end if
if light55.state = 1 then
' light superpops
playsound "elephant"
scoreupdate = false
flushdmdtimer.Interval = 2000
flushdmdtimer.Enabled = true' , 2000

lightseq1.Play Seqblinking, , 5,50
DispDmd1.Text = " SUPER" & " POPS "
'pDMDSplashBig "SUPER POPS", 3, 33023
Bumper1L.state = 2
bumper2l.state = 2
bumper3l.state = 2
bumper4l.state = 2
light55.state = 0
end if
if light56.state = 1 then

DispDmd1.Text = " TRAP" & " OPEN "
'pDMDSplashBig "TRAP OPEN", 3, 33023
if templeopen = false then
opencaptive()
end if

'next scene
'playsound "youcheatdrjones"
'scoreupdate = false
'dmdspeed = 100
'startframe = 2
'endframe = 6
'repeatdmd = true
'dmdfont = "[f8]"
'showjptimer.set true, 2000
'flushdmdtimer.set true ,3500
'startanimation()
'jpscore = nextscenescore
'nextscenescore = nextscenescore  + 1000000
'nextscene()
light56.state = 0

lightseq1.Play Seqblinking, , 5,50
end if

end sub



sub restartmusic_Timer()
restartmusic.Enabled = false
PlaySong "mu_end"

if modename = "" and light41.state = 0 then
PlaySong "mu_end"
PlaySong "mu_maintheme"',true
end if

if slothmulti = 2 and modename = "" then
PlaySong "mu_end"
PlaySong "mu_slothmulti"', true
end if

if light41.state = 2 and modename = "" then
PlaySong "mu_end"
PlaySong "mu_data"', true
end if

if modename = "boulder" then
PlaySong "mu_end"
PlaySong "mu_boulder"' , true
end if

if modename = "bone" then
PlaySong "mu_end"
PlaySong "mu_bonemusic"' , true
end if

if modename = "fight" then
PlaySong "mu_end"
PlaySong "mu_fratfight"' , true
end if

if modename = "key" then
PlaySong "mu_end"
PlaySong "mu_keymusic"', true
end if

if modename = "truffle" then
PlaySong "mu_end"
PlaySong "mu_slothmulti"' , true
end if

if modename = "water" then
PlaySong "mu_end"
PlaySong "mu_waterslide"' , true
end if

if modename = "sword" then
PlaySong "mu_end"
PlaySong "mu_fratelies"', true
end if

if modename = "trapmulti" then
PlaySong "mu_end"
PlaySong "mu_multiball"', true
end if

if modename = "wizard" then
PlaySong "mu_end"
PlaySong "mu_goodenough"', true
end if

end sub

sub openark()
'lift1.dropped = false
'lift1.collidable = true
'lifttimer.set true , 500
'if lid.angleyz = 0 then
'lid.rotateyz 50,30
'end if
'if lid.angleyz = 30 then
'lid.rotateyz -50,0
'end if
end sub


'hit angle = 335
'open angle 245
'swordsman.anglexz = 245
 



'skillshot
sub startskill()
light53.state = 0
light54.state = 0
light55.state = 0
light56.state = 0


DispDmd1.Text =  "SKILLSHOT" & "SHOOT HERE FOR" & "SLOTH"
'pDMDSplash3Lines "SKILLSHOT", "SHOOT HERE", "FOR SLOTH", 2, 33023
light52.state = 1
skilltimer1.Interval = 5000
skilltimer1.Enabled = true',500
end sub
sub skilltimer1_Timer()
skilltimer1.Enabled = false

'swordsman
DispDmd1.Text =  "SKILLSHOT"  &" SHOOT HERE FOR" & " FRATELLIS"
'pDMDSplash3Lines "SKILLSHOT", "SHOOT HERE","FOR FRATELLIS", 2, 33023
light52.state = 0
light53.state = 1
skilltimer2.Interval = 5000
skilltimer2.Enabled = true',500
end sub
sub skilltimer2_Timer()
skilltimer2.Enabled = false

'mystery
DispDmd1.Text =  "SKILLSHOT"  &"SHOOT HERE FOR" & " DATA"
'pDMDSplash3Lines "SKILLSHOT", "SHOOT HERE", "FOR DATA", 2, 33023
light53.state = 0
light54.state = 1
skilltimer3.Interval = 5000
skilltimer3.Enabled = true',500
end sub
sub skilltimer3_Timer()
skilltimer3.Enabled = false

'super pops
DispDmd1.Text =  "SKILLSHOT"  &" SHOOT HERE FOR" & " SUPER POPS"
'pDMDSplash3Lines "SKILLSHOT", "SHOOT HERE", "FOR SUPER POPS", 2, 33023
light54.state = 0
light55.state = 1
skilltimer4.Interval = 5000
skilltimer4.Enabled = true',500
end sub
sub skilltimer4_Timer()
skilltimer4.Enabled = false

'next scene

DispDmd1.Text =  "SKILLSHOT"  &" SHOOT HERE FOR" & " OPEN TRAP"
'pDMDSplash3Lines "SKILLSHOT", "SHOOT HERE", "FOR OPEN TRAP", 2, 33023
light55.state = 0
light56.state = 1
skilltimer5.Interval = 5000
skilltimer5.Enabled = true',500
end sub

sub skilltimer5_Timer()
skilltimer5.Enabled = false
'indy jones
DispDmd1.Text =  "SKILLSHOT"  &" SHOOT HERE FOR" & " SLOTH"
'pDMDSplash3Lines "SKILLSHOT", "SHOOT HERE", "FOR SLOTH", 2, 33023
light52.state = 1
light56.state = 0
skilltimer1.Enabled = true',500
end sub

sub flushdmdtimer_Timer()
modejp = false
repeatdmd = false
scoreupdate = true
dmdtimer.Enabled = false
flushdmdtimer.Enabled = false
DispDmd1.Text = "[xc] [y3] [f7]" & formatscore(nvscore(currentplayer)) & "[f1][x0][y26]BALL:" & (6 -BallsRemaining(CurrentPlayer)) & "[f1][x40][y26]PLAYER:" & currentplayer & "[f1][x86][y26]CREDITS:" & nvcredits
dispdmd1.text = " "
addscore(0)
endtext = ""
end sub

'************************************************************************
'transmap
'************************************************************************
sub kicker7_hit()
PlaySoundAt SoundFXDOF("fx15", 114, DOFPulse, DOFContactors), Kicker7
Kicker7Fake.enabled = 0
if light46.state = 2 then
startwizard
exit sub
end if

if bulb4.state = 2 and modename ="bone" then
bonehit
exit sub
end if
if modename <> "" or slothmulti = 2 then
kicker7solenoidpulse()
exit sub
end if
 

if light43.state = 2 then
starttransmap


exit sub


end if
end sub


Sub kicker7solenoidpulse()
    PlaySound "salidadebola"
    Kicker7.Kick 0, 30, 1.5
    Kicker7FakeTimer.interval = 800
    Kicker7FakeTimer.enabled = True
End Sub

Sub Kicker1FakeTimer_Timer
    Kicker7FakeTimer.enabled = False
    Kicker7Fake.enabled = 1
End Sub

sub starttransmap()
PlaySong "mu_end"
restartmusic.Enabled = true ', 15000
kicker7timer.Enabled = true ', 15000
temptext = "TRANSLATE MAP"' & " "' & chr(40)
DispDmd1.Text =  temptext
'pDMDSplashLines ""&temptext, "", 8, 33023
transdisptimer.Enabled = true ', 500

target10.Isdropped = 0
target11.Isdropped = 0
target12.Isdropped = 0
target13.Isdropped = 0
target14.Isdropped = 0
target15.Isdropped = 0
target16.Isdropped = 0
if neverA.state = 0 then
neverA.state = 1
playsound "i_have_the_key"
'checknever
'startwatermode.set true , 12000
startkeymode.Interval = 8000
startkeymode.Enabled = true ', 8000
restartmusic.Interval = 15500
restartmusic.Enabled = true', 15500
kicker7timer.Interval = 17000
kicker7timer.Enabled = true', 17000
exit sub
end if

if nevery.state = 0 then
playsound "mouthintruders"
'dodge boulders
nevery.state = 1
'checknever
startbouldermode.Interval = 12000
startbouldermode.Enabled = true ', 12000
restartmusic.Interval = 12500
restartmusic.Enabled = true', 12500
kicker7timer.Interval = 18000
kicker7timer.Enabled = true', 18000
exit sub
end if
if neverd.state = 0 then
neverd.state = 1
playsound "boneorgan1"

startbonemode.Interval = 8000
startbonemode.Enabled = true ', 8000
restartmusic.Interval = 20500
restartmusic.Enabled = true', 20500
kicker7timer.Interval = 21000
kicker7timer.Enabled = true', 21000
'checknever
exit sub
end if
if neveri.state = 0 then
neveri.state = 1

playsound "mouthintruders"

startwatermode.Interval = 12000
startwatermode.Enabled = true ', 12000
restartmusic.Interval = 12500
restartmusic.Enabled = true', 12500
kicker7timer.Interval = 18000
kicker7timer.Enabled = true', 18000
'water slide
'checknever
exit sub
end if
if nevere3.state = 0 then
nevere3.state = 1
playsound "mouthintruders"
startfightmode.Interval = 12000
startfightmode.Enabled = true ', 12000
restartmusic.Interval = 34000'
restartmusic.Enabled = true', 34000
kicker7timer.Interval = 40000
kicker7timer.Enabled = true', 40000
'fight fratellis
'checknever
exit sub
end if
end sub
sub kicker7timer_Timer()
transdisptimer.Enabled = false
'playsound "mouthintruders"
kicker7timer.Enabled = false
kicker7solenoidpulse
if modename <> "bone" then
resetdoor.Interval = 2000
resetdoor.Enabled = true' , 1000
end if

end sub

'-------------------------------------
'Key Mode
'-------------------------------------
sub startkeymode_Timer()


transdisptimer.Enabled = false
light43.state = 0
light51.state = 2
light36.state = 2
light45.state = 2
light23.state = 2
light24.state = 2
light25.state = 2
startkeymode.Enabled = false
modename = "key"

modetime = 61
modetimer.Interval = 8000
modetimer.Enabled = true ', 8000
keysearch = 20
scoreupdate = false
playsound "keyintro"
DispDmd1.Text =  "[xc][y5][f5]HIT SPINNER TO[xc][y18]SEARCH FOR KEY[edge4]"
'pDMDSplashLines "HIT SPINNER TO", "SEARCH FOR KEY", 2, 33023
end sub

sub keyfound()
addscore(jackpotscore)
restartmusic.Interval = 2000
restartmusic.Enabled = true ', 2000
playsound "keyfound"
DispDmd1.Text =  "[xc][yc][f5]KEY FOUND![edge4]" & "[f9][xc][yc]" & chr(45)
'pDMDSplashBig "KEY FOUND!", 4, 33023
flushdmdtimer.Interval = 2000
flushdmdtimer.Enabled = true' , 2000
endmode
end sub

'------------------------------------------------------------------
'boulder mode
'----------------------
sub startbouldermode_Timer()


transdisptimer.Enabled false
light43.state = 0
light50.state = 2
light40.state = 2
light37.state = 2
light26.state = 2
light51.state = 2
light36.state = 2
light45.state = 2
light23.state = 2
light24.state = 2
light25.state = 2
startbouldermode.Enabled false
modename = "boulder"
playsound "boulders"
modetime = 45
modetimer.Interval = 8000
modetimer.Enabled true ', 8000
'keysearch = 30
scoreupdate = false
'playsound "i_have_the_key"
DispDmd1.Text =  "[xc][y5][f5]HIT LOOPS TO[xc][y18]DODGE BOULDERS[edge4]"
'pDMDSplashLines "HIT LOOPS TO", "DODGE BOULDERS", 2, 33023
end sub

sub boulderjp()
addscore(jackpotscore)
DispDmd1.Text =  "[xc][yc][f5]JACKPOT[edge4]"
'pDMDSplashBig "JACKPOT", 2, 33023
playsound "jackpot"
'flushdmdtimer.set true , 2000
modetimer.Interval = 2000
modetimer.Enabled true ', 2000

end sub
'---------------------------------------------
'bone organ mode


sub startbonemode_Timer()

transdisptimer.Enabled false
light43.state = 0
bulb4.state = 2
startbonemode.Enabled false
modename = "bone"
modetime = 45
modetimer.Interval = 14000
modetimer.Enabled = true ', 14000
'keysearch = 30
scoreupdate = false
boneplay = 0
playsound "boneorgan2"
DispDmd1.Text =  "[xc][y5][f5]PLAY THE[xc][y18]BONES[edge4]"
'pDMDSplashLines "PLAY THE", "BONES", 4, 33023
end sub

sub bonehit()
boneplay = boneplay + 1

if boneplay = 1 or boneplay = 2 then
playsound "boneorgan6"
addscore(jackpotscore)
DispDmd1.Text =  "[xc][yc][f5]JACKPOT[edge4]"
'pDMDSplashBig "JACKPOT", 4, 33023
'flushdmdtimer.set true , 2000
modetimer.Interval = 2000
modetimer.Enabled = true ', 2000
kicker7timer.Interval = 2000
kicker7timer.Enabled true ', 2000
'resetdoor,set true , 3000
end if

if boneplay = 3 then
playsound "boneorgan3"
addscore(jackpotscore)
DispDmd1.Text =  " SUPER JACKPOT "
'pDMDSplashBig "SUPER JACKPOT", 4, 33023
flushdmdtimer.Interval = 2000
flushdmdtimer.Enabled = true' , 2000
delayendmode.Interval = 2000
delayendmode.Enabled true ', 2000
kicker7timer.Interval = 2000
kicker7timer.Enabled true ', 2000
resetdoor.Interval = 3000
resetdoor.Enabled true ', 3000
restartmusic.Interval = 3000
restartmusic.Enabled true ', 2000
end if
end sub

'-------------------------------------------------------------
'Water slide mode

sub startwatermode_Timer()

transdisptimer.Enabled false
light43.state = 0
light44.state = 2
light39.state = 2
light49.state = 2

startwatermode.Enabled = false
modename = "water"
modetime = 45
modetimer.Interval = 8000
modetimer.Enabled = true ' 8000
'keysearch = 30
scoreupdate = false
DispDmd1.Text =  "WATER SLIDE"
'pDMDSplashBig "WATER SLIDE", 4, 33023
end sub


sub waterjp()
addscore(jackpotscore)
modejp = true
flushdmdtimer.Interval = 6500
flushdmdtimer.Enabled = true' , 6500
playsound "water_slide"
dmdfont = ""

matchchr = 32
endmatchchr = 91
dmdanimtimer.Enabled = true' , 100
dmdspeed = 70

endtext =  "JACKPOT"
'flushdmdtimer.set true , 2000
modetimer.Interval = 2000
modetimer.Enabled = true ', 2000

end sub

'--------------------------------------------------------------------
'fight fratellis


sub startfightmode_Timer()

transdisptimer.Enabled = false
light43.state = 0
light20.state = 2
light21.state = 2
light22.state = 2

playsound "fratfightstart"
startfightmode.set false
modename = "fight"
modetime = 45
modetimer.Interval = 8000
modetimer.Enabled = true ' 8000
'keysearch = 30
scoreupdate = false
DispDmd1.Text =  "FIGHT THE FRATELLIS"
'pDMDSplashBig "FIGHT THE FRATELLIS", 4, 33023
end sub


sub fighthit()
addscore(jackpotscore)
DispDmd1.Text =  "JACKPOT"
'pDMDSplashBig "JACKPOT", 4, 33023
playsound "jackpot"
'flushdmdtimer.set true , 2000
modetimer.Interval = 2000
modetimer.Enabled = true ' 2000

end sub


sub delayendmode_Timer()
delayendmode.set false
endmode
end sub


sub transdisptimer_Timer()
if temptext =  "TRANSLATE MAP" then
temptext =  "TRANSLATE MAP"' & " " & chr(41)
'pDMDSplashLines "TRANSLATE MAP", "", 4, 33023
else
temptext =  "TRANSLATE MAP"' & " "' & chr(40)
end if
dispdmd1.text = temptext
'pDMDSplashLines ""&temptext, "", 4, 33023
 end sub


sub modetimer_Timer()
modetime = modetime - 1
modetimer.Interval = 1000
modetimer.Enabled = true ' 1000
if modetime < 0 then
restartmusic.Interval = 1000
restartmusic.Enabled = true', 500
flushdmdtimer.Interval = 500
flushdmdtimer.Enabled = true' , 500
if modename = "bone" then

kicker7timer.Enabled = true ', 1000
resetdoor.Enabled = true' , 2000
end if

endmode
end if
if modejp = false then
if modename = "key" then
DispDmd1.Text =  "SEARCH FOR KEY" & keysearch & " " & modetime & " " & " " & chr(45)
'pDMDSplashLines "SEARCH FOR KEY",keysearch&" " & modetime & " " & " ", 2, 33023
end if
if modename = "boulder" then
DispDmd1.Text =  "HIT LOOPS" & " " & modetime & " "
'pDMDSplashLines "HIT LOOPS" , " "& modetime, 2, 33023
end if


if modename = "bone" then
DispDmd1.Text =  "HIT BONE ORGAN" & " " & modetime & " "
'pDMDSplashLines "HIT BONE ORGAN" , " " & modetime, 2, 33023
end if
if modename = "water" then
DispDmd1.Text =  "HIT RAMP" & " " & modetime & " "
'pDMDSplashLines "HIT RAMP" , " " & modetime, 2, 33023
end if
if modename = "fight" then
DispDmd1.Text =  "HIT FRATELLIS" & " " & modetime & " "
'pDMDSplashLines "HIT FRATELLIS" , " " & modetime, 2, 33023
end if
end if

end sub

sub endmode()
checknever
organhitsleft = 7
if modename = "key" then
modename = ""
modetimer.Enabled = false
light51.state = 1
light36.state = 1
light45.state = 1
light23.state = 1
light24.state = 2
light25.state = 0
'scoreupdate = true
end if
if modename = "boulder" then
modename = ""
modetimer.Enabled = false
light50.state = 2
light40.state = 0
light37.state = 0
light26.state = 0
light51.state = 1
light36.state = 1
light45.state = 1
light23.state = 1
light24.state = 2
light25.state = 0
'scoreupdate = true
end if
if modename = "bone" then
modename = ""
bulb4.state = 0
modetimer.Enabled = false

end if
if modename = "water" then
modename = ""
light49.state = 0
light39.state = 0
light44.state = 0

modetimer.Enabled = false

end if

if modename = "fight" then
modename = ""
light20.state = 0
light21.state = 0
light22.state = 0
playsound "fratfightend"
modetimer.Enabled = false

end if
end sub



'need to add hits left display
sub target10_hit()
PlaySoundAt SoundFXDOF("fx_droptarget", 103, DOFPulse, DOFContactors), target10
'playsound "fx_droptarget"
if modename = "truffle" then
trufflehit
end if

if light43.state = 2 then
exit sub
end if

if modename <> "" then

target10.Isdropped = 0
end if
if modename = "" then
'flasher4.state = bulbblink
'flasher5.state = bulbblink
'bulb11.state = bulbblink
'bulb19.state = bulbblink
'flasheroff.set true , 500
organhitsleft = organhitsleft - 1
'spellarkframe = spellarkframe + 1
addscore (5000)
if organhitsleft = 0 then
startmap
exit sub
end if

if scoreupdate = true then
scoreupdate = false
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(spellarkframe)
dispdmd1.text = "[f3][xc][y3]BONE ORGAN" & "[xc][y19]" &  organhitsleft & " MORE FOR MAP[edge4]"
'pDMDSplashLines "BONE ORGAN" , organhitsleft&" MORE FOR MAP", 2, 33023
flushdmdtimer.Interval = 2000
 flushdmdtimer.Enabled = true' , 2000
end if
exit sub
end if

end sub
sub target11_hit()
PlaySoundAt SoundFXDOF("fx_droptarget", 103, DOFPulse, DOFContactors), Target11
'playsound "fx_droptarget"
if modename = "truffle" then
trufflehit
target11.Isdropped = 0
end if
if light43.state = 2 then
exit sub
end if
if modename <> "" then

target11.Isdropped = 0
end if
if modename = "" then
'flasher4.state = bulbblink
'flasher5.state = bulbblink
'bulb11.state = bulbblink
'bulb19.state = bulbblink
'flasheroff.set true , 500
organhitsleft = organhitsleft - 1
'spellarkframe = spellarkframe + 1
addscore (5000)
if organhitsleft = 0 then
startmap
exit sub
end if

if scoreupdate = true then
scoreupdate = false
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(spellarkframe)
dispdmd1.text = "[f3][xc][y3]BONE ORGAN" & "[xc][y19]" &  organhitsleft & " MORE FOR MAP[edge4]"
'pDMDSplashLines "BONE ORGAN" , organhitsleft&" MORE FOR MAP", 2, 33023
flushdmdtimer.Interval = 2000
 flushdmdtimer.Enabled = true' , 2000
end if
exit sub
end if
end sub



sub target12_hit()
PlaySoundAt SoundFXDOF("fx_droptarget", 103, DOFPulse, DOFContactors), Target12
'playsound "fx_droptarget"
if modename = "truffle" then
trufflehit
target12.Isdropped = 0
end if
if light43.state = 2 then
exit sub
end if
if modename <> "" then

target12.Isdropped = 0
end if
if modename = "" then
'flasher4.state = bulbblink
'flasher5.state = bulbblink
'bulb11.state = bulbblink
'bulb19.state = bulbblink
'flasheroff.set true , 500
organhitsleft = organhitsleft - 1
'spellarkframe = spellarkframe + 1
addscore (5000)
if organhitsleft = 0 then
startmap
exit sub
end if

if scoreupdate = true then
scoreupdate = false
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(spellarkframe)
dispdmd1.text = "[f3][xc][y3]BONE ORGAN" & "[xc][y19]" &  organhitsleft & " MORE FOR MAP[edge4]"
'pDMDSplashLines "BONE ORGAN" , organhitsleft&" MORE FOR MAP", 2, 33023
flushdmdtimer.Interval = 2000
 flushdmdtimer.Enabled = true' , 2000
end if
exit sub
end if
end sub




sub target13_hit()
PlaySoundAt SoundFXDOF("fx_droptarget", 103, DOFPulse, DOFContactors), Target13
'playsound "fx_droptarget"
if modename = "truffle" then
trufflehit
target13.Isdropped = 0
end if
if light43.state = 2 then
exit sub
end if
if modename <> "" then

target13.Isdropped = 0
end if
if modename = "" then
'flasher4.state = bulbblink
'flasher5.state = bulbblink
'bulb11.state = bulbblink
'bulb19.state = bulbblink
'flasheroff.set true , 500
organhitsleft = organhitsleft - 1
'spellarkframe = spellarkframe + 1
addscore (5000)
if organhitsleft = 0 then
startmap
exit sub
end if

if scoreupdate = true then
scoreupdate = false
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(spellarkframe)
dispdmd1.text = "[f3][xc][y3]BONE ORGAN" & "[xc][y19]" &  organhitsleft & " MORE FOR MAP[edge4]"
'pDMDSplashLines "BONE ORGAN" , organhitsleft&" MORE FOR MAP", 2, 33023
flushdmdtimer.Interval = 2000
 flushdmdtimer.Enabled = true' , 2000
end if
exit sub
end if
end sub



sub target14_hit()
PlaySoundAt SoundFXDOF("fx_droptarget", 103, DOFPulse, DOFContactors), Target14
'playsound "fx_droptarget"
if modename = "truffle" then
trufflehit
target14.Isdropped = 0
end if
if light43.state = 2 then
exit sub
end if
if modename <> "" then

target14.Isdropped = 0
end if
if modename = "" then
'flasher4.state = bulbblink
'flasher5.state = bulbblink
'bulb11.state = bulbblink
'bulb19.state = bulbblink
'flasheroff.set true , 500
organhitsleft = organhitsleft - 1
'spellarkframe = spellarkframe + 1
addscore (5000)
if organhitsleft = 0 then
startmap
exit sub
end if

if scoreupdate = true then
scoreupdate = false
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(spellarkframe)
dispdmd1.text = "[f3][xc][y3]BONE ORGAN" & "[xc][y19]" &  organhitsleft & " MORE FOR MAP[edge4]"
'pDMDSplashLines "BONE ORGAN" , organhitsleft&" MORE FOR MAP", 2, 33023
flushdmdtimer.Interval = 2000
 flushdmdtimer.Enabled = true' , 2000
end if
exit sub
end if
end sub



sub target15_hit()
PlaySoundAt SoundFXDOF("fx_droptarget", 103, DOFPulse, DOFContactors), Target15
'playsound "fx_droptarget"
if modename = "truffle" then
trufflehit
target15.Isdropped = 0
end if
if light43.state = 2 then
exit sub
end if
if modename <> "" then

target15.Isdropped = 0
end if
if modename = "" then
'flasher4.state = bulbblink
'flasher5.state = bulbblink
'bulb11.state = bulbblink
'bulb19.state = bulbblink
'flasheroff.set true , 500
organhitsleft = organhitsleft - 1
'spellarkframe = spellarkframe + 1
addscore (5000)
if organhitsleft = 0 then
startmap
exit sub
end if

if scoreupdate = true then
scoreupdate = false
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(spellarkframe)
dispdmd1.text = "[f3][xc][y3]BONE ORGAN" & "[xc][y19]" &  organhitsleft & " MORE FOR MAP[edge4]"
'pDMDSplashLines "BONE ORGAN" , organhitsleft&" MORE FOR MAP", 2, 33023
flushdmdtimer.Interval = 2000
 flushdmdtimer.Enabled = true' , 2000
end if
exit sub
end if

end sub



sub target16_hit()
PlaySoundAt SoundFXDOF("fx_droptarget", 103, DOFPulse, DOFContactors), Target16
'playsound "fx_droptarget"
if modename = "truffle" then
trufflehit
target16.Isdropped = 0
end if
if light43.state = 2 then
target16.Isdropped = 0
exit sub
end if
if modename <> "" then

target16.Isdropped = 0
end if

if modename = "" then
'flasher4.state = bulbblink
'flasher5.state = bulbblink
'bulb11.state = bulbblink
'bulb19.state = bulbblink
'flasheroff.set true , 500
organhitsleft = organhitsleft - 1
'spellarkframe = spellarkframe + 1
addscore (5000)
if organhitsleft = 0 then
startmap
exit sub
end if

if scoreupdate = true then
scoreupdate = false
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(spellarkframe)
dispdmd1.text = "[f3][xc][y3]BONE ORGAN" & "[xc][y19]" &  organhitsleft & " MORE FOR MAP[edge4]"
'pDMDSplashLines "BONE ORGAN" , organhitsleft&" MORE FOR MAP", 2, 33023
flushdmdtimer.Interval = 2000
 flushdmdtimer.Enabled = true' , 2000
end if
exit sub
end if

end sub


sub startmap()
light43.state = 2
fakedoor.Isdropped = true
bulb4.state = 2
'door.MoveTo door.Tx, door.Ty-40, door.Tz , 50
DoorDown 60, 0
end sub

Sub Fakedoor_Hit
    Playsound "tack"
End Sub


sub startraiderscene1()
jackpotanim = false
lightseq1.play seqalloff
flushdmdtimer.set false
rjackpothits = 10
rjackpothitsleft = 10
magnet.Isdropped = false
magnet.render = false
'overlay1.fadein()
'Overlay1.Frame 73, 274,73
ospeed = 77
oframestart =73
oframeend = 274

scoreupdate = false
endtext  = "" & score(currentplayer) & " " & lastscore &" " & " " & chr(58) & " " & rjackpothitsleft & " MORE" & "SWITCHES" & "FOR JACKPOT"

'startoverlay()
'ball release
stopmusic 1
sounddelay.set true, 820
tempsound =  "raidersintro"
'light1.state = bulbon
'light2.state = bulbblink
spellarkframe = 38
organhitsleft = 19

delayark.set true,16000
modename = "rscene1"
bMultiBallMode = True
end sub
sub delayark_Timer()
lightseq1.stopplay()
delayark.set false
openark()
'if modename = "rscene1" then
fourballtimer.set true, 500
'end if
delayark2.set true,1000
'overlay1.fadeout()
'overlay1.frame 1,1,1
end sub
sub delayark2_Timer()
delayark2.set false
openark()
restartmusic.Interval = 15000
restartmusic.Enabled = true
end sub
sub fourballtimer_Timer()
fourballtimer.set false
'kicker7.createball
'kicker8.createball
'kicker9.createball
'kicker10.createball
balldropsound.set true ,1500
magnet.Isdropped = true
if modename = "rscene1" then
createnewball()
'plunger.pull
threeballtimer.set true,1500
end if
end sub

sub threeballtimer_Timer()
threeballtimer.set false
plungersolenoidpulse
ballcreatetimer.set true,500
twoballtimer.set true, 1500
end sub
sub twoballtimer_Timer()
twoballtimer.set false
plungersolenoidpulse
ballcreatetimer.set true,500
oneballtimer.set true, 1500
end sub

sub oneballtimer_Timer()
oneballtimer.set false
plungersolenoidpulse
end sub
 sub ballcreatetimer_Timer()
createnewball()
'plunger.pull
ballcreatetimer.set false
end sub

sub startraiderscene2()
jackpotanim = false
lightseq1.play seqalloff
flushdmdtimer.set false
rjackpothits = 10
rjackpothitsleft = 10
magnet.Isdropped = false
magnet.render = false
'overlay1.fadein()
'Overlay1.Frame 73, 274,73
ospeed = 77
oframestart =73
oframeend = 274

scoreupdate = false
endtext  = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x95][y7]" & rjackpothitsleft & " MORE" & "[f5][x90][y25]TO LIGHT" & "[f5][x90][y45]JACKPOT"

startoverlay()
'ball release
stopmusic 1
sounddelay.set true, 820
tempsound =  "raidersintro"
light2.state = 1
light3.state = 2
spellarkframe = 38
organhitsleft = 19
delayark.set true,16000
modename = "rscene2"
bMultiBallMode = True
restartmusic.Interval = 15000
restartmusic.Enabled = true
end sub
sub startraiderscene3()
jackpotanim = false
lightseq1.play seqalloff
rjackpothits = 3
rjackpothitsleft = 3
flushdmdtimer.set false
magnet.Isdropped = false
magnet.render = false
'overlay1.fadein()
'Overlay1.Frame 73, 274,73
ospeed = 77
oframestart =73
oframeend = 274

scoreupdate = false
endtext = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x95][y7]" & rjackpothitsleft & " MORE" & "[f5][x90][y25]TO LIGHT" & "[f5][x90][y45]JACKPOT"

startoverlay()
'ball release
stopmusic 1
sounddelay.set true, 820
tempsound =  "raidersintro"
light3.state = 1
light4.state = 2
spellarkframe = 38
organhitsleft = 19
delayark.set true,16000
modename = "rscene3"
bMultiBallMode = True
restartmusic.Interval = 15000
restartmusic.Enabled = true
end sub
sub startraiderscene4()
jackpotanim = false
lightseq1.play seqalloff
rjackpothits = 2
rjackpothitsleft = 2
flushdmdtimer.set false
magnet.Isdropped = false
magnet.render = false
'overlay1.fadein()
'Overlay1.Frame 73, 274,73
ospeed = 77
oframestart =73
oframeend = 274
endtext = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x95][y7]" & rjackpothitsleft & " MORE" & "[f5][x90][y25]TO LIGHT" & "[f5][x90][y45]JACKPOT"

scoreupdate = false
light36.state = 2
light37.state = 2
'light38.state = bulbblink
light39.state = 2
light50.state = 2
light51.state = 2

startoverlay()
'ball release
stopmusic 1
sounddelay.set true, 820
tempsound =  "raidersintro"
light4.state = 1
light23.state = 2
spellarkframe = 38
organhitsleft = 19
delayark.set true,16000
modename = "rscene4"
bMultiBallMode = True
restartmusic.Interval = 15000
restartmusic.Enabled = true
end sub

sub raidershit()
rjackpothitsleft = rjackpothitsleft - 1
addscore(5000)
if rjackpothitsleft = 0 and modename = "rscene1"then
raiderjackpotgot()
if rjackpothits = 40 or rjackpothits = 60 or rjackpothits = 80 or rjackpothits = 100 then
lightrsuper()
exit sub
end if

if rjackpothits = 10 and modename = "rscene1" then
rjackpothits = 30
else
rjackpothits = rjackpothits + 5
end if

rjackpothitsleft = rjackpothits
exit sub
end if
if rjackpothitsleft = 0 and modename = "rscene2"then
raiderjackpotlight1()
rjackpothits = rjackpothits + 10
rjackpothitsleft = rjackpothits
exit sub
end if
if rjackpothitsleft = 0 and modename = "rscene3"then
lightrsuper3()
exit sub
end if
if rjackpothitsleft = 0 and modename = "rscene4"then
lightjackpot4()
exit sub
end if
if jackpotanim = false and modename = "rscene1" then
dispdmd1.text = " " & score(currentplayer) & "" & lastscore &"" & "" & chr(58) & "" & rjackpothitsleft & " MORE" & "SWITCHES" & "FOR JACKPOT"
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", rjackpothitsleft & " MORE" & "SWITCHES" & "FOR JACKPOT", 2, 33023
end if
if jackpotanim = false and modename = "rscene2" then
dispdmd1.text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x95][y7]" & rjackpothitsleft & " MORE" & "[f5][x90][y25]TO LIGHT" & "[f5][x90][y45]JACKPOT"
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", rjackpothitsleft & " MORE" & " TO LIGHT" & " JACKPOT", 2, 33023
end if
if jackpotanim = false and modename = "rscene3" then
dispdmd1.text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x95][y7]" & rjackpothitsleft & " MORE" & "[f5][x90][y25]TO LIGHT" & "[f5][x90][y45]JACKPOT"
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", rjackpothitsleft & " MORE" & " TO LIGHT" & " JACKPOT", 2, 33023
end if
if jackpotanim = false and modename = "rscene4" then
dispdmd1.text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x95][y7]" & rjackpothitsleft & " MORE" & "[f5][x90][y25]TO LIGHT" & "[f5][x90][y45]JACKPOT"
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", rjackpothitsleft & " MORE" & " TO LIGHT" & " JACKPOT", 2, 33023
end if
end sub

sub lightrsuper()
'light38.state = bulbblink
modename = "rsuper"
dispdmd1.text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x85][y7]HIT ARK FOR" & "[f5][x95][y25]SUPER" & "[f5][x90][y45]JACKPOT"
'pDMDSplashLines " "& score(currentplayer) & " " & lastscore &"" & "", "HIT ARK FOR SUPER JACKPOT", 2, 33023
end sub

sub getrsuper()

lightseq1.Play Seqblinking, , 20,50
jackpotanim = true
ospeed = 77
oframestart =354
oframeend = 399
startoverlay()
jpscore = raidersjp*5
endtext = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64][f8][x60][yc]" & chr(59) & "[f7][x80][yc]" & formatscore(jpscore)
'pDMDSplashLines " "& score(currentplayer) & " " & lastscore &"" & "", " "& formatscore(jpscore) , 2, 33023
addscore(jpscore)
resetrjackpot.set true ,5000
sounddelay.set true,3500
tempsound = "superjackpot2"
modename = "rscene1"
rjackpothits = rjackpothits + 5
'light38.state = bulboff
rjackpothitsleft = rjackpothits
end sub
sub raiderjackpotgot()

lightseq1.Play Seqblinking, , 20,50
jackpotanim = true
ospeed = 77
oframestart =275
oframeend = 306
startoverlay()
jpscore = raidersjp
endtext = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64][f8][x60][yc]" & chr(59) & "[f7][x80][yc]" & formatscore(jpscore)
addscore(jpscore)
if modename = "rscene1" then
resetrjackpot.set true ,4000
end if

sounddelay.set true,2500
tempsound = "jackpot2"
end sub

sub resetrjackpot_Timer()
jackpotanim = false
resetrjackpot.set false
if modename = "rsuper" then
dispdmd1.text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x85][y7]HIT ARK FOR" & "[f5][x95][y25]SUPER" & "[f5][x90][y45]JACKPOT"
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", "HIT ARK FOR SUPER JACKPOT", 2, 33023
else
dispdmd1.text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x95][y7]" & rjackpothitsleft & " MORE" & "[f5][x90][y25]SWITCHES" & "[f5][x80][y45]FOR JACKPOT"
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", rjackpothitsleft & " MORE SWITCHES FOR JACKPOT", 2, 33023
end if
if modename = "rscene2" or modename = "rscene3" or modename = "rscene4" then
dispdmd1.text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x95][y7]" & rjackpothitsleft & " MORE" & "[f5][x90][y25]TO LIGHT" & "[f5][x90][y45]JACKPOT"
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", rjackpothitsleft & " MORE TO LIGHT JACKPOT", 2, 33023
end if
if modename = "rfinal" then
dispdmd1.text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x95][y7]HIT ARK" & "[f5][x105][y25]FOR" & "[f5][x90][y45]JACKPOT"
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", "HIT ARK FOR JACKPOT" , 2, 33023
end if


end sub

sub raiderjackpotlight1()
'light38.state = bulbblink
modename = "r2jackpot"
dispdmd1.text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x85][y7]HIT ARK FOR" & "[f5][x90][y45]JACKPOT"
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", "HIT ARK FOR JACKPOT" , 2, 33023
end sub

sub getr2jackpot()
lightseq1.Play Seqblinking, , 20,50
jackpotanim = true
ospeed = 77
oframestart =307
oframeend = 334
startoverlay()
jpscore = raidersjp
endtext = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64][f8][x60][yc]" & chr(59) & "[f7][x80][yc]" & formatscore(jpscore)
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", " "& formatscore(jpscore) , 2, 33023
addscore(jpscore)
modename = "rscene2"
resetrjackpot.set true ,4000
'light38.state = bulboff

sounddelay.set true,2500
tempsound = "jackpot2"

end sub
sub raiderjackpotgot3()
if rjackpothits =7 or rjackpothits =13 or rjackpothits =18 or rjackpothits = 24 then
getrsuper3()
exit sub
end if
rjackpothits = rjackpothits + 1

rjackpothitsleft = rjackpothits
lightseq1.Play Seqblinking, , 20,50
jackpotanim = true
ospeed = 77
oframestart =335
oframeend = 353
startoverlay()
jpscore = raidersjp
endtext = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64][f8][x60][yc]" & chr(59) & "[f7][x80][yc]" & formatscore(jpscore)
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", " "& formatscore(jpscore) , 2, 33023
addscore(jpscore)
modename = "rscene3"
resetrjackpot.set true ,4000
'light38.state = bulboff
sounddelay.set true,2500
tempsound = "jackpot2"
end sub
sub getrsuper3()

lightseq1.Play Seqblinking, , 20,50
jackpotanim = true
ospeed = 77
oframestart =354
oframeend = 399
startoverlay()
jpscore = raidersjp*5
endtext = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64][f8][x60][yc]" & chr(59) & "[f7][x80][yc]" & formatscore(jpscore)
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", " "& formatscore(jpscore) , 2, 33023
addscore(jpscore)
resetrjackpot.set true ,5000
sounddelay.set true,3500
tempsound = "superjackpot2"
modename = "rscene3"
rjackpothits = rjackpothits + 1
'light38.state = bulboff
rjackpothitsleft = rjackpothits
end sub

sub lightrsuper3()
'light38.state = bulbblink
modename = "rsuper3"
dispdmd1.text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x85][y7]HIT ARK FOR" & "[f5][x95][y25]SUPER" & "[f5][x90][y45]JACKPOT"
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", "HIT ARK FOR SUPER JACKPOT" , 2, 33023
end sub


sub lightjackpot4()
'light38.state = bulbblink
light36.state = 0
light37.state = 0
light39.state = 0
light50.state = 0
light51.state = 0
modename = "r4jackpot"
dispdmd1.text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x85][y7]HIT ARK FOR" & "[f5][x90][y45]JACKPOT"
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", "HIT ARK FOR JACKPOT" , 2, 33023
end sub


sub getr4jackpot()
lightseq1.Play Seqblinking, , 20,50
jackpotanim = true

rjackpothits = rjackpothits + 1

rjackpothitsleft = rjackpothits
select case(randomnumber(3))
case 1:
ospeed = 77
oframestart =307
oframeend = 334

case 2:
ospeed = 77
oframestart =335
oframeend = 353
case 3:
ospeed = 77
oframestart =275
oframeend = 306
end select
startoverlay()
jpscore = raidersjp
endtext = "" & score(currentplayer) & "" & lastscore &"" & chr(59) & "" & formatscore(jpscore)
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", " " , 2, 33023
addscore(jpscore)
modename = "rscene4"
resetrjackpot.set true ,4500
light36.state = 2
light37.state = 2
'light38.state = bulbblink
light39.state = 2
light50.state = 2
light51.state = 2

sounddelay.set true,2500
tempsound = "jackpot2"

end sub



sub startraidersfinal()
jackpotanim = false
lightseq1.play seqalloff
flushdmdtimer.set false
rjackpothits = 7
rjackpothitsleft = 7
magnet.dropped = false
magnet.render = false
'overlay1.fadein()
'Overlay1.Frame 73, 274,73
ospeed = 77
oframestart =73
oframeend = 274

scoreupdate = false
endtext  = "" & score(currentplayer) & "" & lastscore &"" & "" & chr(58) & "HIT ARK" & "FOR" & "JACKPOT"
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", "HIT ARK FOR JACKPOT" , 2, 33023

startoverlay()
'ball release
stopmusic 1
sounddelay.set true, 820
tempsound =  "raidersintro"
light23.state = 1
spellarkframe = 38
organhitsleft = 19
delayark.set true,16000
modename = "rfinal"
bMultiBallMode = True


end sub

sub rfinaljackpot()

lightseq1.Play Seqblinking, , 20,50

jpscore = raidersjp

rjackpothitsleft = rjackpothitsleft - 1
if rjackpothitsleft = 0 then
lightseq1.Play Seqblinking, , 20,50
jackpotanim = true
ospeed = 77
oframestart =354
oframeend = 399
startoverlay()
jpscore = raidersjp*5
endtext = "" & score(currentplayer) & "" & lastscore &"" & chr(59) & "" & formatscore(jpscore)
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", " " , 2, 33023
addscore(jpscore)
resetrjackpot.set true ,5000
sounddelay.set true,3500
tempsound = "superjackpot2"
modename = "rfinal"
resetrjackpot.set true ,4500

rjackpothits = rjackpothits + 1
'light38.state = bulboff
rjackpothitsleft = rjackpothits
exit sub
end if
'rjackpothitsleft = rjackpothits
if jackpotanim = false then
jackpotanim = true
select case(randomnumber(3))
case 1:
ospeed = 77
oframestart =307
oframeend = 334

case 2:
ospeed = 77
oframestart =335
oframeend = 353
case 3:
ospeed = 77
oframestart =275
oframeend = 306
end select

startoverlay()
end if

endtext = "" & score(currentplayer) & "" & lastscore &"" & chr(59) & "[f7][x80][yc]" & formatscore(jpscore)
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", " "& formatscore(jpscore) , 2, 33023
addscore(jpscore)
modename = "rfinal"
resetrjackpot.set true ,4500

'light38.state = bulbblink


sounddelay.set true,2500
tempsound = "jackpot2"
end sub


sub raidersbonus()
spellarkframe = 38
organhitsleft = 19
jpscore = raidersjp*5
if scoreupdate = true then
dispdmd1.text= "" & score(currentplayer) & "" & lastscore &"" & chr(59) & "" & formatscore(jpscore)
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", " "& formatscore(jpscore) , 2, 33023
flushdmdtimer.set true ,1500
end if
playsound "superjackpot2"

addscore(jpscore)
end sub

'*******************************************************
'STONE HIT
'*******************************************************

sub stonetarget_hit()
playsound "ballclick"
if modename <> "" then
exit sub
end if

if modename = "truffle" then
trufflehit
end if
if ballsinlock = 2 and modename <> "" then
exit sub
end if

traphitsleft = traphitsleft - 1
if scoreupdate = true and modename = "" then
scoreupdate = false
dispdmd1.text = " " & traphitsleft & " MORE" & " TO OPEN"
'pDMDSplashBig " " & traphitsleft & " MORE" & " TO OPEN", 2, 33023
flushdmdtimer.Interval = 1500
flushdmdtimer.Enabled = true ',1500
end if
if traphitsleft = 0 then
opencaptive()
traphitsleft = 2
scoreupdate = false
DispDmd1.Text = " TRAP" & " OPEN "
'pDMDSplashBig " TRAP" & " OPEN ", 2, 33023
flushdmdtimer.Interval = 1500
flushdmdtimer.Enabled = true ',1500
playsound "molarram"
end if
'end if
end sub



'sub Target20_hit()
'If HPos <= 0 Then
'if modename <> "" then
'exit sub
'end if

'if modename = "truffle" then
'trufflehit
'end if
'if ballsinlock = 2 and modename <> "" then
'exit sub
'end if

'traphitsleft = traphitsleft - 1
'if scoreupdate = true and modename = "" then
'scoreupdate = false
'dispdmd1.text = " " & traphitsleft & " MORE" & " TO OPEN"
'flushdmdtimer.Interval = 1500
'flushdmdtimer.Enabled = true ',1500
'end if
'if traphitsleft = 0 then
'opencaptive()
'traphitsleft = 2
'scoreupdate = false
'DispDmd1.Text = "TRAP" & " OPEN "
'flushdmdtimer.Interval = 1500
'flushdmdtimer.Enabled = true ',1500
'playsound "molarram"
'end if
'end if
'end sub

Sub kicker6_hit()
PlaySoundAt SoundFXDOF("fx_drain", 114, DOFPulse, DOFContactors), kicker6
kicker6.kick 10, 120
nevere2.state = 1
checknever
DispDmd1.Text = "BALL" & " TRAPPED "
'pDMDSplashBig "BALL TRAPPED ", 6, 33023
opencaptive()
templeopen = false
ballslocked = ballslocked + 1
PlaySong "mu_end"
if ballslocked = 1 then
playsound "lock1"
restartmusic.Interval = 8000
restartmusic.Enabled = true ', 8000
end if
if ballslocked = 2 then
playsound "lock2"
restartmusic.Interval = 8000
restartmusic.Enabled = true ', 8000
end if

if ballslocked = 3 then
startmultiball
neverr.state = 1
checknever
'vuk1.createball 255,255,159
 'vpmtimer.addtimer 1000, "Vuk1SolenoidPulse '"
Vuk1SolenoidPulse.Interval = 800
Vuk1SolenoidPulse.Enabled = True
else
locktrap.Interval = 2500
locktrap.Enabled = true ', 2500
end if
end sub

Sub kicker6_Unhit()
Playsound "subway2"
End Sub


sub startmultiball()
ballslocked = 0
ballsonplayfield = 3
modename = "trapmulti"
'stopmusic 1
PlaySong "mu_end"
delaymulti.Interval = 5000
delaymulti.Enabled = true ', 5000
scoreupdate = false
flushdmdtimer.Interval = 30000
flushdmdtimer.Enabled = true ', 30000
dispdmd1.text = " MULTIBALL "
'pDMDSplashBig "MULTIBALL", 6, 33023
'animation
playsound "lock3"
end sub

sub delaymulti_Timer()
light39.state = 2
light49.state = 2
light44.state = 2
delaymulti.Enabled = false
restartmusic.Interval = 500
restartmusic.Enabled = true ', 500
popup1.IsDropped = 1
Popup.TransY = -25
PlaySound "DiverterOn"
bmultiballmode = true

end sub

sub trapjp()

addscore(jackpotscore)
if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 2000
flushdmdtimer.Enabled = true' , 2000
dispdmd1.text = "JACKPOT"
'pDMDSplashBig "JACKPOT", 2, 33023
end if
end sub



sub locktrap_Timer()
popup1.IsDropped = 0
Popup.TransY = 0
PlaySound "DiverterOff"
'vuk1.createball 255,255,159
ballsonplayfield = ballsonplayfield - 1
'vuk1.createball 255,255,159
Vuk1SolenoidPulse.Interval = 800
Vuk1SolenoidPulse.Enabled = True
createnewball
locktrap.Enabled = false
autoball = true
vpmtimer.addtimer 3000, "TiraBolaAutomatico.Enabled = 1 '"
end sub

Sub TiraBolaAutomatico_Timer()
TiraBolaAutomatico.Enabled = 0
PlungerIM.AutoFire
End Sub

'sub collectstone()
'stonescollected = stonescollected + 1
'if stonescollected < 3 then
'playsound "preparetomeetcaleem"

'overlay1.fadein()
'overlay1.frame 782
'stonedisplaytimer.set true , 2000
'end if
'end sub

'sub stonedisplaytimer_expired()
'stonedisplaytimer.set false
''overlay1.fadeout()
'scoreupdate = false
'addscore(125000)
'dispdmd1.text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64][f8][x60][yc]" & chr(75) & "[f6][x110][y15]" & stonescollected & " OF 3[f6][x95][y30]COLLECTED"
'flushdmdtimer.set true ,2000
'end sub


sub starttemplescene()
if light24.state = 1 then
scoreupdate = true
templebonus()
exit sub
end if
stopmusic 1
stonescollected = 0
ospeed = 77
oframestart =401
oframeend = 639

scoreupdate = false

'endtext  = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(58) & "[f5][x95][y7]" & rjackpothitsleft & " MORE" & "[f5][x90][y25]SWITCHES" & "[f5][x80][y45]FOR JACKPOT"
if light24.state = 2 then
light24.state = 1
modename = "tfinal"
end if
if light8.state = 2 then
light8.state = 1
light24.state = 2
modename = "tscene4"
end if
if light7.state = 2 then
light7.state = 1
light8.state = 2
modename = "tscene3"
end if
if light6.state = 2 then
light6.state = 1
light7.state = 2
modename = "tscene2"
end if
if light5.state = 2 then
light5.state = 1
light6.state = 2
modename = "tscene1"
endtext  = "" & score(currentplayer) & "" & lastscore &"" & "" & chr(75) & "TEMPLE OF DOOM"  & "SHOOT FLASHING" & "ARROWS"
'pDMDSplashLines  "TEMPLE OF DOOM", "SHOOT FLASHING ARROWS" , 2, 33023
light36.state = 2
light37.state = 2
'light38.state = bulbblink
light39.state = 2
light50.state = 2
light51.state = 2
end if


starttemplescenedelay.set true , 21000
startoverlay()
bmultiballmode = true
end sub

sub starttemplescenedelay_Timer()
starttemplescenedelay.set false
kicker1.solenoidpulse()
playsound "fx_kicker"
restartmusic.set true, 500
createnewball()
'plunger.pull
threeballtimer.set true,1500
end sub


sub templebonus()
jpscore = templejp*5
if scoreupdate = true then
dispdmd1.text= "" & score(currentplayer) & "" & lastscore &"" & chr(59) & "" & formatscore(jpscore)
'pDMDSplashLines " "& score(currentplayer) & " " & lastscore &"" & "", " " & formatscore(jpscore) , 2, 33023

flushdmdtimer.set true ,1500
end if
playsound "superjackpot2"

addscore(jpscore)
end sub

'*******************************************************
'grail hit
'*******************************************************

sub kicker1_hit()
If Tilted Then
Kicker1Fake.enabled = 0
kicker1timer2.Interval = 500
kicker1timer2.Enabled =  true ', 1800
Else
Kicker1Fake.enabled = 0
PlaySoundAt SoundFXDOF("scoopenter", 114, DOFPulse, DOFContactors), kicker1
if light41.state = 2  and modename = "" then
startmystery()
light41.state = 0
exit sub
end if
kicker1timer.Interval = 1500
kicker1timer.Enabled = true ', 1500
'grailhit = grailhit + 1
addscore(10000)
kicker1timer2.Interval = 1800
kicker1timer2.Enabled =  true ', 1800
end if
end sub

sub kicker1timer_Timer()
kicker1timer2.Enabled =  false
kicker1solenoidpulse()
playsound "fx_kicker"
kicker1timer.Enabled =  false
end sub

sub kicker1timer2_Timer()
kicker1timer2.Enabled =  false
kicker1solenoidpulse()
playsound "fx_kicker"
kicker1timer.Enabled =  false
end sub
sub resettempledisplay_Timer()
'resettempledisplay.Enabled =  false
end sub



Sub kicker1solenoidpulse()
    PlaySound "salidadebola"
    Kicker1.Kick 0, 30, 1.5
    Kicker1FakeTimer.interval = 800
    Kicker1FakeTimer.enabled = True
End Sub

Sub Kicker1FakeTimer_Timer
    Kicker1FakeTimer.enabled = False
    Kicker1Fake.enabled = 1
End Sub   

'*******************************************************
'skull ramp
'*******************************************************
sub trigger7_hit()
'playsound "fx_PlasticRamp"
if modename = "wizard" then
wizardjp
exit sub
end if
if modename = "water" then
waterjp
exit sub
end if
if modename = "trapmulti" then
trapjp
exit sub
end if

if comboon = false then
comboon = true
combotimer.Interval = 8000
combotimer.Enabled = true ', 8000
else
addcombo
combotimer.Interval = 8000
combotimer.Enabled = true ', 8000
end if

if light49.state = 2 then
addscore(jackpotscore)
playsound "chunkamazing"
light39.state = 0
light49.state = 0
light44.state = 0
end if
addscore(5000)
rampshots = rampshots + 1
if rampshots = 10 then
light1.state = 2
end if

if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 1500
flushdmdtimer.Enabled = true ', 1500
if rampshots = 1 then
dispdmd1.text = "[edge4][x20][y5][f6]" & rampshots & " RAMP" & "[f9][xc][yc]" & chr(33) & "[f1][x15][y19]9 MORE TO[x2][y25]LIGHT EXTRA BALL"
'pDMDSplashLines " " & rampshots & " RAMP MORE TO", "LIGHT EXTRA BALL", 2, 33023
exit sub
end if
if rampshots > 1 and rampshots < 10 then

dispdmd1.text = "[edge4][x20][y5][f6]" & rampshots & " RAMPS" & "[f9][xc][yc]" & chr(33) & "[f1][x15][y19]" & (10 - rampshots) & " MORE TO[x2][y25]LIGHT EXTRA BALL"
'pDMDSplashLines " " & rampshots & " RAMPS"& (10 - rampshots)&" MORE TO", "LIGHT EXTRA BALL", 2, 33023
exit sub
end if
if rampshots = 10 then
dispdmd1.text = "[edge4][x20][y5][f6]" & rampshots & " RAMP" & "[f9][xc][yc]" & chr(33) & "[f1][x18][y19]GET THE[x15][y25]EXTRA BALL"
'pDMDSplashLines " " & rampshots & " RAMP GET THE", "LIGHT EXTRA BALL", 2, 33023
light1.state = 2
exit sub
end if

dispdmd1.text = "[edge4][x20][y5][f6]" & rampshots & " RAMP" & "[f9][xc][yc]" & chr(33) & "[f1][x20][y23]10,000"
'pDMDSplashBig " " & rampshots & " RAMP ", 2, 33023
addscore(5000)

'if rampshots = rampshotsleft then
'startskullscene()
'end if

end if



'if hitskull = true then
'skullhit = skullhit +1
'resetskull.set true,1500
addscore(20000)
'else
'exit sub
'end if


'hitskull = false

end sub

Sub Trigger002_Hit
   StopSound "fx_PlasticRamp"
End Sub

Sub Trigger001_Hit
  StopSound "fx_PlasticRamp"
  Playsound "fx_RampPlasticHit2"
End Sub

sub startskullscene()
rampshots = 0
rampshotsleft = rampshotsleft + 1
end sub

sub resetskull_Timer()
resetskull.set false
hitskull = true
end sub



'*******************************************************
'DATA Targets
'*******************************************************

sub target6_hit()

Select case (RandomNumber(2))
case 1: PlaySoundAt SoundFXDOF("boing4", 103, DOFPulse, DOFContactors), Target6
case 2: PlaySoundAt SoundFXDOF("boing6", 103, DOFPulse, DOFContactors), Target6
end select
if modename = "truffle" then
trufflehit
exit sub
end if

if modename <> "" then
exit sub
end if
'if modename = "rscene1" or modename = "rscene2" or modename = "rscene3" then
'raidershit()
'exit sub
'end if
'if light27.state = bulbon and indyscoring = true then
'indyhit()
'exit sub
'end if
'if light28.state = bulbon and indyscoring = true then
'indyhit2()
'exit sub
'end if
'if light29.state = bulbon and indyscoring = true then
'indyhit3()
'exit sub
'end if

if light27.state = 2 then
light27.state = 1
addscore(5000)

'if scoreupdate = true then
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(60) & indyi & indyn & indyd & indyy & "[f1][x65][y57]COMPLETE FOR INDY SCORING"
'scoreupdate = false
'flushdmdtimer.set true ,2000
'end if
dataD = "D"' & chr(46)
checkdata
else
addscore(1000)
end if

end sub

sub target7_hit()

Select case (RandomNumber(2))
case 1: PlaySoundAt SoundFXDOF("boing4", 103, DOFPulse, DOFContactors), Target7
case 2: PlaySoundAt SoundFXDOF("boing6", 103, DOFPulse, DOFContactors), Target7
end select

if modename = "truffle" then
trufflehit
exit sub
end if

if modename <> "" then
exit sub
end if
'if modename = "rscene1" or modename = "rscene2" or modename = "rscene3" then
'raidershit()
'exit sub
'end if
'if light28.state = bulbon and indyscoring = true then
'indyhit()
'exit sub
'end if
'if light29.state = bulbon and indyscoring = true then
'indyhit2()
'exit sub
'end if
'if light30.state = bulbon and indyscoring = true then
'indyhit3()
'exit sub
'end if


if light28.state = 2 then
light28.state = 1
'indyN = "[f8][yc][x60]" & chr(62)

dataA = "A"' & chr(47)
addscore(5000)

'if scoreupdate = true then
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(60) & indyi & indyn & indyd & indyy & "[f1][x65][y57]COMPLETE FOR INDY SCORING"
'scoreupdate = false
'flushdmdtimer.set true ,2000
'end if
checkdata
else
addscore(1000)
end if
end sub

sub target8_hit()

Select case (RandomNumber(2))
case 1: PlaySoundAt SoundFXDOF("boing4", 103, DOFPulse, DOFContactors), Target8
case 2: PlaySoundAt SoundFXDOF("boing6", 103, DOFPulse, DOFContactors), Target8
end select
if modename = "truffle" then
trufflehit
exit sub
end if

if modename <> "" then
exit sub
end if
'if modename = "rscene1" or modename = "rscene2" or modename = "rscene3" then
'raidershit()
'exit sub
'end if
'if light29.state = bulbon and indyscoring = true then
'indyhit()
'exit sub
'end if

'if light30.state = bulbon and indyscoring = true then
'indyhit2()
'exit sub
'end if
'if light27.state = bulbon and indyscoring = true then
'indyhit3()
'exit sub
'end if

if light29.state = 2 then
light29.state = 1
'indyD = "[f8][yc][x60]" & chr(63)
addscore(5000)

'if scoreupdate = true then
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(60) & indyi & indyn & indyd & indyy & "[f1][x65][y57]COMPLETE FOR INDY SCORING"
'scoreupdate = false
'flushdmdtimer.set true ,2000
'end if
dataT = "T"' & chr(48)
checkdata
else
addscore(1000)
end if
end sub

sub target9_hit()

Select case (RandomNumber(2))
case 1: PlaySoundAt SoundFXDOF("boing4", 103, DOFPulse, DOFContactors), Target9
case 2: PlaySoundAt SoundFXDOF("boing6", 103, DOFPulse, DOFContactors), Target9
end select
if modename = "truffle" then
trufflehit
exit sub
end if

if modename <> "" then
exit sub
end if
'if modename = "rscene1" or modename = "rscene2" or modename = "rscene3" then
'raidershit()
'exit sub
'end if
'if light30.state = bulbon and indyscoring = true then
'indyhit()
'exit sub
'end if
'if light27.state = bulbon and indyscoring = true then
'indyhit2()
'exit sub
'end if
'if light28.state = bulbon and indyscoring = true then
'indyhit3()
'exit sub
'end if
if light30.state = 2 then
light30.state = 1
'indyY = "[f8][yc][x60]" & chr(64)
addscore(5000)
'if scoreupdate = true then
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(60) & indyi & indyn & indyd & indyy & "[f1][x65][y57]COMPLETE FOR INDY SCORING"
'scoreupdate = false
'flushdmdtimer.set true ,2000
'end if
dataA2 = "A"' & chr(49)
checkdata
else
addscore(1000)
end if
end sub

'********************************************************************************
'Sloth 2x scoring
'*******************************************************************************

sub target1_hit()
Select case (RandomNumber(4))
case 1: PlaySoundAt SoundFXDOF("sloth_laugh1", 103, DOFPulse, DOFContactors), Target1
case 2: PlaySoundAt SoundFXDOF("sloth_laugh2", 103, DOFPulse, DOFContactors), Target1
case 3: PlaySoundAt SoundFXDOF("sloth_laugh3", 103, DOFPulse, DOFContactors), Target1
case 4: PlaySoundAt SoundFXDOF("slothsloth", 103, DOFPulse, DOFContactors), Target1
end select
playsound "fx14"
if modename = "truffle" then
trufflehit
exit sub
end if

'if modename <> "" then
'exit sub
'end if
'if modename = "rscene1" or modename = "rscene2" or modename = "rscene3" then
'raidershit()
'exit sub
'end if
'if light31.state = bulbon and jonesscoring = true then
'joneshit()
'exit sub
'end if
'if light32.state = bulbon and jonesscoring = true then
'joneshit2()
'exit sub
'end if
'if light33.state = bulbon and jonesscoring = true then
'joneshit3()
'exit sub
'end if



if light31.state = 2 then
light31.state = 1
'JonesJ = "[f8][yc][x60]" & chr(66)

slothS = "S"' & chr(50)
addscore(5000)
'if scoreupdate = true then
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(65) & jonesJ & JonesO & jonesN & JonesE & JonesS & "[f1][x65][y57]COMPLETE FOR JONES SCORING"
'scoreupdate = false
'flushdmdtimer.set true ,2000
'end if
checksloth()
else
addscore(1000)
end if
end sub

sub target2_hit()
Select case (RandomNumber(4))
case 1: PlaySoundAt SoundFXDOF("sloth_laugh1", 103, DOFPulse, DOFContactors), Target2
case 2: PlaySoundAt SoundFXDOF("sloth_laugh2", 103, DOFPulse, DOFContactors), Target2
case 3: PlaySoundAt SoundFXDOF("sloth_laugh3", 103, DOFPulse, DOFContactors), Target2
case 4: PlaySoundAt SoundFXDOF("slothsloth", 103, DOFPulse, DOFContactors), Target2
end select
playsound "fx14"
if modename = "truffle" then
trufflehit
exit sub
end if

'if modename <> "" then
'exit sub
'end if
'if modename = "rscene1" or modename = "rscene2" or modename = "rscene3" then
'raidershit()
'exit sub
'end if
'if light32.state = bulbon and jonesscoring = true then
'joneshit()
'exit sub
'end if
'if light33.state = bulbon and jonesscoring = true then
'joneshit2()
'exit sub
'end if
'if light34.state = bulbon and jonesscoring = true then
'joneshit3()
'exit sub
'end if

if light32.state = 2 then
light32.state = 1
'JonesO = "[f8][yc][x60]" & chr(67)
addscore(5000)
'if scoreupdate = true then
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(65) & jonesJ & JonesO & jonesN & JonesE & JonesS & "[f1][x65][y57]COMPLETE FOR JONES SCORING"
'scoreupdate = false
'flushdmdtimer.set true ,2000
'end if
slothL = "L"' & chr(51)
checksloth()
else
addscore(1000)
end if
end sub


sub target3_hit()


Select case (RandomNumber(4))
case 1: PlaySoundAt SoundFXDOF("sloth_laugh1", 103, DOFPulse, DOFContactors), Target3
case 2: PlaySoundAt SoundFXDOF("sloth_laugh2", 103, DOFPulse, DOFContactors), Target3
case 3: PlaySoundAt SoundFXDOF("sloth_laugh3", 103, DOFPulse, DOFContactors), Target3
case 4: PlaySoundAt SoundFXDOF("slothsloth", 103, DOFPulse, DOFContactors), Target3
end select


playsound "fx14"
if modename = "truffle" then
trufflehit
exit sub
end if

'if modename <> "" then
'exit sub
'end if
'if modename = "rscene1" or modename = "rscene2" or modename = "rscene3" then
'raidershit()
'exit sub
'end if
'if light33.state = bulbon and jonesscoring = true then
'joneshit()
'exit sub
'end if
'if light34.state = bulbon and jonesscoring = true then
'joneshit2()
'exit sub
'end if
'if light35.state = bulbon and jonesscoring = true then
'oneshit3()
'exit sub
'end if

if light33.state = 2 then
light33.state = 1
'JonesN = "[f8][yc][x60]" & chr(68)
addscore(5000)
'if scoreupdate = true then
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(65) & jonesJ & JonesO & jonesN & JonesE & JonesS & "[f1][x65][y57]COMPLETE FOR JONES SCORING"
'scoreupdate = false
'flushdmdtimer.set true ,2000
'end if
slothO = "O"' & chr(52)
checksloth()

else
addscore(1000)
end if
end sub


sub target4_hit()
Select case (RandomNumber(4))
case 1: PlaySoundAt SoundFXDOF("sloth_laugh1", 103, DOFPulse, DOFContactors), Target4
case 2: PlaySoundAt SoundFXDOF("sloth_laugh2", 103, DOFPulse, DOFContactors), Target4
case 3: PlaySoundAt SoundFXDOF("sloth_laugh3", 103, DOFPulse, DOFContactors), Target4
case 4: PlaySoundAt SoundFXDOF("slothsloth", 103, DOFPulse, DOFContactors), Target4
end select

playsound "fx14"
if modename = "truffle" then
trufflehit
exit sub
end if

'if modename <> "" then
'exit sub
'end if
'if modename = "rscene1" or modename = "rscene2" or modename = "rscene3" then
'raidershit()
'exit sub
'end if

'if light34.state = bulbon and jonesscoring = true then
'joneshit()
'exit sub
'end if
'if light35.state = bulbon and jonesscoring = true then
'joneshit2()
'exit sub
'end if
'if light31.state = bulbon and jonesscoring = true then
'joneshit3()
'exit sub
'end if

if light34.state = 2 then
light34.state = 1
'JonesE = "[f8][yc][x60]" & chr(69)
addscore(5000)
'if scoreupdate = true then
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(65) & jonesJ & JonesO & jonesN & JonesE & JonesS & "[f1][x65][y57]COMPLETE FOR JONES SCORING"
'scoreupdate = false
'flushdmdtimer.set true ,2000
'end if
slothT = "T"' & chr(53)
checksloth()
else
addscore(1000)
end if

end sub


sub target5_hit()
Select case (RandomNumber(4))
case 1: PlaySoundAt SoundFXDOF("sloth_laugh1", 103, DOFPulse, DOFContactors), Target5
case 2: PlaySoundAt SoundFXDOF("sloth_laugh2", 103, DOFPulse, DOFContactors), Target5
case 3: PlaySoundAt SoundFXDOF("sloth_laugh3", 103, DOFPulse, DOFContactors), Target5
case 4: PlaySoundAt SoundFXDOF("slothsloth", 103, DOFPulse, DOFContactors), Target5
end select

playsound "fx14"
if modename = "truffle" then
trufflehit
exit sub
end if

'if modename <> "" then
'exit sub
'end if
'if modename = "rscene1" or modename = "rscene2" or modename = "rscene3" then
'raidershit()
'exit sub
'end if
'if light35.state = bulbon and jonesscoring = true then
'joneshit()
'exit sub
'end if
'if light31.state = bulbon and jonesscoring = true then
'joneshit2()
'exit sub
'end if
'if light32.state = bulbon and jonesscoring = true then
'joneshit3()
'exit sub
'end if
if light35.state = 2 then
light35.state = 1
'JonesS = "[f8][yc][x60]" & chr(70)
addscore(5000)
'if scoreupdate = true then
'DispDmd1.Text = "[f1][x0] [y0]" & nvscore(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f8][x60][yc]" & chr(65) & jonesJ & JonesO & jonesN & JonesE & JonesS & "[f1][x65][y57]COMPLETE FOR JONES SCORING"
'scoreupdate = false
'flushdmdtimer.set true ,2000
'end if
slothH = "H"' & chr(54)
checksloth()

else
addscore(1000)
end if
end sub


sub checkdata()
if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 1500
flushdmdtimer.Enabled = true ', 1500
dispdmd1.text = dataD & dataA & DataT & dataA2
'pDMDSplashBig " " & dataD & dataA & DataT & dataA2, 2, 33023
end if

if light27.state = 1 and light28.state = 1 and light29.state = 1 and light30.state = 1 then
startindy()
exit sub

end if

if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 1500
flushdmdtimer.Enabled = true ', 1500
dispdmd1.text = dataD & dataA & DataT & dataA2
'pDMDSplashBig " " & dataD & dataA & DataT & dataA2, 2, 33023
end if
end sub



sub checksloth()
if light31.state = 1 and light32.state = 1 and light33.state = 1 and light34.state = 1 and light35.state = 1 then
startsloth()
end if


if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 1500
flushdmdtimer.Enabled = true ', 1500
dispdmd1.text = slothS & slothL & slothO & slothT & slothH
'pDMDSplashBig " " & slothS & slothL & slothO & slothT & slothH, 2, 33023
end if
end sub


sub startindy()
playsound "unknownnotneeded10"
light41.state = 2
if modename = "" then
restartmusic.Enabled = true ', 100
end if
scoreupdate = false
flushdmdtimer.Interval = 2000
flushdmdtimer.Enabled = true ', 2000

lightseq1.Play Seqblinking, , 5,50
DispDmd1.Text = "[x2][y1][f5]DATA GADGET" & "[xc][y15][f6]LIT" & "[f9][xc][yc]"' & chr(36)
'pDMDSplashBig "DATA GADGET LIT", 2, 33023
light54.state = 0
light27.state = 1
light28.state = 1
light29.state = 1
light30.state = 1
end sub


sub indylightstimer_Timer()
if light30.state = 1 then
light30.state = 0
light27.state = 1
exit sub
end if
if light29.state = 1 then
light30.state = 1
light29.state = 0
exit sub
end if
if light28.state = 1 then
light29.state = 1
light28.state = 0
exit sub
end if
if light27.state = 1 then
light28.state = 1
light27.state = 0
exit sub
end if
end sub



sub indyscoringtimer_Timer()

'flushdmdtimer.set true , 1500

' show number of indy hits left.
indyhitsleft = indyhitsleft + 1
if modename = "" then
DispDmd1.Text = " " & score(currentplayer) & " " & lastscore &" " & " " & chr(60) &" " & chr(61) &" " & chr(62) &" " & chr(63) &" " & chr(64) & "SUPER SCORE #" & indyhitsleft & " OF 6"
'pDMDSplashLines " "& score(currentplayer) & "" & lastscore &"" & "", "SUPER SCORE #" & indyhitsleft & " OF 6", 2, 33023
end if
indyscoringtimer.Enabled = false
if indyhitsleft = 6 then
endindy()
if modename = "" then
DispDmd1.Text = "" & score(currentplayer) & "" & lastscore &"" & "" & chr(60) &"" & chr(61) &"" & chr(62) &"" & chr(63) &"" & chr(64) & "BONUS " & formatscore(2000000)
'pDMDSplashLines "BONUS", " " & formatscore(2000000), 3, 33023
end if
addscore(2000000)
end if

end sub

sub endindy()
'indyscoringtimer.set false
indylightstimer.Enabled = false

indyscoring = false
light27.state = 2
light28.state = 2
light29.state = 2
light30.state = 2
indyI = "[f1] "
indyN = "[f1] "
indyD = "[f1] "
indyY = "[f1] "
indyhitsleft = 0
end sub

sub indyhit()

lightseq1.Play Seqblinking, , 2,50
addscore(750000)
if modename = "" then
DispDmd1.Text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f7][x90][yc]" & formatscore(750000)
'pDMDSplashLines  " ", " " & formatscore(750000), 2, 33023
scoreupdate = false

indyscoringtimer.Interval = 2000
indyscoringtimer.Enabled = true', 2000
flushdmdtimer.Interval = 3500
flushdmdtimer.Enabled = true ', 3500
end if
end sub
sub indyhit2()

lightseq1.Play Seqblinking, , 2,50
addscore(650000)
if modename = "" then
DispDmd1.Text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f7][x90][yc]" & formatscore(750000)
'pDMDSplashLines  " ", " " & formatscore(750000), 2, 33023
scoreupdate = false

indyscoringtimer.Interval = 2000
indyscoringtimer.Enabled = true', 2000
flushdmdtimer.Interval = 3500
flushdmdtimer.Enabled = true' , 3500
end if
end sub
sub indyhit3()

lightseq1.Play Seqblinking, , 2,50
addscore(500000)
if modename = "" then
DispDmd1.Text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f7][x90][yc]" & formatscore(750000)
'pDMDSplashLines  " ", " " & formatscore(750000), 2, 33023
scoreupdate = false

indyscoringtimer.Interval = 2000
indyscoringtimer.Enabled = true', 2000
flushdmdtimer.Interval = 3500
flushdmdtimer.Enabled = true ', 3500
end if
end sub




sub startsloth()
nevern.state = 1:NeverNP.visible = 1
checknever
playsound "slothhey"
slothmulti = 2
flushdmdtimer.Interval = 30000
flushdmdtimer.Enabled = true ', 30000
if modename = "" then
'modename = "sloth"
PlaySong "mu_end"
restartmusic.Enabled = true' , 100
DispDmd1.Text = "[f4][x10][y0]SLOTH" & "[f4][y18][x0]2X SCORING" & "[f9][xc][yc]" & chr(42)
'pDMDSplashBig "SLOTH X2 SCORING", 2, 33023
scoreupdate = false
flushdmdtimer.Interval = 2000
flushdmdtimer.Enabled = true ', 2000
end if
'jonesscoring = true
light38.state = 2
light31.state = 1
light32.state = 1
light33.state = 1
light34.state = 1
light35.state = 1
'joneslightstimer.set true,500
'indyscoringtimer.set true,20000
end sub

sub slothtimer_Timer()
endsloth
playsound "slothrockyroad"
if modename = "" then
PlaySong "mu_end"
restartmusic.Enabled = true ', 50
end if
end sub





sub endsloth()
'indyscoringtimer.set false


slothS = "S"
slothL = "L"
slothO = "O"
slothT = "T"
slothH = "H"

slothtimer.Enabled = false
slothmulti = 2 = false
light31.state = 2
light32.state = 2
light33.state = 2
light34.state = 2
light35.state = 2
light38.state = 0

end sub

sub joneshit()

lightseq1.Play Seqblinking, , 2,50
addscore(750000)
if modename = "" then
DispDmd1.Text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f7][x90][yc]" & formatscore(750000)
'pDMDSplashLines " ", " " & formatscore(750000), 2, 33023
scoreupdate = false

'jonesscoringtimer.Enabled = true', 2000
flushdmdtimer.Interval = 3500
flushdmdtimer.Enabled = true ', 3500
end if

end sub
sub joneshit2()

lightseq1.Play Seqblinking, , 2,50
addscore(650000)
if modename = "" then
DispDmd1.Text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f7][x90][yc]" & formatscore(750000)
'pDMDSplashLines " ", " " & formatscore(750000), 2, 33023
scoreupdate = false

'jonesscoringtimer.Enabled = true, 2000
flushdmdtimer.Interval = 3500
flushdmdtimer.Enabled = true ', 3500
end if
end sub
sub joneshit3()

lightseq1.Play Seqblinking, , 2,50
addscore(500000)
if modename = "" then
DispDmd1.Text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f7][x90][yc]" & formatscore(750000)
'pDMDSplashLines " ", " " & formatscore(750000), 2, 33023
scoreupdate = false

'jonesscoringtimer.Enabled = true, 2000
flushdmdtimer.Interval = 3500
flushdmdtimer.Enabled = true ', 3500
end if
end sub


'**********************************************************************************
'Bumpers
'**********************************************************************************
sub bumper2_hit() ' raiders
PlaySoundAt SoundFXDOF("bumper2", 109, DOFPulse, DOFContactors), ActiveBall
DOF 110, DOFPulse
If Tilted Then Exit Sub
'playsound "gunshot6"
if bumper2l.state = 2 then
addscore(25000)
else
addscore(1000)
end if
if modename = "rscene1" or modename = "rscene2" then
raidershit()
exit sub
end if
resetbumpers.Interval = 10000
resetbumpers.Enabled = true', 10000



end sub

sub bumper1_hit() ' temple
PlaySoundAt SoundFXDOF("Bumper1", 107, DOFPulse, DOFContactors), ActiveBall
DOF 110, DOFPulse
If Tilted Then Exit Sub
'playsound "gunshot6"
if bumper1l.state = 2 then
addscore(25000)
else
addscore(1000)
end if
if modename = "rscene1" or modename = "rscene2" then
raidershit()
exit sub
end if
resetbumpers.Interval = 10000
resetbumpers.Enabled = true', 10000


end sub

sub bumper4_hit() 'crusade
PlaySoundAt SoundFXDOF("fx_bumper", 110, DOFPulse, DOFContactors), ActiveBall
DOF 110, DOFPulse
If Tilted Then Exit Sub
'playsound "gunshot6"
if bumper4l.state = 2 then
addscore(25000)
else
addscore(1000)
end if
if modename = "rscene1" or modename = "rscene2" then
raidershit()
exit sub
end if
resetbumpers.Interval = 10000
resetbumpers.Enabled = true', 10000


resetbumperscore.Enabled = true',200


end sub

sub bumper3_hit() 'crystal
PlaySoundAt SoundFXDOF("Bumper3", 108, DOFPulse, DOFContactors), ActiveBall
DOF 110, DOFPulse
If Tilted Then Exit Sub
'playsound "gunshot6"
if bumper3l.state = 2 then
addscore(25000)
else
addscore(1000)
end if
if modename = "rscene1" or modename = "rscene2" then
raidershit()
exit sub
end if
resetbumpers.Interval = 10000
resetbumpers.Enabled = true', 10000



resetbumperscore.Enabled = true',200

end sub

sub resetbumpers_Timer()
resetbumpers.Enabled = false
bumper1l.state = 0
bumper2l.state = 0
bumper3l.state = 0
bumper4l.state = 0
end sub
sub resetbumperscore_Timer()
resetbumperscore.Enabled = false
end sub
'*********************************************************************************
'map room
'*********************************************************************************
sub target17_hit()
PlaySoundAt SoundFXDOF("fx3", 103, DOFPulse, DOFContactors), Target17
If Tilted Then Exit Sub
if modename = "truffle" then
trufflehit
end if
'if modename = "rscene1" or modename = "rscene2" then
'raidershit()
'exit sub
'end if
if light20.state = 0 or light20.state = 2 then
light20.state = 1
addscore(5000)
checkfrat()
else
addscore(1000)
end if

end sub
sub target18_hit()
PlaySoundAt SoundFXDOF("fx3", 103, DOFPulse, DOFContactors), Target17
If Tilted Then Exit Sub
if modename = "truffle" then
trufflehit
end if
'if modename = "rscene1" or modename = "rscene2" then
'raidershit()
'exit sub
'end if
if light21.state = 0 or light21.state = 2 then
light21.state = 1
addscore(5000)
checkfrat()
else
addscore(1000)
end if

end sub
sub target19_hit()
PlaySoundAt SoundFXDOF("fx3", 103, DOFPulse, DOFContactors), Target17
If Tilted Then Exit Sub
if modename = "truffle" then
trufflehit
end if
'if modename = "rscene1" or modename = "rscene2" then
'raidershit()
'exit sub
'end if
if light22.state = 0 or light22.state = 2 then
light22.state = 1
addscore(5000)
checkfrat()
else
addscore(1000)
end if

end sub
sub checkfrat()
if light20.state = 1 and light21.state = 1 and light22.state = 1 then

if modename = "fight" then

light20.state = 2
light21.state = 2
light22.state = 2
fighthit
exit sub
end if

jackpotscore = jackpotscore + 250000

Select case (RandomNumber(3))
case 1: playsound "frat1"
case 2:  playsound "frat2"
case 3:  playsound "frat3"
end select

if jackpotscore > 10000000 then
jackpotscore = 10000000
end if
lightseq1.Play Seqblinking, , 3,50
if scoreupdate = true and jackpotscore < 10000000 then
DispDmd1.Text = "[edge4][f5][xc][y3]JACKPOT GROWS" & "[f4][xc][y18]" & formatscore(jackpotscore)
'pDMDSplashLines "JACKPOT GROWS", " " & formatscore(jackpotscore), 2, 33023

scoreupdate = false
flushdmdtimer.Interval = 2000
flushdmdtimer.Enabled = true ', 2000
end if
if jackpotscore = 10000000 and scoreupdate = true then

DispDmd1.Text = "[edge4][f5][xc][y3]JACKPOT AT MAX" & "[f4][xc][y18]" & formatscore(jackpotscore)
'pDMDSplashLines "JACKPOT AT MAX", " " & formatscore(jackpotscore), 2, 33023

scoreupdate = false
flushdmdtimer.Interval = 2000
flushdmdtimer.Enabled = true ', 2000
playsound "jingle15"
end if
'light20.flashforms 2000, , bulboff
FlashForMs light20, 2000, 50, 0
'light21.flashforms 2000, , bulboff
FlashForMs light21, 2000, 50, 0
'light22.flashforms 2000, , bulboff
FlashForMs light22, 2000, 50, 0
addscore(10000)
end if
 end sub

sub kicker2_hit()
'if flasher1.state = bulboff then

'end if

if modename = "sword" then
swordsmanhit()
exit sub
end if



addscore(10000)
kicker2.Kick 215, 15
playsound "fx_kicker"
end sub


sub resetxmarks_Timer()
resetxmarks.set false
xmarks = 1
xmarkshits = 3
'flasher1.state = bulboff
'flasher1b.state = bulboff

end sub



'*******************************************************************************
'loops
'*******************************************************************************
sub trigger3_hit()
If Tilted Then Exit Sub
loopd = ""
playsound "fx_sensor"
addscore(1000)
if modename = "rscene1" or modename = "rscene2" then
raidershit()
exit sub
end if
end sub

sub trigger4_hit()
If Tilted Then Exit Sub
if loopd = "r" then
'right loop hit "MIKEY"

if comboon = false then
comboon = true
combotimer.Interval = 8000
combotimer.Enabled = true' , 8000
else
addcombo
combotimer.Interval = 8000
combotimer.Enabled = true' , 8000
end if
if modename = "wizard" then
wizardjp
exit sub
end if
if modename = "boulder" then
boulderjp
exit sub
end if

addmarble
end if


addscore(1000)
loopd = "l"
end sub

sub trigger2_hit()

playsound "fx_sensor"
if loopd = "l" then
if comboon = false then
comboon = true
combotimer.Interval = 8000
combotimer.Enabled = true' , 8000
else
addcombo
combotimer.Interval = 8000
combotimer.Enabled = true' , 8000
end if
if modename = "wizard" then
wizardjp
exit sub
end if
if modename = "boulder" then
boulderjp
exit sub
end if
addchunk
end if

addscore(1000)
loopd = "r"
end sub

sub trigger1_hit()
loopd = ""
if modename = "rscene1" or modename = "rscene2" then
raidershit()
exit sub
end if
addscore(1000)
end sub


sub addchunk()
'disp
if modename = "truffle" then
trufflejackpot
exit sub
end if

if modename <> "" then
exit sub
end if
if light51.state = 2 then
light51.state = 1
light36.state = 2
playsound "truf1"
exit sub
end if
if light36.state = 2 then
light36.state = 1
light45.state = 2
playsound "truf2"
exit sub
end if
if light45.state = 2 then
light45.state = 1
light23.state = 2
playsound "truf3"
exit sub
end if
if light23.state = 2 then
light23.state = 1
light24.state = 2
playsound "truf4"
exit sub
end if
if light24.state = 2 then
light24.state = 1
light25.state = 2
playsound "truf5"
exit sub
end if

if light25.state = 2 then
light25.state = 1
starttruffle
exit sub
end if
end sub

sub starttruffle()
modename = "truffle"
playsound "truf6"
nevers.state = 1
PlaySong "mu_end"
restartmusic.Interval = 500
restartmusic.Enabled = true ', 500
trufflechrtimer.Interval = 300
trufflechrtimer.Enabled = true ', 300
'sound of chunk
light51.state = 2
light36.state = 2
light45.state = 2
light23.state = 2
light24.state = 2
light25.state = 2
truffletimer.Interval = 30000
truffletimer.Enabled = true ', 30000
if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 2000
flushdmdtimer.Enabled = true ', 1000
dispdmd1.text = "TRUFFLE SHUFFLE" & "ALL TARGETS" & "WORTH 50,000"
'pDMDSplash3Lines "TRUFFLE SHUFFLE", "ALL TARGETS WORTH", "50,000", 2, 33023
end if
end sub
sub endtruffle()
trufflechrtimer.Enabled = false
'chunk sound
truffletimer.Enabled = false
light51.state = 2
light36.state = 0
light45.state = 0
light23.state = 0
light24.state = 0
light25.state = 0
end sub

sub trufflehit()
addscore(50000)
'animation
'sound

end sub

sub trufflejackpot()
addscore(jackpotscore)
playsound "trufhit"
'disp
'sound
end sub
sub truffletimer_Timer()
endtruffle
modename = ""
restartmusic.Interval = 500
restartmusic.Enabled = true ', 500
addscore(0)
end sub

sub trufflechrtimer_Timer()
if tchr = 34 then
tchr = 35
else
tchr = 34
end if

DispDmd1.Text = "[f2][x5][y12]" & formatscore(score(currentplayer)) & "[f2][x2][y0]TRUFFLE SHUFFLE" & "[f1][x2][y25]TARGETS WORTH 50,000" & "[f9][xc][yc]" & chr(tchr) & "[f1] "
'pDMDSplash3Lines "TRUFFLE SHUFFLE", "ALL TARGETS WORTH", "50,000"& chr(tchr), 2, 33023
end sub

'----------------------------------
sub addmarble()
if modename <> "" then
exit sub
end if

'disp
if light50.state = 2 then
light50.state = 1
light40.state = 2
marbles = marbles + 1000
if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 1000
flushdmdtimer.Enabled = true ', 1000
dispdmd1.text = "MARBLE BONUS" & "" & formatscore(marbles) & "" & chr(39)
'pDMDSplashLines "MARBLE BONUS", " "& formatscore(marbles), 3, 33023
end if
exit sub
end if
if light40.state = 2 then
light40.state = 1
light26.state = 2
marbles = marbles + 2000
if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 1000
flushdmdtimer.Enabled = true ', 1000
dispdmd1.text = "MARBLE BONUS" & "[f4][xc][y18]" & formatscore(marbles) & " " & chr(39)
'pDMDSplashLines "MARBLE BONUS", " "& formatscore(marbles), 3, 33023
end if
exit sub
end if
if light26.state = 2 then
light26.state = 1
light37.state = 2
marbles = marbles + 3000
if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 1000
flushdmdtimer.Enabled = true ', 1000
dispdmd1.text = "MARBLE BONUS" & "" & formatscore(marbles) & " " & chr(39)
'pDMDSplashLines "MARBLE BONUS", " "& formatscore(marbles), 3, 33023
end if
exit sub
end if
if light37.state = 2 then
playsound "marble_bag"
end if
if light37.state = 2 or light37.state = 1 then
light37.state = 1
marbles = marbles + 10000
if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 1000
flushdmdtimer.Enabled = true ', 1000
dispdmd1.text = "MARBLE BONUS" & " " & formatscore(marbles) & " " & chr(39)
'pDMDSplashLines "MARBLE BONUS", " "& formatscore(marbles), 3, 33023
end if
exit sub
end if

end sub
'**********************************************************************************
'Spinners
'**********************************************************************************
Sub spinner1_Spin() 'Key
DOF 130, DOFPulse
playsound "fx_spinner"
If Tilted Then Exit Sub
if modename = "key" then
addscore(10000)
keysearch = keysearch - 1
if keysearch = 0 then
keyfound
exit sub
end if
DispDmd1.Text =  "SEARCH FOR KEY" & keysearch & " " & modetime & " " & " " & chr(45)
'pDMDSplashLines "SEARCH FOR KEY"& keysearch, " "& modetime, 3, 33023
exit sub
end if



keytotal = keytotal + 250
if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 500
flushdmdtimer.Enabled = true ', 500
dispdmd1.text = "KEY = " & formatscore(keytotal) & " " & chr(45)
'pDMDSplashLines "KEY = "& formatscore(keytotal), "", 3, 33023
end if


addscore(250)



end sub

sub spinner2_Spin()
DOF 130, DOFPulse
playsound "fx_spinner"
If Tilted Then Exit Sub
doubloon = doubloon + 250
if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 500
flushdmdtimer.Enabled = true ', 500
dispdmd1.text = "DOUBLOON " & formatscore(doubloon) & " " & chr(44)
'pDMDSplashLines "DOUBLOON "& formatscore(doubloon), "", 3, 33023
end if

addscore(250)

end sub

'**********************************************************************************
'Swordsman
'**********************************************************************************
sub trigger6_hit()
If Tilted Then Exit Sub
playsound "ballclick"
'if modename = "rscene1" or modename = "rscene2" then
'raidershit()
'exit sub
'end if
playsound "ughh2"
if modename = "" then
swordhit = swordhit + 1
if swordhit = swordneeded then
startsword()
exit sub
end if
end if
if modename <>"" then
exit sub
end if

if scoreupdate = true then
DispDmd1.Text = " " & (swordneeded-swordhit) & " MORE FOR" & " HURRY UP"
'pDMDSplashLines " " & (swordneeded-swordhit), "MORE FOR HURRY UP", 3, 33023
scoreupdate = false
flushdmdtimer.Interval = 2000
flushdmdtimer.Enabled = true ', 500
end if
end sub

sub startsword()
if templeopen = true then
traphitsleft = 2
opencaptive
templeopen = false
end if
playsound "masizefives"
light47.state = 2
nevere1.state = 1
checknever
swordscore = 1500000
DispDmd1.Text = "[f4][x20][y18]" & formatscore(swordscore) & "[f2][x2][y2]HIDE FROM THE" &"[f2][x10][y10]FRATELLIS" & "[f9][xc][yc]" & chr(38)
'pDMDSplash3Lines " "&formatscore(swordscore), "", "HIDE FROM THE FRATELLIS", 3, 33023
scoreupdate = false
modename = "sword"
swordmodetimer.Interval = 60000
swordmodetimer.Enabled = true', 60000
swordmodetimer2.Interval = 5000
swordmodetimer2.Enabled = true', 5000
restartmusic.Interval = 200
restartmusic.Enabled = true', 200
swordmove()
end sub

sub swordmodetimer2_Timer()
swordscore = swordscore - 1520
if swordscore <250000 then
swordscore = 250000
end if
DispDmd1.Text = "[f4][x20][y18]" & formatscore(swordscore) & "[f2][x2][y2]HIDE FROM THE" &"[f2][x10][y10]FRATELLIS" & "[f9][xc][yc]" & chr(38)
'pDMDSplash3Lines " "&formatscore(swordscore), " ", "HIDE FROM THE FRATELLIS", 3, 33023
swordmodetimer2.Interval = 60
swordmodetimer2.Enabled = true ',60
end sub



sub swordmodetimer_Timer()
light47.state = 0
swordmodetimer2.Enabled = false
DispDmd1.Text =  "[f9][xc][yc]" & chr(43)
playsound "fratlose"
flushdmdtimer.Interval = 2000
flushdmdtimer.Enabled = true ', 500
swordneeded = swordneeded + 3
swordhit = 0
modename = ""
swordmodetimer.Enabled = false
restartmusic.Interval = 200
restartmusic.Enabled = true', 200
swordmove()
end sub
sub swordsmanhit()
'swordman shot animation and score
kicker2timer.Interval = 3000
kicker2timer.Enabled = true ', 3000
lightseq1.Play Seqblinking, , 5,50
playsound "gunshot"
DispDmd1.Text = "[edge4][f7][xc][yc]" & formatscore(swordscore)
'pDMDSplashLines " "&formatscore(swordscore), " ", 3, 33023
flushdmdtimer.Interval = 1500
flushdmdtimer.Enabled = true ', 500
addscore(swordscore)
swordneeded = swordneeded + 3
swordhit = 0
modename = ""
swordmodetimer.Enabled = false
swordmodetimer2.Enabled = false
restartmusic.Enabled = true', 200

light47.state = 0
end sub
sub kicker2timer_Timer()
kicker2solenoidpulse()
playsound "fx_kicker"
kicker2timer.Enabled = false
end sub

Sub kicker2solenoidpulse()
Kicker2.kick 225, 10
End Sub

sub swordmove()
'if swordsman.anglexz = 245 then
'swordsman.rotatexz 150,335
'end if
'if swordsman.anglexz = 335 then

'swordsman.RotateXZ -150,245
'end if
end sub

'*********************************************************************************
'Mystery
'*********************************************************************************

Sub startmystery()
neverv.state = 1
checknever
PlaySong "mu_end"
restartmusic.Interval = 5500
restartmusic.Enabled = true', 5200
playsound "databoody"
Select case (RandomNumber(8))
case 1: mysterymode = "SPY EYES" ' bonus at max DONE
'pDMDSplash3Lines "DATA GADGET", "", "SPY EYES", 2, 33023
case 2: mysterymode = "SLICK SHOES" ' jackpot at max DONE
'pDMDSplash3Lines "DATA GADGET", "", "SLICK SHOES", 2, 33023
case 3: mysterymode = "THATS NOT A CANDLE" ' shoot ramp for jackpot
'pDMDSplash3Lines "DATA GADGET", "", "THATS NOT A CANDLE", 2, 33023
case 4: mysterymode = "WINGS OF FLIGHT" ' award jackpot DONE
'pDMDSplash3Lines "DATA GADGET", "", "WINGS OF FLIGHT", 2, 33023
case 5: mysterymode = "STICKY DART" ' extra ball DONE
'pDMDSplash3Lines "DATA GADGET", "", "STICKY DART", 2, 33023
case 6: mysterymode = "PINCERS OF PERIL" ' open trap DONE
'pDMDSplash3Lines "DATA GADGET", "", "PINCERS OF PERIL", 2, 33023
case 7: mysterymode = "BULLY BLINDERS" ' start truffle DONE
'pDMDSplash3Lines "DATA GADGET", "", "BULLY BLINDERS", 2, 33023
case 8: mysterymode = "BULLY BUSTER" ' marble bonus boost DONE
'pDMDSplash3Lines "DATA GADGET", "", "BULLY BUSTER", 2, 33023
end select
scoreupdate = false
DispDmd1.Text = " DATA GADGET" & " " & mysterymode & " " & chr(36)
'pDMDSplash3Lines "DATA GADGET", "", ""& mysterymode, 4, 33023
mysteryend.Interval = 4000
mysteryend.Enabled = true ',4000
mysterychange.Interval = 200
mysterychange.Enabled = true', 200

lightseq1.Play Seqblinking, , 10,50

light27.state = 2
light28.state = 2
light29.state = 2
light30.state = 2

dataD = "D"
dataA = "A"
dataT = "T"
dataA2 = "A"
end sub

sub mysteryend_Timer()
addscore(10000)
'mysterymode = "SLICK SHOES"
mysterychange.Enabled = false
'kicker1.solenoidpulse()
'playsound "fx_kicker"
mysteryend.Enabled = false
kicker1timer.Interval = 1000
kicker1timer.Enabled = true ',1000
'test
'startsnakes()
'exit sub
'mysterymode = "WINGS OF FLIGHT"
if mysterymode = "SPY EYES" then
kicker1timer.Interval = 2500
kicker1timer.Enabled = true ', 2500
flushdmdtimer.Interval = 2500
flushdmdtimer.Enabled = true ', 2500
scoreupdate = false

DispDmd1.Text = "SPY EYES" & " BONUS X AT MAX"
'pDMDSplashLines "SPY EYES", "BONUS X AT MAX", 3, 33023
mapmulti = 10

exit sub
end if

if mysterymode = "SLICK SHOES" then
kicker1timer.Interval = 2500
kicker1timer.Enabled = true ', 2500
flushdmdtimer.Interval = 2500
flushdmdtimer.Enabled = true ', 2500
scoreupdate = false

DispDmd1.Text = "[xc][y1][f5]SLICK SHOES" & "[xc][y18][f3]JACKPOT AT MAX[edge4]"
'pDMDSplashLines "SLICK SHOES", "JACKPOT AT MAX", 3, 33023
'light17.state = bulbon
jackpotscore = 10000000
playsound "dataslickshoes"
exit sub
end if

if mysterymode = "THATS NOT A CANDLE" then
kicker1timer.Interval = 2500
kicker1timer.Enabled = true ', 2500
flushdmdtimer.Interval = 2500
flushdmdtimer.Enabled = true ', 2500
scoreupdate = false
playsound "candle"
DispDmd1.Text = "[xc][y1][f4]THATS NOT A CANDLE" & "[xc][y18][f2]HIT RAMP FOR JACKPOT[edge4]"
'pDMDSplashLines "THATS NOT A CANDLE", "HIT RAMP FOR JACKPOT", 3, 33023
'to do add flag for ramp jackpot
light39.state = 2
light49.state = 2
light44.state = 2


exit sub
end if
if mysterymode = "WINGS OF FLIGHT" then
kicker1timer.Interval = 8500
kicker1timer.Enabled = true ', 8500
flushdmdtimer.Interval = 9500
flushdmdtimer.Enabled = true' , 9500
restartmusic.Interval = 8500
restartmusic.Enabled = true', 8500
scoreupdate = false
playsound "datawings"
dmdfont = "WINGS OF FLIGHT"

matchchr = 32
endmatchchr = 125
dmdanimtimer.Interval = 100
dmdanimtimer.Enabled = true ', 100
dmdspeed = 60
endtext = "WINGS OF FLIGHT" & " JACKPOT AWARDED"
'pDMDSplashLines "WINGS OF FLIGHT", "JACKPOT AWARDED", 3, 33023
addscore(jackpotscore)
exit sub
end if
if mysterymode = "STICKY DART" then
kicker1timer.Interval = 8500
kicker1timer.Enabled = true' , 8500
flushdmdtimer.Interval = 9500
flushdmdtimer.Enabled = true ', 9500
restartmusic.Interval = 8500
restartmusic.Enabled = true', 8500
scoreupdate = false
playsound "datadart"
dmdfont = "EXTRA BALL"

matchchr = 32
endmatchchr = 126
dmdanimtimer.Interval = 100
dmdanimtimer.Enabled = true ', 100
dmdspeed = 60
endtext = "STICKY DART" & " EXTRA BALL!"
'pDMDSplashLines "STICKY DART", "EXTRA BALL", 5, 33023

ExtraBallsAwards(CurrentPlayer) = ExtraBallsAwards(CurrentPlayer) + 1
shootagainlight.state = 1
exit sub
end if
if mysterymode = "PINCERS OF PERIL" then
kicker1timer.Interval = 2500
kicker1timer.Enabled = true ', 2500
flushdmdtimer.Interval = 2500
flushdmdtimer.Enabled = true ', 2500
scoreupdate = false
playsound "datapincers"
DispDmd1.Text = "PINCERS OF PERIL" & " TRAP OPEN "
'pDMDSplashLines "PINCERS OF PERIL", "TRAP OPEN", 3, 33023

if templeopen = false then
opencaptive()
end if
exit sub
end if
if mysterymode = "BULLY BLINDERS" then
playsound "databullyblinders"
kicker1timer.Interval = 2500
kicker1timer.Enabled = true ', 2500
flushdmdtimer.Interval = 2500
flushdmdtimer.Enabled = true ', 2500
scoreupdate = false

DispDmd1.Text = "BULLY BLINDERS" & "START TRUFFLE SHUFFLE"
'pDMDSplashLines "BULLY BLINDERS", "START TRUFFLE SHUFFLE", 3, 33023
delaytruffle.Interval = 2500
delaytruffle.Enabled = true', 2500
exit sub
end if
if mysterymode = "BULLY BUSTER" then

kicker1timer.Interval = 2500
kicker1timer.Enabled = true ', 2500
flushdmdtimer.Interval = 2500
flushdmdtimer.Enabled = true ', 2500
scoreupdate = false

DispDmd1.Text = "BULLY BUSTER" & " BOOST MARBLE BONUS"
'pDMDSplashLines "BULLY BUSTER", "BOOST MARBLE BONUS", 3, 33023
marbles = marbles + 10000
exit sub
end if

flushdmdtimer.Interval = 100
flushdmdtimer.Enabled = true',100
end sub

sub delaytruffle_Timer()
delaytruffle.Enabled = false
starttruffle
end sub

sub mysterychange_Timer()
Select case (RandomNumber(8))
case 1: mysterymode = "SPY EYES"
 :'pDMDSplash3Lines "", "","SPY EYES", 4, 33023 ':datachr = 36:
case 2: mysterymode = "SLICK SHOES"
: 'pDMDSplash3Lines "", "", "SLICK SHOES", 4, 33023 ': datachr = 37
case 3: mysterymode = "THATS NOT A CANDLE"
: 'pDMDSplash3Lines "", "", "THATS NOT A CANDLE", 4, 33023' :datachr = 36
case 4: mysterymode = "WINGS OF FLIGHT"
: 'pDMDSplash3Lines "", "", "WINGS OF FLIGHT", 4, 33023' :datachr = 36
case 5: mysterymode = "STICKY DART"
: 'pDMDSplash3Lines "", "", "STICKY DART", 4, 33023 ':datachr = 37
case 6: mysterymode = "PINCERS OF PERIL"
: 'pDMDSplash3Lines "", "", "PINCERS OF PERIL", 4, 33023 ':datachr = 36
case 7: mysterymode = "BULLY BLINDERS"
: 'pDMDSplash3Lines "", "", "BULLY BLINDERS", 4, 33023 ':datachr = 37
case 8: mysterymode = "BULLY BUSTER"
: 'pDMDSplash3Lines "", "", "BULLY BUSTER", 4, 33023 ':datachr = 36
end select
DispDmd1.Text = "DATA GADGET" & " " & mysterymode' & " " & chr(datachr)
'pDMDSplash3Lines "DATA GADGET" , "", "" & mysterymode , 4, 33023
end sub

sub startrats()
ratsendtimer.Interval = 20000
ratsendtimer.Enabled = true', 20000
modename = "rats"
hurrytotal = 2500000
flushdmdtimer.Enabled = false
scoreupdate = false
DispDmd1.Text = " " & score(currentplayer) & " " & lastscore &" " & "RATS" & "Shoot orbits now!" & " " & formatscore(hurrytotal)
'pDMDSplashLines "RATS" , "SHOOT ORBITS NOW!" & " " & formatscore(hurrytotal), 2 ,33023
light50.state = 2
light51.state = 2
ratstimer1.Interval = 3000
ratstimer1.Enabled = true', 3000
end sub

sub ratstimer1_Timer()
ratstimer1.Enabled = false
ratstimer2.Interval = 70
ratstimer2.Enabled = true', 70
end sub

sub ratstimer2_Timer()
hurrytotal = hurrytotal - 10020
if hurrytotal < 500000 then
hurrytotal = 500000
end if

DispDmd1.Text = " " & score(currentplayer) & " " & lastscore &" " & "RATS" & "Shoot orbits now!" & " " & formatscore(hurrytotal)
'pDMDSplashLines "RATS" , "SHOOT ORBITS NOW!" & " " & formatscore(hurrytotal), 2 ,33023
end sub

sub ratsendtimer_Timer()
light50.state = 0
light51.state = 0
ratsendtimer.Enabled = false
ratstimer2.Enabled = false
scoreupdate = true
flushdmdtimer.Interval = 200
flushdmdtimer.Enabled = true', 200
modename = ""
restartmusic.Interval = 200
restartmusic.Enabled = true ', 200
end sub


sub startants()
antsendtimer.Interval = 20000
antsendtimer.Enabled = true', 20000
modename = "ants"
hurrytotal = 2500000
flushdmdtimer.Enabled = false
scoreupdate = false
DispDmd1.Text = " " & score(currentplayer) & " " & lastscore &" " & "ANTS" & " Shoot orbits now!" & " " & formatscore(hurrytotal)
'pDMDSplashLines "ANTS" , "SHOOT ORBITS NOW!" & " " & formatscore(hurrytotal), 2 ,33023
light50.state = 2
light51.state = 2
antstimer1.Interval = 3000
antstimer1.Enabled = true', 3000
end sub

sub antstimer1_Timer()
antstimer1.Enabled = false
antstimer2.Interval = 70
antstimer2.Enabled = true', 70
end sub

sub antstimer2_Timer()
hurrytotal = hurrytotal - 10020
if hurrytotal < 500000 then
hurrytotal = 500000
end if

DispDmd1.Text = " " & score(currentplayer) & " " & lastscore &" " & "ANTS" & " Shoot orbits now!" & "" & formatscore(hurrytotal)
'pDMDSplashLines "ANTS" , "SHOOT ORBITS NOW!" & " " & formatscore(hurrytotal), 2 ,33023
end sub

sub antsendtimer_Timer()
light50.state = 0
light51.state = 0
antsendtimer.Enabled = false
antstimer2.Enabled = false
scoreupdate = true
flushdmdtimer.Interval = 200
flushdmdtimer.Enabled = true', 200
modename = ""
restartmusic.Interval = 200
restartmusic.Enabled = true' , 200
end sub


sub startsnakes()

snakesendtimer.Interval = 20000
snakesendtimer.Enabled = true', 20000
modename = "snakes"
hurrytotal = 2500000
flushdmdtimer.Enabled = false
scoreupdate = false
DispDmd1.Text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f4][x105][y10]SNAKES" & "[f4][x70][y45]Shoot orbits now!" & "[f4][x100][y28]" & formatscore(hurrytotal)
'pDMDSplashLines "SNAKES" , "SHOOT ORBITS NOW!" & " " & formatscore(hurrytotal), 2 ,33023
light50.state = 2
light51.state = 2
snakestimer1.Interval = 3000
snakestimer1.Enabled = true', 3000
end sub
sub snakestimer1_Timer()
snakestimer1.Enabled = false
snakestimer2.Interval = 70
snakestimer2.Enabled = true', 70
end sub

sub snakestimer2_Timer()
hurrytotal = hurrytotal - 10020
if hurrytotal < 500000 then
hurrytotal = 500000
end if

DispDmd1.Text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & "[f4][x105][y10]SNAKES" & "[f4][x70][y45]Shoot orbits now!" & "[f4][x100][y28]" & formatscore(hurrytotal)
'pDMDSplashLines "SNAKES" , "SHOOT ORBITS NOW!" & " " & formatscore(hurrytotal), 2 ,33023
end sub


sub snakesendtimer_Timer()
light50.state = 0
light51.state = 0
snakesendtimer.Enabled = false
snakestimer2.Enabled = false
scoreupdate = true
flushdmdtimer.Interval = 500
flushdmdtimer.Enabled = true', 500
modename = ""
restartmusic.Interval = 200
restartmusic.Enabled = true ', 200
end sub


'**********************************************************************************
sub startoverlay()
'overlay1.fadein()
'overlay1.frame oframestart
'otimer.set true,ospeed
end sub
sub otimer_Timer()
oframestart = oframestart + 1
'overlay1.frame oframestart
if oframestart = oframeend then
otimer.Enabled = false
'overlay1.fadeout()
dispdmd1.text = endtext
endtext = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]0" &"[line3,59,0,59,64] [x70] [yc] [f7]" & formatscore(score(currentplayer)) & "[f1][x66][y57]BALL:" & (6 -BallsRemaining(CurrentPlayer)) & "[f1][x105][y57]PLAYER:" & currentplayer & "[f1][x146][y57]CREDITS:" & nvcredits
 
                        
exit sub
end if
otimer.Enabled = true ', ospeed
end sub

sub endtexttimer_Timer()
endtexttimer.Enabled = false
dispdmd1.text = endtext
end sub





sub sounddelay_Timer()
playsound tempsound
sounddelay.Enabled = false
end sub

sub resetlights()
Dim x
 for x= 20 to 56
  Execute "Light" & x & ".State=BulbOff"
 next
light1.state = 0

end sub



'**********************************************************************************
'DMD animations
'**********************************************************************************

sub startanimation()
currentframe = startframe + 31
endframe = endframe + 31
dispdmd1.text =  "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & dmdfont & "[x60][yc]" & chr(currentframe)
''pDMDSplashLines " " & score(currentplayer) & " " & lastscore &" " & dmdfont , " " & chr(currentframe), 2 ,33023
'dmdanimtimer.Interval = dmdspeed
dmdanimtimer.Enabled = true ', dmdspeed
end sub

sub dmdtimer_Timer()
dmdtimer.Enabled = false
currentframe = currentframe + 1
dispdmd1.text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64]" & dmdfont & "[x60][yc]" & chr(currentframe)
''pDMDSplashLines " " & score(currentplayer) & " " & lastscore &" " & dmdfont , " " & chr(currentframe), 2 ,33023
if currentframe = endframe then
if repeatdmd = true then

currentframe = startframe + 31
'dmdanimtimer.Interval = dmdspeed
dmdanimtimer.Enabled = true ', dmdspeed
exit sub
end if
exit sub
end if
'dmdanimtimer.Interval = dmdspeed
dmdanimtimer.Enabled = true ', dmdspeed
end sub

'****************************************************************************
'show jackpot
'****************************************************************************
sub showjptimer_Timer()
dmdtimer.Enabled = false
'flushdmdtimer.set true , 1500
playsound "excellent"
scoreupdate = false
dispdmd1.text = "[f1][x0] [y0]" & score(currentplayer) & "[f1][x0] [y6]" & lastscore &"[line3,59,0,59,64][f8][x60][yc]" & chr(59) & "[f7][x80][yc]" & formatscore(jpscore)
'pDMDSplashLines " " & score(currentplayer) & " " & lastscore & " " & chr(59) , " " & formatscore(jpscore), 2 ,33023
showjptimer.Enabled = false
addscore(jpscore)
end sub


'*****************************************************************************
'next scene
'*****************************************************************************

sub nextscene()






end sub


'******************************************************************************
'eob bonus
'******************************************************************************

sub starteob()
flushdmdtimer.Enabled = false
PlaySong "Mu_End"
playsound "bonus1"
scoreupdate = false
dispdmd1.text = "BONUS"
'pDMDSplashBonus "BONUS","", 4, 33023
'pNote "BONUS", ""
totalbonus =  ballbonus
if keytotal > 0 then
eobark.Interval = 1500
eobark.Enabled = true',1500
exit sub
end if

if doubloon > 0 then
eobtemple.Interval = 1500
eobtemple.Enabled = true',1500
exit sub
end if

if grailhit > 0 then
eobgrail.Interval = 1500
eobgrail.Enabled = true',1500
exit sub
end if

if rampshots > 0 then
eobskull.Interval = 1500
eobskull.Enabled = true',1500
exit sub
end if

if marbles > 0 then
eobmarble.Interval = 1500
eobmarble.Enabled = true',1500
exit sub
end if

eobmulti.Interval = 1500
eobmulti.Enabled = true',1500
end sub

sub eobark_Timer()
playsound "bonus1"
eobark.Enabled = false
dispdmd1.text = "KEY " & formatscore(keytotal) & " " & chr(45)
'pDMDSplashBonus "KEY", "" & formatscore(keytotal), 2 ,33023
'pNote "KEY " & formatscore(keytotal) & " " & chr(45), ""

totalbonus = totalbonus + (keytotal)

if doubloon > 0 then
eobtemple.Interval = 1500
eobtemple.Enabled = true',1500
exit sub
end if
if grailhit > 0 then
eobgrail.Interval = 1500
eobgrail.Enabled = true',1500
exit sub
end if
if rampshots > 0 then
eobskull.Interval = 1500
eobskull.Enabled = true',1500
exit sub
end if

if marbles > 0 then
eobmarble.Interval = 1500
eobmarble.Enabled = true',1500
exit sub
end if

eobmulti.Interval = 1500
eobmulti.Enabled = true', 1500
end sub

sub eobtemple_Timer()
playsound "bonus1"
eobtemple.Enabled = false
dispdmd1.text = "DOUBLOON " & formatscore(doubloon) & " " & chr(44)
'pDMDSplashBonus "DOUBLOON" , formatscore(keytotal) & "", 2 ,33023
'pNote "DOUBLOON " & formatscore(doubloon) & " " & chr(44), ""
totalbonus = totalbonus + (doubloon)

if grailhit > 0 then
eobgrail.Interval = 1500
eobgrail.Enabled = true',1500
exit sub
end if
if rampshots > 0 then
eobskull.Interval = 1500
eobskull.Enabled = true',1500
exit sub
end if

if marbles > 0 then
eobmarble.Interval = 1500
eobmarble.Enabled = true','1500
exit sub
end if

eobmulti.Interval = 1500
eobmulti.Enabled = true', 1500
end sub

sub eobgrail_Timer()
playsound "bonus1"
eobgrail.Enabled = false

dispdmd1.text = " " & score(currentplayer) & " " & lastscore &" " & chr(72) & " " & grailhit & " GRAIL HITS " & formatscore(grailhit*75000)
'pDMDSplashBonus " GRAIL HITS ", "" & grailhit & "" & formatscore(grailhit*75000) , 2 ,33023
'pNote " " & score(currentplayer) & " " & lastscore &" " & chr(72) & " " & grailhit & " GRAIL HITS " & formatscore(grailhit*75000), ""

totalbonus = totalbonus + (grailhit*75000)

if rampshots > 0 then
eobskull.Interval = 1500
eobskull.Enabled = true',1500
exit sub'
end if


if marbles > 0 then
eobmarble.Interval = 1500
eobmarble.Enabled = true',1500
exit sub
end if
eobmulti.Interval = 1500
eobmulti.Enabled = true', 1500
end sub

sub eobskull_Timer()
playsound "bonus1"
eobskull.Enabled = false

if rampshots = 1 then
dispdmd1.text = " " & rampshots & " RAMP HIT" & " " & chr(33)
'pDMDSplashBonus "RAMP" , "   HIT " & rampshots, 3, 33023
'pNote " " & rampshots & " RAMP HIT" & " " & chr(33) , ""
else
dispdmd1.text = " " & rampshots & " RAMP HITS"  & " " & chr(33)
'pDMDSplashBonus "RAMP HIT" , "HIT " & rampshots, 3, 33023
'pNote " " & rampshots & " RAMP HITS"  & " " & chr(33), ""
end if
totalbonus = totalbonus + (rampshots*100000)

if marbles > 0 then
eobmarble.Interval = 1500
eobmarble.Enabled = true',1500
exit sub
end if
eobmulti.Interval = 1500
eobmulti.Enabled = true', 1500
end sub

sub eobmarble_Timer()
playsound "bonus1"
eobmarble.Enabled = false



dispdmd1.text = "MARBLE BONUS"  & " " & formatscore(marbles) & " " & chr(39)
'pDMDSplashBonus "MARBLE BONUS"  , "" & formatscore(marbles), 3, 33023
totalbonus = totalbonus + (marbles)

eobmulti.Interval = 1500
eobmulti.Enabled = true', 1500
end sub
sub eobmulti_Timer()
playsound "bonus1"
dispdmd1.text = " " & mapmulti & "X " & formatscore(totalbonus)
'pDMDSplashBonus mapmulti & " X"   , "" & formatscore(totalbonus) , 3, 33023
eobmulti.Enabled = false
totalbonus = (totalbonus * mapmulti)

eobtotal.Interval = 1500
eobtotal.Enabled = true',1500
end sub

sub eobtotal_Timer()
playsound "bonus2"
eobtotal.Enabled = false
dispdmd1.text = "TOTAL" &" " & formatscore(totalbonus)
'pDMDSplashBonus "TOTAL" ,"" & formatscore(totalbonus) , 3, 33023
addscore(totalbonus)
checkreplay()
flushdmdtimer.Enabled = false
end sub


'captive.ty = captive.ty-35


sub opencaptive()
'if captive.angleyz <>0 or captive.angleyz<>30 then
'exit sub
'end if

'if captiveP.RotX = 20 then
if captiveP.RotX > 15 then
stonetarget.Isdropped = false
stonetarget1.Isdropped = false
stonetarget2.Isdropped = false
'stonetarget.render = false
'captiveP.RotX = 0',0
captiveDown 35, 0
else
templeopen = true
traphitsleft = 2
droptimer.Interval = 800
droptimer.Enabled = true',800
'captiveP.RotX = 20',20
captiveUp 0, 35
end if



end sub


sub droptimer_Timer()
droptimer.Enabled = false
stonetarget.Isdropped = true
stonetarget1.Isdropped = true
stonetarget2.Isdropped = true
end sub

 Dim HPos, HPosEnd
 Sub captivePAnim_timer()
    captiveP.RotX = HPos
    If Hpos < HposEnd Then
     HPos = HPos + 1
    Else
     'Popupsolenoidpulse.enabled = 0
    End If
end Sub

 Sub captivePAnim2_timer()
    captiveP.RotX = HPos
    If Hpos > HposEnd Then
     HPos = HPos - 1
    Else
     captivePAnim2.enabled = 0
    End If
end Sub

Sub captiveUp(FrameStart, FrameEnd)
    'popup.Isdropped = 0
    HPos = FrameStart         
    HPosEnd = FrameEnd
    captivePAnim.enabled = 1
End Sub

Sub captiveDown(FrameStart, FrameEnd)
    'popup.Isdropped = 1
    HPos = FrameStart         
    HPosEnd = FrameEnd
    captivePAnim2.enabled = 1
End Sub




sub plungertimer_Timer()
    Plungersolenoidpulse
    PlaySound "cannon"
    playsound "gunshot"
autoball = true
plungertimer.Enabled = false
end sub

Sub Plungersolenoidpulse()
    plungerIM.AutoFire
    LaserKickP.TransY = 90
    vpmtimer.addtimer 400, "LaserKickRes '"
End Sub

Sub LaserKickRes()
    LaserKickP.TransY = 0
End Sub

sub titletimer_Timer()
titletimer.Enabled = false

endtext = "  "
matchchr = 32
endmatchchr = 89
dmdfont = "  "
dmdspeed = 80
dmdanimtimer.Interval = 100
dmdanimtimer.Enabled = true ', 100
end sub


sub matchgame()
SollFlipper 0
SolrFlipper 0
LeftFlipper.RotateToStart
RightFlipper.RotateToStart
matchchr = 32
endmatchchr = 61
playermatch =  right(Score(CurrentPlayer),2)
dispdmd1.text = " " & playermatch & " " & chr(matchchr)
'pDMDSplashBonus " " & playermatch , " "&(matchchr),  2, 33023
matchdmdtimer.Interval = 150
matchdmdtimer.Enabled = true ', 150
select case (randomnumber(10))
case 1: indymatch = "00"
case 2: indymatch = "10"
case 3: indymatch = "20"
case 4: indymatch = "30"
case 5: indymatch = "40"
case 6: indymatch = "50"
case 7: indymatch = "60"
case 8: indymatch = "70"
case 9: indymatch = "80"
case 10: indymatch = "90"
end select
'playermatch = indymatch

PlaySong "mu_end"
endofgamedelay.Interval = 10000
endofgamedelay.Enabled = true' ,10000
endmatchdelay.Interval = 6500
endmatchdelay.Enabled = true ', 6500
'startoverlay()
end sub
sub matchdmdtimer_Timer()
matchdmdtimer.Interval = 150
matchdmdtimer.Enabled = true ', 150
matchchr = matchchr + 1
if matchchr > endmatchchr then
matchchr = endmatchchr
matchdmdtimer.Enabled = false
end if
if matchchr > 55 then

dispdmd1.text = " " & indymatch & " " & playermatch & " " & chr(matchchr)
'pDMDSplashBonus " " & indymatch & " " & playermatch , " " &(matchchr),  2, 33023
else

dispdmd1.text = " " & playermatch & " " & chr(matchchr)
'pDMDSplashBonus " " & playermatch , " " &(matchchr),  2, 33023
end if

end sub


sub endofgamedelay_Timer()
matchdmdtimer.Enabled = false
endofgamedelay.Enabled = false
endofgame()
end sub

sub endmatchdelay_Timer()
endmatchdelay.Enabled = false
if playermatch = indymatch then
credits = credits +1
'PlaySound SoundFXDOF("fx_knocker",124,DOFPulse,DOFKnocker)

DOF 140, DOFOn
PlaySound SoundFXDOF("fx_knocker",136,DOFPulse,DOFKnocker)        
DOF 115, DOFPulse
else
select case (randomnumber(2))
case 1: playsound "seeyoutomorrowindy"
case 2: playsound "ikeeptellingyou"
end select

end if
end sub

sub collectspecial()
'light17.state = bulboff
'light19.state = bulboff
playsound "excellentfanfare"
addscore(50000000)
end sub




sub balldropsound_Timer()
balldropsound.Enabled = false
playsound "ballfall"
end sub
sub trigger8_hit()
balldropsound.Enabled = true' , 150
end sub

sub fakegate1hit()
if not fakegate1.IsDropped then
                    fakegate1.popdown
                exit sub
            end if

            if fakegate1.IsDropped then
                fakegate1.SolenoidPulse
                exit sub
            end if
end sub

sub trigger9_hit()
PlaySoundAt SoundFXDOF("fx_PlasticRamp", 103, DOFPulse, DOFContactors), trigger9
if not fakegate2.IsDropped then
                    fakegate2.IsDropped = 1
                exit sub
            end if

            if fakegate2.IsDropped then
                fakegate2.IsDropped = 0
                exit sub
            end if
end sub

sub trigger10_hit()
playsound "ballrollinga"
end sub


sub vuk1_hit()
'vuk1.kick 0, 35, 1.5
'PlaySoundAt "fx_vukout_LAH" ,vuk1
End Sub

Sub Vuk1SolenoidPulse_Timer()
Vuk1SolenoidPulse.Enabled = False
vuk1.kick 0, 55, 1.5
Playsound "fx_vukout_LAH"
End Sub

 

sub rightlight()
dim tempstate
tempstate = light19.state
light19.state = light18.state
light18.state = light42.state
light42.state = light17.state
light17.state = tempstate
end sub

sub leftlight()
dim tempstate
tempstate = light17.state
light17.state = light42.state
light42.state = light18.state
light18.state = light19.state
light19.state = tempstate
end sub

sub checkrich()

if light17.state = 1 and light42.state = 1 and light18.state = 1 and light19.state = 1 then
mapmulti = mapmulti + 1
playsound "rich_stuff"
if mapmulti >= 10 then
mapmulti = 10
end if

LightSeqInserts.Play Seqblinking, , 3,50
if scoreupdate = true then
DispDmd1.Text = " " & mapmulti & "X"
scoreupdate = false
flushdmdtimer.Interval = 2000
flushdmdtimer.Enabled = true ',2000
playsound "jingle15"
end if

flashforms light17, 2000, 50, 0
flashforms light18, 2000, 50, 0
flashforms light19, 2000, 50, 0
flashforms Light42, 2000, 50, 0

light17.state = 0
light18.state = 0
light19.state = 0
Light42.state = 0
addscore(10000)
end if
 

end sub
'door.MoveTo door.Tx, door.Ty-8, door.Tz , 1000


Sub nevertimer1_Timer()
nevertimer1.Enabled = false
nevern.state = 1:NeverNP.visible = 1
nevertimer2.Interval = 1100
nevertimer2.Enabled =  true
end sub
Sub nevertimer2_Timer()
nevertimer2.Enabled =  false
nevere1.state = 1: NeverEP.visible = 1
nevertimer3.Interval = 800
nevertimer3.Enabled =  true
end sub
Sub nevertimer3_Timer()
nevertimer3.Enabled =  false
neverv.state = 1: NeverVP.visible = 1
nevertimer4.Interval = 800
nevertimer4.Enabled =  true
end sub
Sub nevertimer4_Timer()
nevertimer4.Enabled =  false
nevere2.state = 1: NeverE2P.visible = 1
nevertimer5.Interval = 800
nevertimer5.Enabled =  true
end sub
Sub nevertimer5_Timer()
nevertimer5.Enabled =  false
neverr.state = 1: NeverRP.visible = 1
nevertimer6.Interval = 800
nevertimer6.Enabled =  true
end sub
Sub nevertimer6_Timer()
nevertimer6.Enabled =  false
nevers.state = 1: NeverSP.visible = 1
nevertimer7.Interval = 1500
nevertimer7.Enabled =  true
end sub
Sub nevertimer7_Timer()
nevertimer7.Enabled =  false
neverA.state = 1: NeverAP.visible = 1
nevertimer8.Interval = 800
nevertimer8.Enabled =  true
end sub
Sub nevertimer8_Timer()
nevertimer8.Enabled =  false
nevery.state = 1: NeverYP.visible = 1
nevertimer9.Interval = 800
nevertimer9.Enabled =  true
end sub
Sub nevertimer9_Timer()
nevertimer9.Enabled =  false
neverd.state = 1: NeverDP.visible = 1
nevertimer10.Interval = 1300
nevertimer10.Enabled =  true
end sub
Sub nevertimer10_Timer()
nevertimer10.Enabled =  false
neveri.state = 1: NeverIP.visible = 1
nevertimer11.Interval = 800
nevertimer11.Enabled =  true
end sub
Sub nevertimer11_Timer()
nevertimer11.Enabled =  false
nevere3.state = 1: NeverEP3.visible = 1
neverreset.Interval = 2500
neverreset.Enabled =  true
end sub
sub neverreset_Timer()
neverreset.Enabled =  false
nevern.state = 0: NeverNP.visible = 0
nevere1.state = 0: NeverEP.visible = 0
neverv.state = 0: NeverVP.visible = 0
nevere2.state = 0: NeverE2P.visible = 0
neverr.state = 0: NeverRP.visible = 0
nevers.state= 0: NeverSP.visible = 0
nevera.state = 0: NeverAP.visible = 0
nevery.state = 0: NeverYP.visible = 0
neverd.state = 0: NeverDP.visible = 0
neveri.state = 0: NeverIP.visible = 0
nevere3.state = 0: NeverEP3.visible = 0
nevertimer1.Interval = 2500
nevertimer1.Enabled =  true
end sub


sub checknever()
if nevern.state = 1 and nevere1.state = 1 and neverv.state = 1 and nevere2.state = 1 and neverr.state = 1 and nevers.state = 1 and nevera.state = 1 and nevery.state = 1 and neverd.state = 1 and neveri.state = 1 and nevere3.state = 1 then
light46.state = 2
playsound "neversaydie"
end if

end sub

sub resetdoor_Timer()
resetdoor.Enabled = false

bulb4.state = 0
'light43.state = bulboff
'fakedoor.isdropped = false
'fakedoor.render = false
'door.MoveTo door.Tx, door.Ty+40, door.Tz , 50
DoorUp 0, 60
end sub


'Bonus Target
sub target20_hit()
if modename = "key" or modename = "bone" or modename = "boulder" or modename = "water" or modename = "fight" then
modetime = modetime + 5
exit sub
end if

if light1.state = 2 then
ExtraBallsAwards(CurrentPlayer) = ExtraBallsAwards(CurrentPlayer) + 1
shootagainlight.state = 1
light1.state = 0
if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 1500
flushdmdtimer.Enabled = true', 1500
dispdmd1.text = "EXTRA BALL"
'pDMDSplashBig "EXTRA BALL", 3, 33023
end if
exit sub
end if

if slothmulti = 2 then
slothtimer.Interval = 30000
slothtimer.Enabled = true ', 30000
playsound "slothhey"
exit sub
end if

if wellsound = true then
wellsound = false
resetwell.Interval = 5000
resetwell.Enabled = true ', 5000
wellhit = wellhit + 1'
if wellhit = 1 then
playsound "wishing_well"
end if
if wellhit = 2 then
playsound "andybucket"
end if
if wellhit = 3 then
playsound "andyyougoonie"
'reward
addscore(500000)
if scoreupdate = true then
scoreupdate = false
flushdmdtimer.Interval = 1500
flushdmdtimer.Enabled = true', 1500
dispdmd1.text = "WELL BONUS"
'pDMDSplashBig "WELL BONUS" , 3, 33023
end if
wellhit = 0
end if
end if


end sub


Dim HPos2, HPosEnd2
 Sub DoorUpSolenoidpulse_timer()
    FakedoorP.Z = HPos2
    If Hpos2 < HposEnd2 Then
     HPos2 = HPos2 + 1
    Else
     DoorUpSolenoidpulse.enabled = 0
    End If
end Sub

 Sub DoorDownSolenoidpulse_timer()
    FakedoorP.Z = HPos2
    If Hpos2 > HposEnd2 Then
     HPos2 = HPos2 - 1
    Else
     DoorDownSolenoidpulse.enabled = 0
    End If
end Sub

Sub DoorUp(FrameStart, FrameEnd)
    Fakedoor.Isdropped = 0
    HPos2 = FrameStart         
    HPosEnd2 = FrameEnd
    DoorUpSolenoidpulse.enabled = 1
End Sub

Sub DoorDown(FrameStart, FrameEnd)
    Fakedoor.Isdropped = 1
    HPos2 = FrameStart         
    HPosEnd2 = FrameEnd
    DoorDownSolenoidpulse.enabled = 1
End Sub









sub resetwell_Timer()
resetwell.Enabled = false
wellsound = true
end sub

sub trigger13_hit()
bulb1.state = 2
DOF 114, DOFPulse        
DOF 115, DOFPulse
end sub

sub trigger12_hit()
bulb1.state = 0
end sub

sub combotimer_Timer()
comboon = false
combotimer.Enabled = false
end sub

sub addcombo()
addscore(combovalue)
if scoreupdate = true then
flushdmdtimer.Interval = 1500
flushdmdtimer.Enabled = true ', 1500
scoreupdate = false
dispdmd1.text = " COMBO" & " " & formatscore(combovalue)
'pDMDBlinkLines " COMBO", " "& formatscore(combovalue), 1, 33023
end if
combovalue = combovalue + 50000
end sub

sub dmdanimtimer_Timer()
'dmdanimtimer.Interval = dmdspeed
dmdanimtimer.Enabled = true ', dmdspeed
matchchr = matchchr + 1
if matchchr => endmatchchr then
matchchr = endmatchchr
dmdanimtimer.Enabled = false
dispdmd1.text = dmdfont & " " & chr(matchchr) & endtext & "  "
'pDMDSplashBonus dmdfont & " ",  chr(matchchr) & endtext &"  ", 1, 33023
exit sub
end if

dispdmd1.text = dmdfont & " " & chr(matchchr) & "  "
'pDMDSplashBonus dmdfont & " ",  chr(matchchr) & "  ", 1, 33023
end sub

sub resettable()
modejp = false

target10.Isdropped = 0
target11.Isdropped = 0
target12.Isdropped = 0
target13.Isdropped = 0
target14.Isdropped = 0
target15.Isdropped = 0
target16.Isdropped = 0
tchr = 34
modetime = 0
keysearch = 0
wellsound = true
wellhit = 0
autoball = false
'ballslocked = 0
loopd = ""
titletimer.Enabled = false
dmdanimtimer.Enabled = false
slothmulti = 1
jackpotscore = 1000000
marbles = 0
comboon = false
combovalue = 50000
    Dim    i
if captiveP.RotX > 15 then

stonetarget.Isdropped = false
stonetarget1.Isdropped = false
stonetarget2.Isdropped = false
'stonetarget.render = false
'captiveP.RotX = 0
captiveDown 35, 0
end if

resetxmarks.Enabled = false
resetlights()
LightSeq1.stopplay()
nevertimer1.Enabled = false
nevertimer2.Enabled = false
nevertimer3.Enabled = false
nevertimer4.Enabled = false
nevertimer5.Enabled = false
nevertimer6.Enabled = false
nevertimer7.Enabled = false
nevertimer8.Enabled = false
nevertimer9.Enabled = false
nevertimer10.Enabled = false
nevertimer11.Enabled = false

neverreset.Enabled = false
nevern.state = 0: NeverNP.visible = 0
nevere1.state = 0: NeverEP.visible = 0
neverv.state = 0: NeverVP.visible = 0
nevere2.state = 0: NeverE2P.visible = 0
neverr.state = 0: NeverRP.visible = 0
nevers.state= 0: NeverSP.visible = 0
nevera.state = 0: NeverAP.visible = 0
nevery.state = 0: NeverYP.visible = 0
neverd.state = 0: NeverDP.visible = 0
neveri.state = 0: NeverIP.visible = 0
nevere3.state = 0: NeverEP3.visible = 0
'playmusic 1 ,"ballready",true
light27.state = 2
light28.state = 2
light29.state = 2
light30.state = 2
light31.state = 2
light32.state = 2
light33.state = 2
light34.state = 2
light35.state = 2
light51.state = 2
light48.state = 2
liftno = 1
scoreupdate = true
lastscore =0
spellarkframe = 42
organhitsleft = 7
tempsound = ""
raidersjp = 1000000
templejp = 1000000
crystaljp = 1000000
crusadejp = 1000000
modename = ""
mapmulti = 1
swordhit = 0
swordneeded = 5
nextscenescore = 1000000
indyscoring = false
jonesscoring = false
indyhitsleft = 0
joneshitsleft = 0
ballbonus = 0
totalbonus = 0
arkhit = 0
templehit = 0
grailhit = 0
skullhit = 0
hitskull = true
mysterymode = ""
xmarks = 1
xmarkshits = 3
traphitsleft = 2
stonesleft = 3
stonekicker = false
jackpotanim = false
templeopen = false
stonescollected = 0
rampshots = 0
rampshotsleft = 5
dataD = "  "
dataA = "  "
dataT = "  "
dataA2 = "  "
slothS = "  "
slothL = "  "
slothO = "  "
slothT = "  "
slothH = "  "

end sub


sub startwizard()
PlaySong "mu_end"
restartmusic.Interval = 2000
restartmusic.Enabled = true', 2000
dispdmd1.text = " WIZARD "
'pDMDSplashBig "WIZARD", 3, 33023
modename = "wizard"
light43.state = 0
light46.state = 0
light50.state = 2
light40.state = 2
light37.state = 2
light26.state = 2
light51.state = 2
light36.state = 2
light45.state = 2
light23.state = 2
light24.state = 2
light25.state = 2

light44.state = 2
light39.state = 2
light49.state = 2
plungertimer.Interval = 1500
plungertimer.Enabled = true ', 1500
createnewball
bmultiballmode = true
kicker7timer.Interval = 5000
kicker7timer.Enabled = true ', 5000
end sub

sub endwizard()
modename = ""
resettable
end sub

sub wizardjp()


addscore(jackpotscore)
modejp = true
scoreupdate = false
flushdmdtimer.Interval = 2500
flushdmdtimer.Enabled = true ',2500
dispdmd1.text =  "JACKPOT"
'pDMDSplashBig "JACKPOT" , 2, 33023
'flushdmdtimer.set true , 2000

end sub

 

 

Cheers,

Nursie

thanks Nursie!

Photo
Flash Table Lover
Sep 14 2019 10:24 PM

Excellent game, thank you javier!! I spent about an hour getting it up and running, and still not quite right, but is playable and fun. Thank you Nursie as well, though that didn't get it going. Finally deleted the game, re-unzipped pinuplayer, then unzipped the table, created a screenres file and got it going...not perfect, but as said, still fun and worth the effort. :) 

Super !

merci pour le script sans PinUPPlayer

 

mais j ai quand même une erreur ligne 5025 erreur nvscore

 

si solution...

Précision pour la ligne 5025 l'erreur est type incompatible nvscore.

 

la ligne : DispDmd1.Text = "[xc] [y3] [f7]" & formatscore(nvscore(currentplayer)) & "[f1][x0][y26]BALL:" & (6 -BallsRemaining(CurrentPlayer)) & "[f1][x40][y26]PLAYER:" & currentplayer & "[f1][x86][y26]CREDITS:" & nvcredits

 

merci

Hi guys!

Breaking down and asking my first question that I simply can not find the answer to.

I'm new to the VP scene. I've installed future pinball and VPX along with the Pinup system.

 

I've been able to find the necessary files for most VPX games and both VPX and FP are up and running 

with popper and pinup player well.

 

I really want to get this game up and running in VPX but simply can not find the ROM.

I've downloaded GTX Joe's ROM list. It isn't in there.

I've looked in the script file to find the correct ROM filename Const cGameName = "goonies"

Nothing I search turns this file up?!? I've looked on multiple Vpinball sites. I can't figure out what

I'm missing here? Any nudge in the right direction would be super helpful. Thanks!

Hi guys!

Breaking down and asking my first question that I simply can not find the answer to.

I'm new to the VP scene. I've installed future pinball and VPX along with the Pinup system.

 

I've been able to find the necessary files for most VPX games and both VPX and FP are up and running 

with popper and pinup player well.

 

I really want to get this game up and running in VPX but simply can not find the ROM.

I've downloaded GTX Joe's ROM list. It isn't in there.

I've looked in the script file to find the correct ROM filename Const cGameName = "goonies"

Nothing I search turns this file up?!? I've looked on multiple Vpinball sites. I can't figure out what

I'm missing here? Any nudge in the right direction would be super helpful. Thanks!

 

 

I got the pup-pack version from another site; The Goonies_VPX_1.03.vpx

My version doesn't need a rom.

I don't see videos however

BONJOUR,

a quel endroit doit on copier le dossier PinUPSystem

Merci pour vos réponses


Other files you may be interested in ..





  • 17,141 Total Files
  • 57 Total Categories
  • 841 Total Authors
  • 21,806,985 Total Downloads
  • Clown Latest File
  • javito Latest Submitter

user(s) are online (in the past 15 minutes)

members, guests, anonymous users