• Google Translate to French or Other Languages Click on the link and a new tab will open with this page translated into French.
    Click on the "To:" pull down option to select a different language. Users will not be logged in on the new Google tab.

BAM Codes and examples of codes to use in BAM

Paolo

No Bam no Play
Chat Moderator
Site Supporters
This code must be inserted directly in the script of FP .... the external file is no longer needed to work (thanks to Gimli)



Code:
'------------------------------------------------------------------
'  Smoke's Ball Rolling Sounds
'------------------------------------------------------------------
' These are the options for ball rolling sounds
Const SelectSound = "zfx_ballrolling0" '"zfx_ballrolling"  or "zfx_ballrolling2" or "zfx_ballrolling2Loud" or "zfx_ballrolling2Louder" or "zfx_ballrolling2Loudest"
Const SoundVolume = 1.0 ' set volume between 0 and 1.  You can also tweak below as you wish


dim ZRBrampHeight
dim ZRBtablewide
dim ZRBrampVolNormLevel
dim ZRBsoundballchan
dim ZRBrampSoundballchan
dim ZRBvolNormLevel
dim ZRBrollingSound
dim ZRBPitchTunning
dim ZRBrampRollingSound
dim ZRBrampPitchTunning

dim ZRBwireVolNormLevel
dim ZRBwireRollingSound
dim ZRBwirePitchTunning

dim zmaxspeedworldrecord
'*****************************
'*****************************
' TO ADJUST TO YOUR NEEDS  in the importing script
'*****************************
'*****************************
ZRBrampHeight=45
ZRBtablewide = 520

ZRBsoundballchan = 7
ZRBvolNormLevel =SoundVolume'  0.40
ZRBrollingSound=SelectSound
ZRBPitchTunning=-40

ZRBrampSoundballchan = 7  'set to -1 to disable rampsound roll
ZRBrampVolNormLevel = 0.80
ZRBrampRollingSound="zfx_ballrolling1" '"zfx_ballrolling"  or "zfx_ballrolling2" or "zfx_ballrolling2Loud" or "zfx_ballrolling2Louder" or "zfx_ballrolling2Loudest"
ZRBrampPitchTunning=40 '20

ZRBwireVolNormLevel = 2.0
ZRBwireRollingSound="zfx_ballrolling" '"zfx_ballrolling"  or "zfx_ballrolling2" or "zfx_ballrolling2Loud" or "zfx_ballrolling2Louder" or "zfx_ballrolling2Loudest"
ZRBwirePitchTunning=10 '60



'*****************************
'*****************************

Const ZRBsearchshifterror = 900   'max radius*radius-> 30mm*30mm=900

Const ZRBvelTuning = 25
Const ZRBvolTuning = 2300

Dim ZRBtrakedSoundBalls(20)
Dim ZRBwireSoundBalls(20)

dim ZRBlastfoundFastBallResultPF
dim ZRBlastfoundFastBallResultRamp
dim ZRBlastRampSound
dim ZRBchanRampPaused
dim ZRBchanPFPaused


Sub RollingBallUpdateTimer_Expired()
    dim volRampFactor,invvolRampFactor,tmpPitch,tmpVol,tmpballonwire
    dim foundFastBallResultPF,foundFastBallResultRamp



    'SOUND MODE

    set foundFastBallResultPF=foundFastBallPlayfield()
    set foundFastBallResultRamp=foundFastBallRamp()
    tmpballonwire=stillBallOnWire()


    volRampFactor=1.0
    invvolRampFactor=0.0


    if (foundFastBallResultPF is nothing) then
        if not(ZRBlastfoundFastBallResultPF is nothing) then
            ZRBchanPFPaused=true
            set ZRBlastfoundFastBallResultPF=nothing
            EffectMusic ZRBsoundballchan, Pause, 0, 0
        end if
     else
        set ZRBlastfoundFastBallResultPF = foundFastBallResultPF
    ' play the rolling sound for each ball
        If ((zfunBallVel(foundFastBallResultPF)>1)) Then

                volRampFactor=1.0/((relativeBallHeight(foundFastBallResultPF.PositionGlobal.z)/7) ^2 +1)

                if (ZRBchanPFPaused) then
                    ZRBchanPFPaused=false
                    EffectMusic ZRBsoundballchan, ResumePlaying, 0, 0
                end if
                EffectMusic ZRBsoundballchan, SetVolume, zfunVol(foundFastBallResultPF)*volRampFactor*ZRBvolNormLevel, 0
                EffectMusic ZRBsoundballchan, SetFrequency, 0, zfunPitch(foundFastBallResultPF)+ZRBPitchTunning

'AddDebugText ( relativeBallHeight(foundFastBallResultPF.PositionGlobal.z)  ) & "   " & volRampFactor &" P"&time()

'if (round(100*(zfunVol(foundFastBallResultPF)*volRampFactor))>10) then
'AddDebugText "v "&round(100*(zfunVol(foundFastBallResultPF)*volRampFactor)) & " P "&(zfunPitch(foundFastBallResultPF)+ZRBPitchTunning)
'end if
        Else
                if not(ZRBchanPFPaused) then
                    ZRBchanPFPaused=true
                    EffectMusic ZRBsoundballchan, Pause, 0, 0
                end if
        End If
    end if



        if (ZRBrampSoundballchan>0) then
                if (foundFastBallResultRamp is nothing) then
                    if not(ZRBlastfoundFastBallResultRamp is nothing) then
                        set ZRBlastfoundFastBallResultRamp=nothing
                        ZRBchanRampPaused=true
                        EffectMusic ZRBrampSoundballchan, Pause, 0, 0
                    end if

                else
                    set ZRBlastfoundFastBallResultRamp = foundFastBallResultRamp
                ' play the rolling sound for each ball
                    If ((zfunBallVel(foundFastBallResultRamp)>1)) Then
            
                                        volRampFactor=1.0-1.0/((relativeBallHeight(foundFastBallResultRamp.PositionGlobal.z)/7) ^2 +1)
                                        if (volRampFactor<0.0) then
                                            volRampFactor=0.0
                                        end if
            
                        
                                        if (tmpballonwire) then
                                            if (ZRBlastRampSound=ZRBrampRollingSound) then
                                                ZRBlastRampSound=ZRBwireRollingSound
                                                StopMusic ZRBrampSoundballchan
                                                PlayMusic ZRBrampSoundballchan, ZRBwireRollingSound, TRUE ,0 ,0
                                            else           
                                                    if (ZRBchanRampPaused) then
                                                        ZRBchanRampPaused=false
                                                        EffectMusic ZRBrampSoundballchan, ResumePlaying, 0, 0
                                                    end if
                                            end if
                                            EffectMusic ZRBrampSoundballchan, SetVolume, zfunVol(foundFastBallResultRamp)*volRampFactor*ZRBwireVolNormLevel, 0
                                            EffectMusic ZRBrampSoundballchan, SetFrequency, 0, zfunPitch(foundFastBallResultRamp)+ZRBwirePitchTunning
'AddDebugText "ww->"&zfunVol(foundFastBallResultRamp)*volRampFactor*ZRBwireVolNormLevel
                                        else
                                            if not(ZRBlastRampSound=ZRBrampRollingSound) then
                                                ZRBlastRampSound=ZRBrampRollingSound
                                                StopMusic ZRBrampSoundballchan
                                                PlayMusic ZRBrampSoundballchan, ZRBrampRollingSound, TRUE ,0 ,0
                                            else           
                                                    if (ZRBchanRampPaused) then
                                                        ZRBchanRampPaused=false
                                                        EffectMusic ZRBrampSoundballchan, ResumePlaying, 0, 0
                                                    end if
                                            end if
                                            EffectMusic ZRBrampSoundballchan, SetVolume, zfunVol(foundFastBallResultRamp)*volRampFactor*ZRBrampVolNormLevel, 0
                                            EffectMusic ZRBrampSoundballchan, SetFrequency, 0, zfunPitch(foundFastBallResultRamp)+ZRBrampPitchTunning
                                        end if
'            AddDebugText relativeBallHeight(foundFastBallResultRamp.PositionGlobal.z) & "   " & volRampFactor &" R"&time()

            'if (round(100*(zfunVol(foundFastBallResultRamp)*volRampFactor))>10) then
            'AddDebugText "v2 "&round(100*(zfunVol(foundFastBallResultRamp)*volRampFactor)) & "P2  "&(zfunPitch(foundFastBallResultRamp)+ZRBPitchTunning)
            'end if
                    Else
                                if not(ZRBchanRampPaused) then
                                    ZRBchanRampPaused=true
                                    EffectMusic ZRBrampSoundballchan, Pause, 0, 0
                                end if
                    End If
               end if
        end if


End Sub

Function relativeBallHeight(zzz)
    if (zzz<ZRBrampHeight) then
        relativeBallHeight=0.0
    else
        relativeBallHeight=(zzz-ZRBrampHeight)
    end if

end Function

Function zfunVol(ball) ' Calculates the Volume of the sound based on the ball speed
   'zfunVol = (zfunBallVel(ball) + zfunBallVel(ball) ^2) / ZRBvolTuning
    zfunVol = (zfunBallVel(ball) ^2) / ZRBvolTuning
    if (zfunVol>1.0) then
        zfunVol=1.0
    end if
End Function

Function foundFastBallPlayfield() ' Calculates the Volume of the sound based on the ball speed
    dim speed,speedtmp,tmpball,j
    speed=1
    set foundFastBallPlayfield=nothing
    For j = 1 To 20
        set tmpball=ZRBtrakedSoundBalls(j)
        if (not(tmpball is nothing)) then
            speedtmp=zfunBallVel(tmpball)
            if (speedtmp>speed and (tmpball.PositionGlobal.z<ZRBrampHeight)) then
                set foundFastBallPlayfield=tmpball
                speed=speedtmp
'AddDebugText j& "fast "& speed
            end if
        end if
    Next
End Function

Function foundFastBallRamp() ' Calculates the Volume of the sound based on the ball speed
    dim speed,speedtmp,tmpball,j
    speed=1
    set foundFastBallRamp=nothing
    For j = 1 To 20
        set tmpball= ZRBtrakedSoundBalls(j)
        if (not(tmpball is nothing)) then
            speedtmp=zfunBallVel(tmpball)
            if (speedtmp>speed and (tmpball.PositionGlobal.z>=ZRBrampHeight)) then
                set foundFastBallRamp=tmpball
                speed=speedtmp
'AddDebugText j& "fastramp "& speed
            end if
        end if
    Next
End Function

'add a call to this in FuturePinball_BeginPlay
Sub initTrakedSoundBalls()
    dim j
    RollingBallUpdateTimer.userdata = nothing

    For j = 1 To 20
        set ZRBtrakedSoundBalls(j)=nothing
        set ZRBwireSoundBalls(j)=nothing
    Next

    'limited to 1 ball sound sorry
    StopMusic ZRBsoundballchan
    PlayMusic ZRBsoundballchan, ZRBrollingSound, TRUE ,0 ,0
    EffectMusic ZRBsoundballchan, Pause, 0, 0

    if (ZRBrampSoundballchan>0) then
        StopMusic ZRBrampSoundballchan
        PlayMusic ZRBrampSoundballchan, ZRBrampRollingSound, TRUE ,0 ,0
        EffectMusic ZRBrampSoundballchan, Pause, 0, 0
    end if


    set ZRBlastfoundFastBallResultPF= nothing
    set ZRBlastfoundFastBallResultRamp= nothing
    ZRBchanRampPaused=true
    ZRBchanPFPaused=true

    zmaxspeedworldrecord=0.0

    ZRBlastRampSound=ZRBrampRollingSound

AddDebugText "ZRBrampHeight "&ZRBrampHeight
AddDebugText "ZRBtablewide "&   ZRBtablewide
AddDebugText "ZRBsoundballchan "&   ZRBsoundballchan
AddDebugText "ZRBvolNormLevel "&    ZRBvolNormLevel
AddDebugText "ZRBrollingSound "&   ZRBrollingSound
AddDebugText "ZRBPitchTunning "&     ZRBPitchTunning
AddDebugText "ZRBrampSoundballchan "&    ZRBrampSoundballchan
AddDebugText "ZRBrampVolNormLevel "&       ZRBrampVolNormLevel
AddDebugText "ZRBrampRollingSound "&      ZRBrampRollingSound
AddDebugText "ZRBrampPitchTunning "&       ZRBrampPitchTunning
AddDebugText "ZRBwireVolNormLevel "&    ZRBwireVolNormLevel
AddDebugText "ZRBwireRollingSound "&       ZRBwireRollingSound
AddDebugText "ZRBwirePitchTunning "&      ZRBwirePitchTunning


    RollingBallUpdateTimer.set true,50
end sub


'called when creating a ball (PlungerKicker ?)
'zbrcreator=trigger/kicker
'zbrtriggheight=height of the trigger (default to 0)
Sub addTrackedBall(zbrcreator)
    addTrackedBallHeight zbrcreator,0.0
end sub
Sub addTrackedBallHeight(zbrcreator,zbrcreatorheight)
    dim j , tmpfoundindex ,tmpball

    RollingBallUpdateTimer.set false

   set tmpball = xBAM_BallCloseTo(zbrcreator.x, zbrcreator.y,zbrcreatorheight)
'AddDebugText zbrcreator.x&"  "&zbrcreator.y
    if (tmpball is nothing) then
AddDebugText "BUUGGGGGGGGG xBAM_BallCloseTo"
end if
tmpfoundindex=-1

    For j = 1 To 20
        if (ZRBtrakedSoundBalls(j) is nothing) then
            if (tmpfoundindex=-1) then
                tmpfoundindex = j
            end if
        else
                if ( ((tmpball.PositionGlobal.x-ZRBtrakedSoundBalls(j).PositionGlobal.x)^2+(tmpball.PositionGlobal.y-ZRBtrakedSoundBalls(j).PositionGlobal.y)^2+(tmpball.PositionGlobal.z-ZRBtrakedSoundBalls(j).PositionGlobal.z)^2)<ZRBsearchshifterror ) then
                    tmpfoundindex=-2
AddDebugText "cleanedc->"&j&" "& ((tmpball.PositionGlobal.x-ZRBtrakedSoundBalls(j).PositionGlobal.x)^2+(tmpball.PositionGlobal.y-ZRBtrakedSoundBalls(j).PositionGlobal.y)^2+(tmpball.PositionGlobal.z-ZRBtrakedSoundBalls(j).PositionGlobal.z)^2)   
                end if
        end if
    Next

            if (tmpfoundindex>-1) then
                set ZRBtrakedSoundBalls(tmpfoundindex) =   tmpball
AddDebugText "addc->"&tmpfoundindex&" "& ((tmpball.PositionGlobal.x-ZRBtrakedSoundBalls(tmpfoundindex).PositionGlobal.x)^2+(tmpball.PositionGlobal.y-ZRBtrakedSoundBalls(tmpfoundindex).PositionGlobal.y)^2+(tmpball.PositionGlobal.z-ZRBtrakedSoundBalls(tmpfoundindex).PositionGlobal.z)^2)
            end if

    RollingBallUpdateTimer.set true,50
end Sub

'called when creating a ball is on metal ramp
'zbrtrigg=trigger
'zbrtriggheight=height of the trigger (default to 0)
Sub addWireRampTrackedBall(zbrtrigg)
    addWireRampTrackedBallHeight zbrtrigg,0.0
end sub
Sub addWireRampTrackedBallHeight(zbrtrigg,zbrtriggheight)
    dim j  , tmpfoundindex ,tmpball

    RollingBallUpdateTimer.set false


   set tmpball = xBAM_BallCloseTo(zbrtrigg.x, zbrtrigg.y,zbrtriggheight)
'AddDebugText zbrtrigg.x&"  "&zbrtrigg.y
    if (tmpball is nothing) then
AddDebugText "BUUGGGGGGGGG xBAM_BallCloseTo"
end if
tmpfoundindex=-1

    For j = 1 To 20
        if (ZRBwireSoundBalls(j) is nothing) then
            if (tmpfoundindex=-1) then
                tmpfoundindex = j
            end if
        else
                if ( ((tmpball.PositionGlobal.x-ZRBwireSoundBalls(j).PositionGlobal.x)^2+(tmpball.PositionGlobal.y-ZRBwireSoundBalls(j).PositionGlobal.y)^2+(tmpball.PositionGlobal.z-ZRBwireSoundBalls(j).PositionGlobal.z)^2)<ZRBsearchshifterror ) then
                    tmpfoundindex=-2
               AddDebugText "cleanedw->"&j&" "& ((tmpball.PositionGlobal.x-ZRBwireSoundBalls(j).PositionGlobal.x)^2+(tmpball.PositionGlobal.y-ZRBwireSoundBalls(j).PositionGlobal.y)^2+(tmpball.PositionGlobal.z-ZRBwireSoundBalls(j).PositionGlobal.z)^2)
                end if
        end if
    Next

            if (tmpfoundindex>-1) then
                set ZRBwireSoundBalls(tmpfoundindex) =   tmpball
               AddDebugText "addw->"&tmpfoundindex&" "& ((tmpball.PositionGlobal.x-ZRBwireSoundBalls(tmpfoundindex).PositionGlobal.x)^2+(tmpball.PositionGlobal.y-ZRBwireSoundBalls(tmpfoundindex).PositionGlobal.y)^2+(tmpball.PositionGlobal.z-ZRBwireSoundBalls(tmpfoundindex).PositionGlobal.z)^2)
            end if

    RollingBallUpdateTimer.set true,50
end Sub



'to force a remove for wire sound in some case
'zbrtrigg=trigger
'zbrtriggheight=height of the trigger (default to 0)
Sub removeWireRampTrackedBall(zbrtrigg)
    removeWireRampTrackedBallHeight zbrtrigg,0.0
end sub
Sub removeWireRampTrackedBallHeight(zbrtrigg,zbrtriggheight)
    dim j,tmpball

'AddDebugText "remove wire " &zbrtrigg.x&"  "&zbrtrigg.y

    RollingBallUpdateTimer.set false

        For j = 1 To 20
            if not(ZRBwireSoundBalls(j) is nothing) then
                set tmpball=ZRBwireSoundBalls(j)
                if ( ((tmpball.PositionGlobal.x-zbrtrigg.x)^2+(tmpball.PositionGlobal.y-zbrtrigg.y)^2+(tmpball.PositionGlobal.z-zbrtriggheight)^2)<ZRBsearchshifterror ) then
                    set ZRBwireSoundBalls(j)=nothing
AddDebugText "delw "&j&"  "&(((tmpball.PositionGlobal.x-zbrtrigg.x)^2+(tmpball.PositionGlobal.y-zbrtrigg.y)^2+(tmpball.PositionGlobal.z-zbrtriggheight)^2))
                else
AddDebugText "whattttttt"  &tmpball.PositionGlobal.x&"  "&tmpball.PositionGlobal.y&"  "&tmpball.PositionGlobal.z&"-->"&(((tmpball.PositionGlobal.x-zbrtrigg.x)^2+(tmpball.PositionGlobal.y-zbrtrigg.y)^2+(tmpball.PositionGlobal.z-zbrtriggheight)^2))
                end if
            end if
        Next



    RollingBallUpdateTimer.set true,50

end sub



'called by drain_hit
'zbrdestroyer=trigger/kicker
'zbrdestroyerheight=height of the trigger (default to 0)
Sub deleteTrackedBall(zbrdestroyer)
    deleteTrackedBallHeight zbrdestroyer,0.0
end sub
Sub deleteTrackedBallHeight(zbrdestroyer,zbrdestroyerheight)
    dim j,tmpball

    RollingBallUpdateTimer.set false

        For j = 1 To 20
            if not(ZRBtrakedSoundBalls(j) is nothing) then
                set tmpball=ZRBtrakedSoundBalls(j)
                if ( ((tmpball.PositionGlobal.x-zbrdestroyer.x)^2+(tmpball.PositionGlobal.y-zbrdestroyer.y)^2+(tmpball.PositionGlobal.z-zbrdestroyerheight)^2)<ZRBsearchshifterror ) then
                    set ZRBtrakedSoundBalls(j)=nothing
AddDebugText "del "&j&"  "&(((tmpball.PositionGlobal.x-zbrdestroyer.x)^2+(tmpball.PositionGlobal.y-zbrdestroyer.y)^2+(tmpball.PositionGlobal.z-zbrdestroyerheight)^2))

                end if
            end if
        Next



    RollingBallUpdateTimer.set true,50

end sub


function stillBallOnWire()
    dim j,tmpball

  stillBallOnWire=false

        For j = 1 To 20
        if not(ZRBwireSoundBalls(j) is nothing) then
            set tmpball=ZRBwireSoundBalls(j)

            if (tmpball.PositionGlobal.z>=ZRBrampHeight) then
'AddDebugText "wire "&j&" "&tmpball.PositionGlobal.z
                stillBallOnWire=true
            else
'AddDebugText "nowire "&j&" "&tmpball.PositionGlobal.z
                set ZRBwireSoundBalls(j)=nothing
            end if
        end if
    Next
end Function


Function zfunPan(ball) ' Calculates the pan for a ball based on the X position on the table.
    Dim tmp
    tmp = ball.PositionGlobal.x * 2 / ZRBtablewide-1
    If tmp > 0 Then
        zfunPan = (tmp ^10)
    Else
        zfunPan = (-((- tmp) ^10))
    End If
End Function

Function zfunPitch(ball) ' Calculates the pitch of the sound based on the ball speed
    zfunPitch = round(100+zfunBallVel(ball)/4)
    if (zfunPitch>120) then
        zfunPitch=120
    end if
End Function


Function zfunBallVel(ball) 'Calculates the ball speed
    'yes we don't use the Z that we want
        zfunBallVel = INT(  SQR(  (ball.velocity.x^2 + ball.velocity.y^2)   )/ZRBvelTuning )
    if (zfunBallVel>zmaxspeedworldrecord)   then
        zmaxspeedworldrecord    =    zfunBallVel
            AddDebugText "speedworldrecord "& zmaxspeedworldrecord
        end if
End Function


This is the code / sound of the ball rolling(created by Smoke),to be entered in FP,but you need to add these:
0) I hope I haven't forgotten something
1)
Added a Timer and rename it "RollingBallUpdateTimer"
2)
In "FuturePinball_BeginPlay()" added this "initTrakedSoundBalls()",which is the start code of the RollingSounds
3) In all the kickers on the table added the code in red, which destroy and create a ball..here is an example in:

Sub CreateNewBall()
addTrackedBall(PlungerKicker)
PlungerKicker.CreateBall
BallsOnPlayfield = BallsOnPlayfield + 1
PlungerKicker.SolenoidPulse
End Sub

OR

sub Kicker2_hit()
deleteTrackedBall(Kicker2)
Kicker2.DestroyBall
Timer3.Interval = 500
Timer3.Enabled = TRUE
end sub

Sub Timer3_Expired()
Timer3.Enabled = FALSE
addTrackedBall(Kicker2)
Kicker2.CreateBall
Kicker2.SolenoidPulse
end sub

OR

Sub Timer3_Expired()
Timer3.Enabled = FALSE
addTrackedBall(KickerWild)
KickerWild.CreateBall
KickerWild.SolenoidPulse
end sub

4) This is 2 part where you could choose your preferences....schoose the volume....schoose the type of sound,but.....
two sectors are fundamental to avoid that all the code works by being careful with the music channel "ZRBsoundballchan = 8"and "ZRBrampSoundballchan = 8"......I set them to 8, the last available channel the FP, since the first 7 can be used for your music on the table. (there is another way to overcome this limit of 8 channels ... but for those who want to know more, just ask)


Code:
' These are the options for ball rolling sounds
Const SelectSound = "zfx_ballrolling0" '"zfx_ballrolling"  or "zfx_ballrolling2" or "zfx_ballrolling2Loud" or "zfx_ballrolling2Louder" or "zfx_ballrolling2Loudest"
Const SoundVolume = 1.0 ' set volume between 0 and 1.  You can also tweak below as you wish

'*****************************
'*****************************
' TO ADJUST TO YOUR NEEDS  in the importing script
'*****************************
'*****************************
ZRBrampHeight=45
ZRBtablewide = 520

ZRBsoundballchan = 8
ZRBvolNormLevel =SoundVolume'  0.40
ZRBrollingSound=SelectSound
ZRBPitchTunning=-40

ZRBrampSoundballchan =8  'set to -1 to disable rampsound roll
ZRBrampVolNormLevel = 0.80
ZRBrampRollingSound="zfx_ballrolling1" '"zfx_ballrolling"  or "zfx_ballrolling2" or "zfx_ballrolling2Loud" or "zfx_ballrolling2Louder" or "zfx_ballrolling2Loudest"
ZRBrampPitchTunning=40 '20

ZRBwireVolNormLevel = 2.0
ZRBwireRollingSound="zfx_ballrolling" '"zfx_ballrolling"  or "zfx_ballrolling2" or "zfx_ballrolling2Loud" or "zfx_ballrolling2Louder" or "zfx_ballrolling2Loudest"
ZRBwirePitchTunning=10 '60


5) Add sounds.... in Editor FP / Table / MusicManager .... this sound
 

Attachments

  • rollersound.zip
    557.4 KB · Views: 106
Last edited by a moderator:

Gimli

Pinball Master
It may not matter but I believe you should stop tracking just BEFORE you destroy ball
Code:
sub Kicker2_hit()
deleteTrackedBall(Kicker2)
Kicker2.DestroyBall
Timer3.Interval = 500
Timer3.Enabled = TRUE
end sub
 

Paolo

No Bam no Play
Chat Moderator
Site Supporters
Here is another example of Bam's code, regarding the custom ball.

This type of code is used to create two personalized balls and, of course, a normal ball, via a button, which activates the three choice options.
In addition to having the possibility to create the custom ball,in the scrolling camera( CreateCustomBall(name of kicker)),you can also create a custom ball in the fixed one,( CreateCustomCaptiveBall(name of kicker)).

Note: the "wild" name, must be replaced with the name chosen for your custom ball.
Note: the "name of the texture",I have to rename it the name of your texture 1 and 2.
Note: the value "192,192, 192" it is the color that the ball can assume.

Code:
'------------------------------------------------------------------
'Custom Ball
'------------------------------------------------------------------

Dim  WildBall_1, WildBall_2          
WildBall_1   = xBAM.BallManager.DefineCustomBall(192,192, 192, "name of the texture 1", "334", "269")
WildBall_2   = xBAM.BallManager.DefineCustomBall(192, 192, 192, "name of the texture 2", "334", "269")

Dim WildBallType
WildBallType = 0 ' normal ball
WildBallType = WildBall_1



Sub CreateCustomBall(source)' x CreateBall
  Dim bi
  Set bi = xBAM.BallManager.CreateCustomBall(WildBallType)
  source.CreateBall bi.Red, bi.Green, bi.Blue
End Sub



Sub CreateCustomCaptiveBall(source)' x CreateCaptiveBall
  Dim bi
  Set bi = xBAM.BallManager.CreateCustomBall(WildBallType)
  source.CreateCaptiveBall bi.Red, bi.Green, bi.Blue
End Sub


Sub UpdateWildBall(ball)
   ball.Name = WildBallType
End Sub

Sub ChangeWildball
    If WildBallType = 0 Then
        WildBallType = WildBall_1
   ElseIf WildBallType = WildBall_1 Then
        WildBallType = WildBall_2
   ElseIf WildBallType = WildBall_2 Then
        WildBallType = 0
    End IF
    AddDebugText WildBallType
    xBAM.EnumBalls 100, 0, "UpdateWildBall"
End Sub

what needs?....for to work all: which I will explain step by step

1)
create 2 surfaces, and put them off the table (in the highest part if you want)
2)create three textures, 256x256......1)name of texture that you created.....2)....334....3)....269
3)create a KeyCode for choosing the preferred custom
4)In all the kickers on the table added this code.... CreateCustomBall(name of kicker) or CreateCustomCaptiveBall(name of kicker)

Step1:

Create 2 surface,and rename them as you like, Bam interacts with the inserted textures.....and enter your textures .
pic1.JPG




Step2:
you have to have three textures, to create the custom ball, I can insert two of them, they are the ones I use, but you have to create the third yourself. So....create your favorite texture, and after completing it,you use the tool invert the color.in step one, you can see the textures inserted.
you can change the 334 to 269, and you will see another effect.here you can see,

here------>http://www.gopinball.com/forum/viewtopic.php?f=86&t=5583
you can see other custom balls, and get an idea of how to create your custom ball, by downloading the various packages

Step3:
In the script below this,FuturePinball_KeyPressed(ByVal KeyCode) add this code than an "F" key, to change the texture,but you can change the key code if you want

Code:
If (KeyCode = "33") Then  'key F
   ChangeWildball
End if

Step4:
Add this to every kicker

Sub CreateNewBall()
CreateCustomBall(PlungerKicker)
PlungerKicker.CreateBall------------------>this must be eliminated
BallsOnPlayfield = BallsOnPlayfield + 1
PlungerKicker.SolenoidPulse
End Sub

OR

sub Kicker2_hit()
Kicker2.DestroyBall
Timer3.Interval = 500
Timer3.Enabled = TRUE
end sub

Sub Timer3_Expired()
Timer3.Enabled = FALSE
CreateCustomBall( Kicker2)
Kicker2.CreateBalll------------------>this must be eliminated
Kicker2.SolenoidPulse
end sub

OR

Sub Timer3_Expired()
Timer3.Enabled = FALSE
CreateCustomBall( KickerWild)
KickerWild.CreateBalll------------------>this must be eliminated
KickerWild.SolenoidPulse
end sub

Step5:
try to change these values, "192,192, 192" to have a different color, but be careful, the result can change the current color previously given to your created texture.



Here are the textures to understand how to proceed,if you have any questions or problems say it openly, we are here to help.
 

Attachments

  • texture custom ball.zip
    113.8 KB · Views: 90
Last edited:

AnonTet

Pinball Hall of Famer
Site Supporters
@ravarcade shared something with me recently that I don't think he would mind me posting here and his explanation:

Here is how it works in FP.
When you press flipper key and in script you execute SolenoidOn FP sets flipper rotation speed.
When flipper reaches max rotation, that rotation speed is set to ~0.1%. (Almost no force used to hold flipper up).
When ball hits flipper, flipper don't move, because there is huge difference between masses. Flipper mass = 20 000, Ball mass = 18.

In BAM menu you can change flipper mass for example you can set it to 1. Now you can check what will happened with flipper when you hold flipper key and ball hits flipper.
You will see, how far flipper will rotate and how slow it will go up and return do desired position.

So, to achieve desired EOS effect, you can't just change flipper omega, you need to change flipper mass too.
Also, you need to "reset" force used to move flipper up. (Call SolenoidOn). ... But with default force it will for most time throw away ball.
 

Attachments

  • fp-eos.fpt
    224.5 KB · Views: 84

GeorgeH

Flippered Out
Staff member
Site Supporters
@ravarcade shared something with me recently that I don't think he would mind me posting here and his explanation:

I decided to try the EOS (End of Stroke) flippers and to my thinking the performance of the flippers is rather odd. I decided to add Gimli's and my code for dynamic flippers to it. I honestly didn't think it would work because there is some code for flipper omega in Rav's code and I figured there might be conflicts with the omega in Gimli's and my code. ...But it plays well (as far as I have tested it anyway). The flippers perform much like the regular dynamic flippers. ...But if you use the manual ball roller and drop the ball on a raised flipper, the flipper moves a small amount. Maybe @Gimli or @ravarcade can figure out if I have it coded correctly but it seems to perform OK with the dynamic flippers. I have attached Rav's demo table with the DF code added.

I tried it on my latest version of "Phantom of the Opera" and I am sure some changes would be needed to use Rav's EOS with DF. The change makes the flippers move way too much when the ball hits them while stationary. It is probably worth seeing if we can get this to work.
 

Attachments

  • ```fp-eos with DF.fpt
    227.5 KB · Views: 74
Last edited:

AnonTet

Pinball Hall of Famer
Site Supporters
To Mods:
Before anything else, since this is development and not examples per se, shouldn't this be moved to an EOS development thread or something? When a solid base is reached then put it here?

Continuing...
So, Since we are all into Christmas spirit and all that why not share my version of the thing.

A few notes:
- PLEASE, do tell me what I'm doing wrong.
- Ignore all the debugtext, comments and remember it's all wip.

To give an overview of what I would like to see in FP:
- Static flippers react differently to moving flippers. So I added some conditions for that.

- The flipper "speed" cannot be tracked so, I added some code of mine to try and calculate that. The point being we need to choose between bounce and nobounce control. I left that enabled in debug mode. So a fast ball coming down with the flipper static or moving should give different bounce back

- It's still impossible in my opinion, to stall the ball by timing the flipper to hit the ball at exact same "speed" when the ball comes down those lanes. Not that it's easy in real life either... This is where EOS kicks in I think. It really helps by giving some "slack" so we can get the timing right. The rest is a balance between noBounce and Bounce control values but it will be a balance for the time coming.

-You should also be able to pass the ball from one flipper to another but this depends as usual on flipper position against slingshots. But it's doable. You can and also to ball tapping but not yet on the level of VPX according some videos. But I'm also not skilled/fast enough with the buttons. EOS SHOULD help here but I at least am not there yet.

- I'm working on balance the angle shots with center top shots without the side effect of the "super strong hit" on the ball near the tip but one can work around that under the right conditions. The ideal is obviously, be able to aim everywhere from a cradled ball.

So yeah, I'm aiming too damn high :whistle: :banghead:

/edit
new attach. I've messed up the debug so, new ball speed taking into account both ball and flipperext.vball speeds registers as per original code.

The difference with the flipper at max angle or moving towards max angle should be clearly visible now. There's much more control now.

/edit2
The physics times were all over the place. Should be good now so, download again if you had download before.
The plunger is set to low for this table so don't forget to change that. (and the flipperswing var).
 

Attachments

  • EOS_test.fpt
    231.5 KB · Views: 77
Last edited:

GeorgeH

Flippered Out
Staff member
Site Supporters
@AnonTet

I experimented with your version of the demo table for a while. The flippers move too much when hit with the ball in a raised position. I don't understand the code so I can't help. I tried changing some of the parameters but it didn't help. It will take someone who knows code better than I.

George
 

AnonTet

Pinball Hall of Famer
Site Supporters
@GeorgeH
Just updated. try again please.

BTW, I obviously can't guarantee that it works the same across all the tables, because of what's discussed before. So I recommend messing up only with the flipper angles, and the bounce/nobounce values for start.

It's 4:30 am... I need to sleep and will be gone for the weekend so I can't do much until monday.
 

jamosb

Pinball Wizard
Anyone have script examples of how to remove the top rails from the table in cabinet mode. I can delete them with the editor but I thought there was a way to remove them with script if in cabinet mode that way I do not need two different versions of my table?
 

GeorgeH

Flippered Out
Staff member
Site Supporters
Anyone have script examples of how to remove the top rails from the table in cabinet mode. I can delete them with the editor but I thought there was a way to remove them with script if in cabinet mode that way I do not need two different versions of my table?
The only way I can think of doing that is to use BAM's texture swapping code. You would use the existing texture and swap it with Polygame's invisible texture. If you want to see how to set it up, I did it on my version of Space Shuttle. There is a surface on the right side of the apron that I switch between visible and invisible.
 

GeorgeH

Flippered Out
Staff member
Site Supporters
Ok thanks what is the code to check to see if you are in Cabinet mode?
xBAM.Camera.AspectRatio < 1.0 ' screen is wide (the end user selected either 0 or 180 degrees rotation)
xBAM.Camera.AspectRatio > 1.0 ' screen is tall (the end user selected either 90 or 270 degrees rotation)

I wrote a tutorial on switching between 2 overlays using the above code but you can use the same code to switch between the visible and invisible objects:


My version of Space Shuttle also includes this code to switch between overlays.
 

jamosb

Pinball Wizard
Ok thanks I will try to figure it out updating some FP tables that do not have BAM that are free to modify. Adding BAM Physics/Rolling Ball Sounds to them.
 

jamosb

Pinball Wizard
xBAM.Camera.AspectRatio < 1.0 ' screen is wide (the end user selected either 0 or 180 degrees rotation)
xBAM.Camera.AspectRatio > 1.0 ' screen is tall (the end user selected either 90 or 270 degrees rotation)

I wrote a tutorial on switching between 2 overlays using the above code but you can use the same code to switch between the visible and invisible objects:


My version of Space Shuttle also includes this code to switch between overlays.
So why do you have 2 different versions of the same table for your downloads is that for early bam?
 

Gimli

Pinball Master
Anyone have script examples of how to remove the top rails from the table in cabinet mode. I can delete them with the editor but I thought there was a way to remove them with script if in cabinet mode that way I do not need two different versions of my table?
xBAM.VisibleCabParts = 0

Try different numbers from - 5 to 5
each number removes some or all of the table
 

jamosb

Pinball Wizard
so something like this:
If xBAM.Camera.AspectRatio > 1.0 and BAM_VERSION >= 198 then xBAM.VisibleCabParts = 0
 
Last edited:

jamosb

Pinball Wizard
What is the general way now to add rolling ball sounds? I see that bam installs the rolling ball script now so I am just calling it from the table script instead of inserting smokes script inline. I think I tried the inline mode and could not get the sounds to work.
 

jamosb

Pinball Wizard
Ok got it working good with inline code just changed the ball sound to rollingb2 to make it a bit louder. Thanks all will release this mod soon.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
    There are no messages in the chat. Be the first one to say Hi!
    Top