Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '***********************
- '* Scared Stiff for VPX
- '* By Shoopity
- '* With HEAVY borrowing from Dozer's Mod of JPSalas' table
- '***********************
- 'Shoopity, Hauntfreaks, ICPJuggla, nFozzy, Arngrim, Clark Kent
- 'Some SFX from Knorr, JP, Clark Kent
- 'Ramp Textures by Flupper1
- 'Flare flasher image by LoadedWeapon
- 'New DT Backdrop by Batch
- 'EOStimer script based on LFHM by WRD1972 and Rothbauer
- Option Explicit
- Randomize
- 'Version 1.31
- 'Replaced a few light images with better quality ones (new images are FlashAmbient512 and FlashQuad512. Use them, should be good common resources)
- 'Proper soundFX gain pass
- 'Added animated scorecard
- 'Version 1.3 Changelog by nFozzy
- 'Optimization
- '-new GI in 3 flavors: Soft White, Cool White, and Colorized
- 'New Boogiemen
- 'New physics
- 'Added (limited) Support for pre-production roms with the kickback
- '-The aux light board isn't emulated properly, so crate and deadhead LEDs are not working atm.
- '-these roms have very early code and therefore simplified game rules.
- 'Notes:
- 'You can change the GI in-game by hitting the Right magnasave while holding down the left magnasave
- 'The dancing boogiemen feature must be toggled on in the ROM. It's Feature Adjustment 32.
- 'STUTTERING ON OLDER VIDEO CARDS: please consider utilizing 'max texture dimensions' in the video options
- '-this table utilizes an 8K(!) Playfield and may overload your ram as a result!
- Dim GIselect, SoundLevelMult
- 'OPTIONS
- '=======================
- 'Rom select - uncomment one
- 'Const cGameName = "SS_01" 'prototype rom with kickback 'works, missing a few lamps though
- Const cGameName = "SS_15" 'latest rom
- 'Select type of GI
- GiSelect = 3 '0 = Random '1 = #44 incandescent '2 = Cool Whites '3 = White '4 = Colorized GI
- 'Table SFX multiplier - may cause some normalization
- 'make sure Table Sound Effect Volume (under Table Properties) is already at 100 before increasing this
- SoundLevelMult = 1
- 'Optional mod for extra lamps in the skulls (default 0)
- const SkullLEDMod = 0
- 'Single-Screen FS support (Puts spider on the playfield)
- const SingleScreenFS = 0
- '*************************************************************
- 'Debug stuff
- Dim DebugFlippers : DebugFlippers = False
- dim aDebugBoxes : aDebugBoxes = array(TBflipper, tbl, tbll, TB1, tbpl, TB2, TBbounces,TBwr)
- Sub DebugF(input)
- dim x
- if input = 5 then for each x in aDebugBoxes : x.visible = cBool(input) : next : exit sub
- input = cbool(input)
- debugflippers = cbool(input)
- 'FlippersEnabled = DebugFlippers 'fastflips support
- ' TiltSol input
- 'RollingTimer.Enabled = Not Input
- destroyer.enabled = input
- Drain.enabled = not input
- 'Sw10.enabled = not input 'space station specific, disable trough
- 'if not input then Sw10.kick -10, 45 'space station specific
- for each x in aDebugBoxes : x.visible = input : next
- end sub
- debugf 0
- 'debugf 5
- sub GimmeF() : kl.createsizedballwithmass 25, ballmass : kl.kick 0, 5 : debugf 1 : end Sub
- sub Gimme() : kr.createsizedballwithmass 25, ballmass : kr.kick 0, 5 : debugf 1 : end Sub
- sub GimmeC() : kFeedHole.createsizedballwithmass 25, ballmass : kFeedHole.kick 270, 15 : debugf 1 : end Sub
- sub GimmeS() : kFeedShooter.createsizedballwithmass 25, ballmass : kFeedShooter.kick 180, 1 : debugf 1 : end Sub
- '________________________________________________________
- ' _____ ______
- ' / ' / , /
- '---/__-------/------------__----/--------__----__---_/_-
- ' / / / / ) / /___) (_ ` /
- '_/_________/____/______/___/__/_______(___ __(__)__(_ __
- ' /
- 'Setup - /
- 'Four Kickers named kiL, kL, kR, kiR placed in inlanes and on flippers
- 'Primitive FlipStick (make it a flat vertical stick with >1 opacity)
- 'Timer "FlipTest2"
- 'textbox "tb2"
- dim FTSball : set FTSball = Nothing
- dim FlipDir, FlipDelayV
- Sub FTS(dir, input) 'hopefully more accurate flipper test sub
- debugf 1
- ' FlipperLagCompensation 0 'remember to set this
- dim x : x = 0
- FlipDir = dir
- FlipDelayV = input
- Select Case dir
- case 0 : Set FTSball = kil.createsizedballwithmass(25, ballmass) : kil.kick 0, 0
- case 1 : Set FTSball = Kl.CreateSizedBallWithMass(25, ballmass) : Kl.Kick 2, 5 : SolBFlipper True : x = 2000
- case 2 : Set FTSball = kR.CreateSizedBallWithMass(25, ballmass) : Kr.Kick -2, 5 : SolBFlipper True : x = 2000
- case Else : Set FTSball = kir.createsizedballwithmass(25, ballmass) : kir.kick 0, 0 : flipdir = 3' : SolBFlipper True : x = 2000
- End Select
- if x > 0 then
- FlipDelayT1.Interval = x
- FlipDelayT1.Enabled = 1
- Else
- FlipTestV input 'fire flipper after a delay
- end if
- End Sub
- Sub FlipDelayT1_Timer(): SolBFlipper False : FlipTestV FlipDelayV : me.enabled = 0 : End Sub
- Sub SolBFlipper(enabled)
- On Error Resume Next
- select case FlipDir
- case 2, 3 : SolRFlipper enabled : x = (FTSball.x-RightFlipper.X) / (EndPointR - rightflipper.x)
- case else : SolLFlipper enabled : x = (FTSball.x-LeftFlipper.X) / (EndPointL - LeftFlipper.x)
- end select
- if not enabled then exit sub
- FlipStick.x = FTSball.x : FlipStick.Visible = True
- x = RoundPercent(x)
- tb2.text = tb2.text & vbnewline & "%" & x' & vbnewline & " flip: " & LeftFlipper.x & " ball:" & FTSball.x
- End Sub
- Function RoundPercent(input) : RoundPercent = mid(input, 1, 7)*100 : End Function 'round and mult by 100 for percentage
- dim FlipInputV
- Sub FlipTestV(input)
- tb2.text = " " & input & " MS"
- FlipTest2.Interval = input : FlipTestOn = True
- FlipTest2.Enabled = 1
- End Sub
- dim FlipTestOn
- Sub FlipTest2_Timer()
- if FlipTestOn then
- SolBflipper True : me.interval = 100 : flipteston = False
- Else
- SolBflipper False
- me.enabled = 0
- end if
- End Sub
- '**********************************
- '******************************************************************************
- ' _______. ______ __ __ .__ __. _______ _______ ___ ___
- ' / | / __ \ | | | | | \ | | | \ | ____|\ \ / /
- ' | (----`| | | | | | | | | \| | | .--. | | |__ \ V /
- ' \ \ | | | | | | | | | . ` | | | | | | __| > <
- '.----) | | `--' | | `--' | | |\ | | '--' | | | / . \
- '|_______/ \______/ \______/ |__| \__| |_______/ |__| /__/ \__\
- '
- '******************************************************************************
- '10.4 playsound args - name,loopcount,volume,pan,randompitch,pitch,UseExisting,Restart,Fade
- 'SoundFX with Falloff subs
- '**************************
- Sub Rubbers_Hit(idx) 'bands, native falloff
- Playsound RandomBand, 0, LVL(Vol(ActiveBall)*1 ), Pan(ActiveBall)*50, 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall)
- End Sub
- ' Post rounds
- Sub Posts_Hit(idx)
- FalloffSimple r1, r2, r3, r4, "Posts"
- PlaySound RandomPost, 0, LVL(Vol(ActiveBall)*1 ), Pan(ActiveBall)*50, 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
- End Sub
- Sub Frogs_Hit(idx)
- FalloffSimple f1, f2, f3, f4, "Frogs"
- PlaySound SoundFX("target",DOFTargets), 0, LVL(Vol(ActiveBall)*1.5), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, Fade(ActiveBall)
- End Sub
- Sub Targets_Hit (idx)
- FalloffSimple t1, t2, t3, t4, "Targets"
- PlaySound SoundFX("target",DOFTargets), 0, LVL(Vol(ActiveBall)*1.5), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, Fade(ActiveBall)
- ' PlaySound SoundFX("targethit",DOFTargets), 0, LVL(Vol(ActiveBall)*1.5), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, Fade(ActiveBall)
- End Sub
- 'SLeeves
- Sub zCol_PostSleeves_Hit()
- FalloffSimple s1, s2, s3, s4, "Sleeves"
- PlaySound RandomPost, 0, LVL(Vol(ActiveBall)*1 ), Pan(ActiveBall)*50, 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
- End Sub
- 'Other Sounds
- '**************************
- 'Sub Prim_CrateSubmarine_hit()
- ' PlaySound "WoodHitAluminium", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
- 'end sub
- 'ramp sounds
- Sub RampSounds_Hit(idx)
- PlaySound "ramp_hit1", 0, LVL(Vol(ActiveBall)/2), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
- WireRampOn True 'Ramp SFX Tracking, True = Plastic
- end sub
- Sub RampSounds2_Hit(idx)
- If activeball.vely < -10 then
- PlaySound "ramp_hit2", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall), 0, Pitch(ActiveBall)*10, 1, 0, Fade(ActiveBall)
- WireRampOn True 'Ramp SFX Tracking, True = Plastic
- Elseif activeball.vely > 3 then
- PlaySound "PlayfieldHit", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
- End If
- end sub
- Sub Metals_Medium_Hit (idx)
- PlaySound "metalhit_medium", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
- End Sub
- Sub Metals2_Hit (idx)
- PlaySound "metalhit2", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
- End Sub
- Sub ApronWall_Hit() 'apron hit
- PlaySound "WoodHitAluminium", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall) / 2, 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
- end sub
- Sub Gates_Hit (idx)
- PlaySound "gate4", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
- End Sub
- 'SFX (string) functions -SFX - Posts 1-5, Bands 1-4 and 11,22,33,44
- Function RandomPost() : RandomPost = "Post" & rndnum(1,5) : End Function
- Function RandomBand()
- dim x : x = rndnum(1,4)
- if BallVel(activeball) > 30 then
- RandomBand = "Rubber" & x & x 'ex. Playsound "Band44"
- else
- RandomBand = "Rubber" & x 'ex. Playsound "Band4"
- End If
- End Function
- 'Flipper collide sound
- Sub LeftFlipper_Collide(parm) : RandomSoundFlipper() : End Sub
- Sub RightFlipper_Collide(parm) : RandomSoundFlipper() : End Sub
- Sub RandomSoundFlipper()
- dim x : x = RndNum(1,3)
- PlaySound "flip_hit_" & x, 0, LVL(Vol(ActiveBall) ), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall)
- End Sub
- ' Ball Collision Sound
- Sub OnBallBallCollision(ball1, ball2, velocity) : PlaySound("fx_collide"), 0, LVL(Csng(velocity) ^2 / 2000), Pan(ball1), 0, Pitch(ball1), 0, 0,Fade(ball1) : End Sub
- '*****************************************
- ' JP's VP10 Rolling Sounds
- '*****************************************
- Const tnob = 9 ' total number of balls
- ReDim rolling(tnob)
- InitRolling : Sub InitRolling : Dim i : For i = 0 to tnob : rolling(i) = False : Next : End Sub
- Sub RollingTimer_Timer
- 'On Error Resume Next
- Dim BOT, b : BOT = GetBalls
- For b = UBound(BOT) + 1 to tnob ' stop the sound of deleted balls
- rolling(b) = False
- StopSound("tablerolling" & b)
- Next
- If UBound(BOT) = -1 Then Exit Sub ' exit the sub if no balls on the table
- For b = 0 to UBound(BOT) ' play the rolling sound for each ball
- If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
- rolling(b) = True
- PlaySound("tablerolling" & b), -1, Vol(BOT(b) )*0.3, Pan(BOT(b) )*3, 0, BallPitch(BOT(b)), 1, 0,Fade(BOT(b))*3
- Else
- If rolling(b) = True Then
- StopSound("tablerolling" & b)
- rolling(b) = False
- End If
- End If
- Next
- End Sub
- Sub StopAllRolling() 'call this at table pause!!!
- dim b : for b = 0 to tnob
- StopSound("tablerolling" & b)
- StopSound("RampLoop" & b)
- StopSound("wireloop" & b)
- next
- end sub
- '=====================================
- ' Ramp Rolling SFX updates nf
- '=====================================
- 'Ball tracking ramp SFX 1.0
- ' Usage:
- '- Setup hit events with WireRampOn True or WireRampOn False (True = Plastic ramp, False = Wire Ramp)
- '- To stop tracking ball, use WireRampoff
- '-- Otherwise, the ball will auto remove if it's below 30 vp units
- 'Example, from Space Station:
- 'Sub RampSoundPlunge1_hit() : WireRampOn False : End Sub 'Enter metal habitrail
- 'Sub RampSoundPlunge2_hit() : WireRampOff : WireRampOn True : End Sub 'Exit Habitrail, enter onto Mini PF
- 'Sub RampEntry_Hit() : If activeball.vely < -10 then WireRampOn True : End Sub 'Ramp enterance
- dim RampMinLoops : RampMinLoops = 4
- dim RampBalls(6,2)
- 'x,0 = ball x,1 = ID, 2 = Protection against ending early (minimum amount of updates)
- '0,0 is boolean on/off, 0,1 unused for now
- RampBalls(0,0) = False
- dim RampType(6) 'Slapped together support for multiple ramp types... False = Wire Ramp, True = Plastic Ramp
- Sub WireRampOn(input) : Waddball ActiveBall, input : RampRollUpdate: End Sub
- Sub WireRampOff() : WRemoveBall ActiveBall.ID : End Sub
- Sub Waddball(input, RampInput) 'Add ball
- dim x : for x = 1 to uBound(RampBalls) 'Check, don't add balls twice
- if RampBalls(x, 1) = input.id then
- if Not IsEmpty(RampBalls(x,1) ) then Exit Sub 'Frustating issue with BallId 0. Empty variable = 0
- End If
- Next
- For x = 1 to uBound(RampBalls)
- if IsEmpty(RampBalls(x, 1)) then
- Set RampBalls(x, 0) = input
- RampBalls(x, 1) = input.ID
- RampType(x) = RampInput
- RampBalls(x, 2) = 0
- 'exit For
- RampBalls(0,0) = True
- RampRoll.Enabled = 1 'Turn on timer
- 'RampRoll.Interval = RampRoll.Interval 'reset timer
- exit Sub
- End If
- if x = uBound(RampBalls) then 'debug
- Debug.print "WireRampOn error, ball queue is full: " & vbnewline & _
- RampBalls(0, 0) & vbnewline & _
- Typename(RampBalls(1, 0)) & " ID:" & RampBalls(1, 1) & "type:" & RampType(1) & vbnewline & _
- Typename(RampBalls(2, 0)) & " ID:" & RampBalls(2, 1) & "type:" & RampType(2) & vbnewline & _
- Typename(RampBalls(3, 0)) & " ID:" & RampBalls(3, 1) & "type:" & RampType(3) & vbnewline & _
- Typename(RampBalls(4, 0)) & " ID:" & RampBalls(4, 1) & "type:" & RampType(4) & vbnewline & _
- Typename(RampBalls(5, 0)) & " ID:" & RampBalls(5, 1) & "type:" & RampType(5) & vbnewline & _
- " "
- End If
- next
- End Sub
- Sub WRemoveBall(ID) 'Remove ball
- dim ballcount : ballcount = 0
- dim x : for x = 1 to Ubound(RampBalls)
- if ID = RampBalls(x, 1) then 'remove ball
- Set RampBalls(x, 0) = Nothing
- RampBalls(x, 1) = Empty
- RampType(x) = Empty
- StopSound("RampLoop" & x)
- StopSound("wireloop" & x)
- end If
- 'if RampBalls(x,1) = Not IsEmpty(Rampballs(x,1) then ballcount = ballcount + 1
- if not IsEmpty(Rampballs(x,1)) then ballcount = ballcount + 1
- next
- if BallCount = 0 then RampBalls(0,0) = False 'if no balls in queue, disable timer update
- End Sub
- Sub RampRoll_Timer():RampRollUpdate:End Sub
- Sub RampRollUpdate() 'Timer update
- dim x : for x = 1 to uBound(RampBalls)
- if Not IsEmpty(RampBalls(x,1) ) then
- if BallVel(RampBalls(x,0) ) > 1 then ' if ball is moving, play rolling sound
- If RampType(x) then
- PlaySound("RampLoop" & x), -1, Vol(RampBalls(x,0) )*0.3, Pan(RampBalls(x,0) )*3, 0, BallPitchV(RampBalls(x,0) ), 1, 0,Fade(RampBalls(x,0) )'*3
- StopSound("wireloop" & x)
- Else
- StopSound("RampLoop" & x)
- PlaySound("wireloop" & x), -1, Vol(RampBalls(x,0) )*0.3, Pan(RampBalls(x,0) )*3, 0, BallPitch(RampBalls(x,0) ), 1, 0,Fade(RampBalls(x,0) )'*3
- End If
- RampBalls(x, 2) = RampBalls(x, 2) + 1
- Else
- StopSound("RampLoop" & x)
- StopSound("wireloop" & x)
- end if
- if RampBalls(x,0).Z < 30 and RampBalls(x, 2) > RampMinLoops then 'if ball is on the PF, remove it
- StopSound("RampLoop" & x)
- StopSound("wireloop" & x)
- Wremoveball RampBalls(x,1)
- End If
- Else
- StopSound("RampLoop" & x)
- StopSound("wireloop" & x)
- end if
- next
- if not RampBalls(0,0) then RampRoll.enabled = 0
- End Sub
- Sub tbWR_Timer() 'debug textbox
- me.text = "on? " & RampBalls(0, 0) & " timer: " & RampRoll.Enabled & vbnewline & _
- "1 " & Typename(RampBalls(1, 0)) & " ID:" & RampBalls(1, 1) & " type:" & RampType(1) & " Loops:" & RampBalls(1, 2) & vbnewline & _
- "2 " & Typename(RampBalls(2, 0)) & " ID:" & RampBalls(2, 1) & " type:" & RampType(2) & " Loops:" & RampBalls(2, 2) & vbnewline & _
- "3 " & Typename(RampBalls(3, 0)) & " ID:" & RampBalls(3, 1) & " type:" & RampType(3) & " Loops:" & RampBalls(3, 2) & vbnewline & _
- "4 " & Typename(RampBalls(4, 0)) & " ID:" & RampBalls(4, 1) & " type:" & RampType(4) & " Loops:" & RampBalls(4, 2) & vbnewline & _
- "5 " & Typename(RampBalls(5, 0)) & " ID:" & RampBalls(5, 1) & " type:" & RampType(5) & " Loops:" & RampBalls(5, 2) & vbnewline & _
- "6 " & Typename(RampBalls(6, 0)) & " ID:" & RampBalls(6, 1) & " type:" & RampType(6) & " Loops:" & RampBalls(6, 2) & vbnewline & _
- " "
- End Sub
- ' *********************************************************************
- ' Ball & Sound Functions
- ' *********************************************************************
- '10.4 playsound args - name,loopcount,volume,pan,randompitch,pitch,UseExisting,Restart,Fade
- '**************** 3D Audio Vp10.4 Functions ****************
- Function Fade(tableobj) ' Fades between front and back of the table (for surround systems or 2x2 speakers, etc), depending on the Y position on the table. "table1" is the name of the table
- Dim tmp
- tmp = tableobj.y * 2 / table1.height-1
- If tmp > 0 Then
- Fade = Csng(tmp ^10)
- Else
- Fade = Csng(-((- tmp) ^10) )
- End If
- End Function
- Function FadeY(Y) ' Fades between front and back of the table (for surround systems or 2x2 speakers, etc), depending on the Y position on the table. "table1" is the name of the table
- Dim tmp
- tmp = y * 2 / table1.height-1
- If tmp > 0 Then
- FadeY = Csng(tmp ^10)
- Else
- FadeY = Csng(-((- tmp) ^10) )
- End If
- End Function
- '**************** Other sound functions ****************
- Function RndNum(min, max)
- RndNum = Int(Rnd() * (max-min + 1) ) + min ' Sets a random number between min and max
- End Function
- Function LVL(input) : LVL = Input * SoundLevelMult : End Function
- Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
- Vol = Csng(BallVel(ball) ^2 / 2000)
- End Function
- Function Vol2(ball1, ball2) ' Calculates the Volume of the sound based on the speed of two balls
- Vol2 = (Vol(ball1) + Vol(ball2) ) / 2
- End Function
- Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
- Dim tmp : tmp = ball.x * 2 / Table1.width-1
- If tmp> 0 Then
- Pan = Csng(tmp ^10)
- Else
- Pan = Csng(-((- tmp) ^10) )
- End If
- End Function
- Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
- Pitch = BallVel(ball) * 20
- End Function
- Function BallVel(ball) 'Calculates the ball speed
- BallVel = INT(SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2) )
- End Function
- Function BallSpeed(ball) 'Calculates the ball speed
- BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
- End Function
- 'new
- Function BallPitch(ball) ' Calculates the pitch of the sound based on the ball speed
- BallPitch = SlopeIt(BallVel(ball), 1, -1000, 60, 10000)
- End Function
- Function BallPitchV(ball) ' Calculates the pitch of the sound based on the ball speed Variation
- BallPitchV = SlopeIt(BallVel(ball), 1, -1000, 60, 30000)
- End Function
- '====ELASTICITY========================================================
- ' _______ ___ __ __ ______ _______ _______
- '| ____| / \ | | | | / __ \ | ____|| ____|
- '| |__ / ^ \ | | | | | | | | | |__ | |__
- '| __| / /_\ \ | | | | | | | | | __| | __|
- '| | / _____ \ | `----.| `----.| `--' | | | | |
- '|__| /__/ \__\ |_______||_______| \______/ |__| |__|
- '======================================================================
- 'This script doesn't track ball angle like Jimmyfinger's script does so it may cause some weird ball movement on glancing shots
- 'Usage - Define a falloff line with two points, and then a string for debug purposes
- 'Falloffn x1,y1,x2,y2, DebugString
- '(x = Input velocity, y = output Coef)
- 'Debug box "TBbounces"
- 'Usage: falloffsimple 1,1, 54,0.5, "Targets"
- 'TODO might add 3 point and 5 point envelopes
- Sub FalloffSimple(X1, Y1, X2, Y2, DebugString) 'Two points
- Dim FinalSpeed : FinalSpeed = BallSpeed(ActiveBall) : if FinalSpeed < X1 then Exit Sub 'Cutoff Low
- Dim BounceCoef : BounceCoef = SlopeIt(FinalSpeed,X1,Y1,X2,Y2)
- if BounceCoef < Y2 then BounceCoef = Y2 : DebugString = DebugString & vbnewline & "Clamped" 'Clamp High
- activeball.velx = activeball.velx * BounceCoef
- activeball.vely = activeball.vely * BounceCoef
- DebugString = "FalloffSimple " & Debugstring & vbnewline
- FalloffDebugBox TBbounces, Finalspeed, BallSpeed(ActiveBall), BounceCoef, DebugString
- End Sub
- Sub FalloffDebugBox(object, input,output,Coef,debugstring) 'Debug Box
- 'if not debugflippers then Exit Sub
- object.Text = Debugstring & round(input,4) & vbnewline & round(output,4) & vbnewline & "%" & round(coef,4)
- object.TimerEnabled = 1
- End Sub
- TBbounces.TimerInterval = 3000 'reset debug textbox after this interval
- Sub TBbounces_Timer():me.timerenabled = 0 : me.text = Empty : End Sub
- TBFlipper.TimerInterval = 5000 'reset debug textbox after this interval
- Sub TBFlipper_Timer():me.timerenabled = 0 : me.text = Empty : End Sub
- Dim r1, r2, r3, r4
- Dim S1, s2, s3, s4
- dim T1, t2, t3, t4
- Dim F1, f2, f3,f4
- r1 = 18 : r2 = 1 : r3 = 58 : r4 = 0.3 'Posts
- s1 = 12 : s2 = 1 : s3 = 40 : s4 = 0.5 'Sleeves
- t1 = 2 : t2 = 1 : t3 = 50 : t4 = 0.4 'Targets
- f1 = 2 : f2 = 1 : f3 = 50 : f4 = 0.31 'Frogs
- '===========================
- dim Ballsize : BallSize = 50'49.9634
- dim BallMass : BallMass = 1.65'.3'1.69876
- const UseVPMModSol=true
- On Error Resume Next
- ExecuteGlobal GetTextFile("controller.vbs")
- If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
- On Error Goto 0
- LoadVPM "01530000", "WPC.VBS", 3.10
- '===========================
- Const UseSolenoids = 1
- Const UseLamps = 0
- Const UseGI = 0
- Const UseSync = 0
- Const HandleMech = 1
- Const SCoin = "fx_Coin"
- SideRails.Visible = Table1.ShowDT
- 'if not Table1.ShowDT then Ramp37.visible = 0 : Ramp10.visible = 0 'remove glass in FS
- Lbolt1.visible = 0 : Lbolt2.Visible = 0 : L35r.visible = 0 : Lcandle1.visible = 0 : Lcandle2.visible = 0
- dim Proto : Proto = False
- If cGameName = "SS_01" then 'I made an honest attempt at this but unfortunately
- 'tb.text = "prototype running..."'the preproduction aux lamp board is not supported by pinmame
- MetalProto.Visible = True
- MetalProto.Collidable = True
- Proto = True
- 'get rid of left post
- Col_Rubber_LeftAdjust.Collidable = False
- Post_Adjustable1_Rubber.Visible = False
- Post_Adjustable1.visible = False
- 'Disable Skull Flashers
- F21f.visible = 0
- f25f.visible = 0
- F20n.Visible = 0 'and Bolt flasher
- 'Enable Prototype Lamps
- Lbolt1.visible = 1 : Lbolt2.Visible = 1 : L35r.visible = 1 'bolt lamps, and new metal wall reflection
- Lcandle1.visible = 1 : Lcandle2.visible = 1 'backglass???
- End If
- Dim Save2700K(200, 3) '0 = color 1 = colorfull 2 = intensity 3 = GIreflections
- Save2700kvalues
- sub Save2700kvalues() 'keep default-editor 2700K colors in an array
- dim x
- for x = 0 to (gi2.count -1)
- on error resume Next
- save2700k(x, 0) = GI2(x).color
- save2700k(x, 1) = GI2(x).colorfull
- save2700k(x, 2) = GI2(x).intensity
- Next
- for x = 0 to (gi2.count -1)
- on error resume Next
- save2700k(x, 3) = BallReflections(x).color
- Next
- End Sub
- dim lastinput : lastinput = 0
- Sub GItype(input)
- dim xg, xp, x, s, rnd
- Select Case input
- case 1 '2700k ACES
- xg = "GI_2700K" : xp = "GIP_2700K"
- for x = 0 to (gi2.count -1)
- On Error Resume Next
- GI2(x).color = save2700k(x, 0)
- GI2(x).colorfull = save2700k(x, 1)
- GI2(x).intensity = save2700k(x, 2)
- Next
- for x = 200 to 203 'GI relay on / off Fading Speeds
- FlashSpeedUp(x) = 0.01
- FlashSpeedDown(x) = 0.008
- Next
- for x = 300 to 303 'GI 8 step modulation
- FlashSpeedUp(x) = 0.01
- FlashSpeedDown(x) = 0.008
- Next
- for x = 0 to (BallReflections.Count-1) 'ball reflections
- BallReflections(x).Color = save2700k(x, 3)
- Next
- case 2 '4100k ACES
- xg = "GI_4100K" : xp = "GIP_4100K"
- for each x in GI2
- On Error Resume Next
- s = mid(x.name, 3, 1)
- if s = "t" then 'transmit
- x.Color = RGB(44, 58, 77)
- x.ColorFull = RGB(188, 188, 155)
- end If
- Next
- git3.colorfull = rgb(255,239,232) 'bulbs
- git3.color = rgb(253,227,151)
- git4.colorfull = rgb(255,239,232)
- git4.color = rgb(253,227,151)
- git5.colorfull = rgb(255,239,232)
- git5.color = rgb(253,227,151)
- for x = 200 to 203 'GI relay on / off
- FlashSpeedUp(x) = 0.014
- FlashSpeedDown(x) = 0.014
- Next
- for x = 300 to 303 'GI 8 step modulation
- FlashSpeedUp(x) = 0.014
- FlashSpeedDown(x) = 0.014
- Next
- for x = 0 to (BallReflections.Count-1)
- BallReflections(x).Color = RGB(255,215,166)
- Next
- Case 3 'White
- xg = "GI_White" : xp = "GIP_White"
- for each x in GI2
- x.Color = RGB(255, 255, 255)
- On Error Resume Next
- s = mid(x.name, 3, 1)
- if s = "t" then 'transmit
- x.ColorFull = RGB(255, 255, 255)
- end If
- Next
- git3.colorfull = rgb(255,255,255) 'bulbs
- git3.color = rgb(0,0,0) 'rgb(255,255,255)
- git4.colorfull = rgb(255,255,255)
- git4.color = rgb(0,0,0)'rgb(255,255,255)
- git5.colorfull = rgb(255,255,255)
- git5.color = rgb(0,0,0)'rgb(255,255,255)
- for x = 200 to 203 'GI relay on / off
- FlashSpeedUp(x) = 0.014
- FlashSpeedDown(x) = 0.014
- Next
- for x = 300 to 303 'GI 8 step modulation
- FlashSpeedUp(x) = 0.014
- FlashSpeedDown(x) = 0.014
- Next
- for x = 0 to (BallReflections.Count-1)
- BallReflections(x).Color = RGB(215,226,255)
- Next
- case 4 'Colorized
- xg = "GI_Color" : xp = "GIP_Color"
- for each x in GI2
- x.color = rgb(0, 0, 0)
- Next
- gi.color = rgb(255,255,255) 'gi (always white, image modulates colors)
- gip.color = rgb(255,255,255) 'gi plastics
- git7.colorfull = rgb(250, 20, 250) 'inlanes
- git8.colorfull = rgb(250, 20, 250) '...
- git3.colorfull = rgb(5,250,5) 'bulbs
- git4.colorfull = rgb(5,250,5) '...
- git5.colorfull = rgb(250, 20, 250) 'bumper area bulb
- git1.colorfull = rgb(5,250,5) 'Sling Plastics
- git2.colorfull = rgb(5,250,5) '...
- Git6.colorfull = rgb(250, 20, 250) 'Rollovers
- for x = 200 to 203 'GI relay on / off
- FlashSpeedUp(x) = 0.014
- FlashSpeedDown(x) = 0.014
- Next
- for x = 300 to 303 'GI 8 step modulation
- FlashSpeedUp(x) = 0.014
- FlashSpeedDown(x) = 0.014
- Next
- 'GI reflections
- dim sat : sat = 2
- Gi_BallRefl1.Color = RGB(sat,sat,255) 'green
- Gi_BallRefl2.Color = RGB(sat,sat,255)
- Gi_BallRefl3.Color = RGB(255,sat,255) 'pink
- Gi_BallRefl4.Color = RGB(255,sat,255)
- Gi_BallRefl5.Color = RGB(255,sat,255)
- Gi_BallRefl6.Color = RGB(255,sat,255)
- Gi_BallRefl7.Color = RGB(255,sat,255)
- Gi_BallRefl11.Color = RGB(255,sat,255)
- Gi_BallRefl12.Color = RGB(255,sat,255)
- Gi_BallRefl8.Color = RGB(255,sat,sat) 'red
- Gi_BallRefl9.Color = RGB(sat,sat,255) 'blue
- Gi_BallRefl10.Color = RGB(sat,sat,255)
- case 0 'Random
- rnd = rndnum(1, 4)
- if rnd <> lastinput then GItype rnd else gitype 0 end if
- Exit Sub
- Case 5 'Sequential
- If LastInput > 3 then LastInput = 0
- gitype (Lastinput+1)
- Exit Sub
- Case Else
- Gitype 0 : exit sub
- End Select
- ' dim temp
- ' temp = lastinput
- lastinput = input
- GI.ImageA = xg
- GIP.ImageA = xp
- ' tb.text = temp & " " & input 'debug
- End Sub
- 'EOStimer (just switches elast falloff)
- '============
- 'LFHM physics by wrd1972 and Rothbauer
- dim EOSAngle,ElastFalloffUp,ElastFalloffDown
- 'This rules but it would be way better if it was elasticity and not elast falloff
- ElastFalloffup = LeftFlipper.ElasticityFalloff
- ElastFalloffdown = 0.25'0.7
- 'EOS angle
- EOSAngle = 4
- 'Flipper EOS timer (HMLF)
- dim LastAngle1, LastAngle2 '
- Sub eostimer_Timer() 'use -1 timer interval for this?
- If LeftFlipper.CurrentAngle <> LastAngle1 then 'slight optimization
- If LeftFlipper.CurrentAngle < LeftFlipper.EndAngle + EOSAngle Then
- LeftFlipper.ElasticityFalloff = ElastFalloffup
- Else
- LeftFlipper.ElasticityFalloff = ElastFalloffdown ' This works for flippers :D
- End If
- End If
- If RightFlipper.CurrentAngle <> LastAngle2 then
- If RightFlipper.CurrentAngle > RightFlipper.EndAngle - EOSAngle Then
- RightFlipper.ElasticityFalloff = ElastFalloffup
- Else
- RightFlipper.ElasticityFalloff = ElastFalloffdown
- End If
- End If
- LastAngle1 = LeftFlipper.CurrentAngle
- LastAngle2 = RightFLipper.CurrentAngle
- End Sub
- Sub SolLFlipper(Enabled)
- If Enabled Then
- PlaySound SoundFX("FlipperUpLeft",DOFContactors), 0, LVL(0.75), -0.0375, 0.1
- LeftFlipper.RotateToEnd
- ProcessballsL
- Else
- PlaySound SoundFX("FlipperDown",DOFContactors), 0, LVL(0.01), -0.0375, 0.1
- LeftFlipper.RotateToStart
- End If
- End Sub
- Sub SolRFlipper(Enabled)
- If Enabled Then
- PlaySound SoundFX("FlipperUpLeft",DOFContactors), 0, LVL(0.75), 0.0375, 0.1
- RightFlipper.RotateToEnd
- ProcessballsR
- Else
- PlaySound SoundFX("FlipperDown",DOFContactors), 0, LVL(0.01), 0.0375, 0.1
- RightFlipper.RotateToStart
- End If
- End Sub
- 'Key input Stuff
- '==============
- Dim DesktopMode:DesktopMode = Table1.ShowDT
- dim CardTex : CardTex = False 'False = Graphic Scorecard True = Default paper
- ScoreCardDT.Visible = DesktopMode : ScoreCardFS.Visible = Not DesktopMode
- sub Destroyer_hit():me.destroyball:end sub
- Sub table1_Paused:Controller.Pause = 1: StopAllRolling :End Sub
- Sub table1_unPaused:Controller.Pause = 0:End Sub
- 'dim t0, T1
- 't0 = 180
- 't1 = 10
- dim catchinput(1)
- Sub Table1_KeyDown(ByVal keycode)
- If Keycode = StartGameKey then Controller.Switch(13) = 1
- If keycode = PlungerKey Then PlaySound SoundFx("PlungerPull",0), 0, LVL(0.01), 0.06, 0.2:Plunger.Pullback:end if
- 'if keycode = 31 then SolLeftSling 1' : kicker1.createball:kicker1.kick t0, t1
- ' if keycode = 33 then SolRightSling 1
- if KeyCode = KeyRules then if DeskTopMode then Setlamp cCardDT, 1 : else Setlamp cCardFS, 1 end if
- If Keycode = RightFlipperKey then if DebugFlippers then SolRFlipper 1 : Exit Sub
- If Keycode = LeftFlipperKey then if DebugFlippers then SolLFlipper 1 : Exit Sub
- If keycode = LeftTiltKey Then nfNudge -1, 1.5'vpmnudge.doNudge 90, 3.5 : exit sub
- If keycode = RightTiltKey Then nfNudge 1, 1.5'vpmnudge.doNudge 270, 3.5 : exit sub
- If keycode = CenterTiltKey Then nfNudge 0, 1.5'vpmnudge.doNudge 0, 3.5 : exit sub
- if keycode = LeftMagnaSave then catchinput(0) = True : If catchinput(1) = True then CardTex = not CardTex : ScoreCardDT.Image = abs(cInt(CardTex))+1 & "ScoreCard" : ScoreCardFS.Image = ScoreCardDT.Image : playsound "BSDwhop", 0, LVL(0.0025)
- if keycode = RightMagnaSave then CatchInput(1) = True : if catchinput(0) and flashlevel(cGIon) * flashlevel(cGImod) > 0 then gitype 5 : playsound "fx_relay_on", 0, LVL(0.05),0,0.05
- If vpmKeyDown(keycode) Then Exit Sub
- End Sub
- 'Nudge Script test thing
- 'Same idea as JP's old VP9 nudge script
- redim nfNudgeCache(99)
- Sub nfNudge(dir,Strength) 'dir = Left right coef. 0 = up. No vector calculation
- dim counter,x : counter = 0
- redim nfNudgeCache(99)
- dim debugstr
- for each x in getballs
- if dir = 0 then
- x.Vely = x.Vely + strength*-1
- debugstr = "vely+"& round(x.Vely + strength*-1 , 2)
- else
- x.Velx = x.VelX + strength*dir
- debugstr = "velx+"& round(x.Vely + strength*-1 , 2)
- end if
- 'for shift back
- set nfNudgeCache(counter) = x
- 'debug.print "ballid:" & x.id & " to " & "nfnudgecache(" & counter & ")"
- counter = counter + 1
- next
- if counter = 0 then counter = 1
- redim Preserve nfNudgeCache(Counter-1)
- vpmtimer.addtimer 250, "nfNudgeBack" & " " & dir & ", "& strength/2 & "'"
- End Sub
- Sub nfNudgeBack(dir,Strength)
- if ubound(nfnudgecache) = 0 then exit sub
- on error resume Next
- dim x : for each x in nfNudgeCache
- if Not IsEmpty(x) then
- if dir = 0 then
- x.Vely = x.Vely + strength*-1*-1
- else
- 'if isEmpty(x.VelX) then debug.print "Xnull, exit sub. typename: " & typename(x) & " " & "isempty x:" & IsEmpty(x): exit sub
- x.Velx = x.VelX + strength*dir*-1
- end if
- end if
- next
- End Sub
- Sub Table1_KeyUp(ByVal keycode)
- If Keycode = StartGameKey then Controller.Switch(13) = 0
- if KeyCode = KeyRules then if DeskTopMode then Setlamp cCardDT, 0 : else Setlamp cCardFS, 0 end if
- If keycode = PlungerKey Then
- Plunger.Fire
- if BallInPlunger then
- PlaySound SoundFX("Plunger3",0),0, LVL(0.3),0.06,0.05
- Else
- PlaySound SoundFX("plunger",0),0, LVL(0.3),0.06,0.05
- end if
- End If
- If Keycode = RightFlipperKey then if DebugFlippers then SolRFlipper 0 : Exit Sub
- If Keycode = LeftFlipperKey then if DebugFlippers then SolLFlipper 0 : Exit Sub
- if keycode = LeftMagnaSave then catchinput(0) = False
- if Keycode = RightMagnaSave then catchinput(1) = False
- If vpmKeyUp(keycode) Then Exit Sub
- End Sub
- RandomColors
- Sub RandomColors()
- dim a, x, x2
- a = Array("boogin_Green", "Boogin_Red", "Boogin_Purple", "Boogin_Blue", "Boogin_Yellow")
- x = cInt(rndnum(0, uBound(a)) )
- x2 = x
- x = x + rndnum(1, uBound(a) )
- if x > uBound(a) then x = x - uBound(a)
- if x = x2 then 'try again if the boogies are the same
- RandomColors 'bad idea
- Exit Sub
- End If
- Boogie1.Image = a(x2)
- BoogieArms1.Image = a(x2)
- Boogie2.Image = a(x)
- BoogieArms2.Image = a(x)
- ' tb.text = boogie1.image & vbnewline & boogie2.image
- End Sub
- gip.x = 482
- gip.y = 775
- Bumperw.x = 976.55
- Bumperw.y = 525
- Bumperw.Height = 155
- L84_0.x = 186.4640141
- L84_0.y = 60.6526099
- L84_1.x = 245.5639003
- L84_1.y = 34.6744886
- L84_2.x = 306.8235425
- L84_2.y = 25.5868251
- L85r.x = 384.2346585
- L85r.y = 27.7668062
- L86r.x = 478.6800507
- L86r.y = 34.9814888
- L35r.x = 22.75 'prototype kickback only
- L35r.y = 1584.5
- L45r.x = 864
- L45r.y = 1533.3037335
- FlSkull2_5.bulbhaloheight =34.7'28
- FlSkull2_6.bulbhaloheight =35.1'28
- FlSkull2_5.x = 807'808.1973
- FlSkull2_6.x = 836 '838.3223
- FlSkull2_3.bulbhaloheight =33'29
- FlSkull2_4.bulbhaloheight =29'29
- FlSkull2_3.x = 837'838.39
- FlSkull2_4.x = 864 '860.765
- FlSkull2_1.bulbhaloheight =32'28
- FlSkull2_2.bulbhaloheight =33 '30
- FlSkull2_1.x = 780'782.3
- FlSkull2_2.x = 804 '806.785
- FlSkull5_1.bulbhaloheight = 31.5'28
- FlSkull5_2.bulbhaloheight = 31.5'28
- FlSkull5_1.x = 805.5'807.7266
- 'FlSkull5_2.x = '834.085
- FlSkull4_1.bulbhaloheight = 29'28
- FlSkull4_2.bulbhaloheight = 29'28
- FlSkull4_1.x = 743'743.7
- FlSkull4_2.x = 772.2'774.3
- FlSkull4_1.y = 81'86.609
- f19f.x = 854'853.3457
- f19f.y = 697'696.2
- f18f.x = 703'695
- f18f.y = 555'550.6
- f17.x = 858.2477164
- f17.y = 355.0953586
- f18.x = 712.9653396
- f18.y = 502.0359103
- f19.x = 858.3208126
- f19.y = 648.2506583
- f17f.x = 848'850.5333
- f17f.y = 420'424.1581
- f23.x = 215'195
- f23.y = 600'527
- f26.falloffpower = 3.5'2.5
- f21f.opacity = 2000 '1550
- f25f.opacity = 2000 '1550
- f22side.x = 0.1 'sidewalls
- f24side.x = 0.1
- f35side.x = 0.1
- f27side.x = 976
- f28side.x = 976
- f36side.x = 976
- f22side.y = 164.7058 'sidewalls L
- f22side.height = 235.394
- f24side.y = 905.1276
- f24side.height = 155.195
- f35side.y = 1438.183
- f35side.height = 155.651
- f27side.y = 235.294
- f27side.height = 188.2352
- f28side.y = 815.1855836
- f28side.height = 152.135
- f36side.y = 1461.3333459
- f36side.height = 155.647
- 'ambient flashers
- f27a.x = 74.1650189 'left
- f27a.y = 153.5833371
- f27a.height = 290.9047391
- f22a.x = 635.9062643 'right
- f22a.y = 153.5833371
- f22a.height = 290.9047391 +1
- f24a.x = 37.9471029
- f24a.y = 893.7202263
- f24a.height = 232.9866935
- f35a.x = 32.7692645
- f35a.y = 1421.3283143
- f35a.height = 193.043327
- f28a.x = 916.99662
- f28a.y = 843.8636384
- f28a.height = 236.6003666
- f36a.x = 838.7909472
- f36a.y = 1442.2939137
- f36a.height = 193.043327
- Dim bsTrough, bsCoffin, bsLeftKick, bsSpider, Frog1Vel, Frog2Vel, Frog3Vel, WheelMech, IMAutoPlunger
- Dim UseMech, CrateOpen, BIP, FSSpiderenabled
- BIP = 0
- ' Init table
- Sub table1_Init()
- vpmInit Me
- Dim X
- InitWheel
- With Controller
- .GameName = cGameName
- If Err Then MsgBox "Can't start Game: " & cGameName & vbNewLine & Err.Description:Exit Sub
- .Games(cGameName).Settings.Value("rol") = 0 'rotated to the left
- .HandleMechanics = UseMech
- .ShowDMDOnly = 1
- .ShowFrame = 0
- .ShowTitle = 0
- .Hidden = 0
- '.SetDisplayPosition 0, 0, GetPlayerHWnd 'uncomment this line If you don't see the vpm window
- On Error Resume Next
- .Run GetPlayerHWnd
- If Err Then MsgBox Err.Description
- ' On Error Goto 0
- End With
- Controller.Switch(22) = 1 ' coin door closed...
- Controller.Switch(24) = 1 ' and keep it closed
- Controller.Switch(48) = 1 ' turn on the coffin diode
- vpmNudge.TiltSwitch = 14
- vpmNudge.Sensitivity = 1'0.25
- vpmNudge.TiltObj = Array(bumper1, bumper2, bumper3, LeftSlingshot, RightSlingshot)
- ' Main Ball Trough
- set bsTrough = new cvpmBallStack
- With bsTrough
- .InitSw 0, 32, 33, 34, 35, 0, 0, 0
- .InitKick BallRelease, 90, 6
- ' .InitExitSnd SoundFX("BallReleaseRS",DOFcontactors), SoundFX("FlipperUpLeft",DOFContactors)
- .Balls = 4
- End With
- ' Coffin
- set bsCoffin = new cvpmBallStack
- With bsCoffin
- .InitSw 0, 41, 42, 43, 0, 0, 0, 0
- .InitKick CoffinKicker, 170, 5
- '.InitExitSnd SoundFX("Kicker_Release",DOFContactors), SoundFX("FlipperUpLeft",DOFContactors)
- End With
- ' Spider
- Set bsSpider = New cvpmBallStack
- bsSpider.InitSw 0, 36, 0, 0, 0, 0, 0, 0
- bsSpider.InitKick sw36, 202, 40 '202, 35
- bsSpider.KickZ = 95
- ' bsSpider.KickBalls = 2
- 'bsSpider.InitExitSnd SoundFX("Kicker_Release",DOFContactors), SoundFX("FlipperUpLeft",DOFContactors)
- ' Left Kickout
- Set bsLeftKick = New cvpmBallStack
- ' bsLeftKick.InitSw 0, 37, 0, 0, 0, 0, 0, 0
- ' bsLeftKick.InitKick sw37, 91, 60 '84 66
- ' bsLeftKick.KickZ = 80 '80
- ' bsLeftKick.KickForceVar = 0.1 '5
- ' bsLeftKick.KickAngleVar = 0.1 '0
- bsLeftKick.InitSw 0, 37, 0, 0, 0, 0, 0, 0
- bsLeftKick.InitKick sw37, 91, 63 '91,60
- bsLeftKick.KickZ = 80 '80
- bsLeftKick.KickForceVar = 8 '5
- bsLeftKick.KickAngleVar = 0.1 '0
- ' Impulse Plunger used as the autoplunger
- Set IMAutoPlunger = New cvpmImpulseP
- With IMAutoPlunger
- .InitImpulseP Sw18, 38, 0.4
- .Random 0.6
- ' .InitExitSnd SoundFX("plunger",DOFContactors), SoundFX("FlipperUpLeft",DOFContactors)
- .CreateEvents "IMAutoPlunger"
- .Switch 18
- End With
- ' Main Timer init
- PinMAMETimer.Interval = PinMAMEInterval
- PinMAMETimer.Enabled = 1
- Frog1Vel = 0:Frog2Vel = 0:Frog3Vel = 0
- sw37_dropwall.isdropped = 1
- 'Start gi on
- UpdateGIon 0, 1:UpdateGIon 1, 1: UpdateGIon 2, 1
- UpdateGI 0, 7:UpdateGI 1, 7:UpdateGI 2, 7
- gitype giselect
- 'Wheel Placer
- 'idk why this doesn't work whatever
- if DesktopMode = True then 'should be true just debugging
- flspiderback.visible = 0
- FlSpider.RotX = -Table1.Inclination 'broken in VP10.3
- ' FlSpider.RotX = 0
- ' FlSpiderback.RotX = FlSpider.RotX
- WheelPlacer l82, -90.1
- WheelPlacer l83, -67.5
- WheelPlacer l64, -45
- WheelPlacer l65, -22.5
- WheelPlacer l66, 0
- WheelPlacer l67, 22.5
- WheelPlacer l68, 45
- WheelPlacer l71, 67.5
- WheelPlacer l72, 90
- WheelPlacer l73, 112.5
- WheelPlacer l74, 135
- WheelPlacer l75, 157.5
- WheelPlacer l76, 179.9
- WheelPlacer l77, -157.5
- WheelPlacer l78, -135
- WheelPlacer l81, -112.5
- FadingLevel(cSpiderFade) = 9
- FSSpiderenabled = False
- Elseif Desktopmode = False then
- if SingleScreenFS = 1 Then FS_SingleScreen_Spider_Init
- End If
- End Sub
- 'tdebugbox2.timerenabled = 1
- 'sub tdebugbox2_timer()
- ' Tdebugbox2.text = "DT=" & DesktopMode & " moved?" & l78.height & " " & l78.opacity & "spiderboot" & spiderspinning
- 'end sub
- Dim WheelAwards
- WheelAwards = Array(l82, l83, l64, l65, l66, l67, l68, l71, l72, l73, l74, l75, l76, l77, l78, l81)
- Sub WheelPlacer(object, angle)
- Dim a, b, rad
- rad = (angle/180)*Pi 'Converts radians into degrees
- a = FlSpider.SizeX/2+75 'Set the width of the ellipse/circle
- b = FlSpider.SizeX/4+75 'Set the height of the ellipse
- object.RotX = FlSpider.RotX 'First, rotate to face the player
- ' object.RotX = -Table1.Inclination 'First, rotate to face the player 'old
- object.X = FlSpider.X + (a)*dCos(angle) 'The icon's X coordinate is based off the spider's center and the angle around it (3 o'clock being 0 degrees, noon being -90, 6 o'clock +90, etc.)
- object.Y = FlSpider.Y + ((a)*(dCos(FlSpider.RotX)))*dSin(angle) 'The Y coord is based off both the angle of the clock as well as the angle of table inclination
- object.Height = FlSpider.Height + a*-dSin(angle) 'The Z coord is based off just the angle
- End Sub
- Sub FS_SingleScreen_Spider_Init 'spider rotation is enabled by spiderFS and setlamp 398, 1
- FSSpiderenabled = True
- FlashLevel(cSpiderFade) = 0
- FlashLevel(cSpiderFade) = 4
- 'setlamp 398, 0
- FLspiderback.visible = 1
- FLspider.visible = 1
- dim x : for each x in Awards : x.opacity = 0 : next
- l82.x = 537.6
- l82.y = 1292.665
- l83.x = 624.8
- l83.y = 1316.84
- l64.x = 696.2
- l64.y = 1361.3
- l65.x = 744.27
- l65.y = 1418.82
- l66.x = 761.4
- l66.y = 1484.78
- l67.x = 741.9
- l67.y = 1550.73
- l68.x = 707.55
- l68.y = 1630.95
- l71.x = 639.89
- l71.y = 1676.413
- l72.x = 537.2
- l72.y = 1702.965 'bottom
- l73.x = 441.6
- l73.y = 1677.2
- l74.x = 374.34
- l74.y = 1623.15
- l75.x = 323.79
- l75.y = 1553.1 '
- l76.x = 309.82
- l76.y = 1485.08
- l77.x = 326.95
- l77.y = 1418.03
- l78.x = 373.3545
- l78.y = 1364.481
- l81.x = 447.93
- l81.y = 1318.427
- dim xx
- For each xx in WheelAwards
- xx.ModulateVsAdd = 0.1
- xx.Height = 165
- xx.RotX = 0
- xx.RotZ = 0
- xx.RotY = 0
- xx.x = xx.x - 90
- xx.y = xx.y - 10
- Next
- ''' FLSpiderback.RotX = 0
- ''' FLSpiderback.RotZ = 0
- ''' FLSpiderback.RotY = 0
- ''' FLSpiderback.x = 438.7415
- ''' FLSpiderBack.y = 1479.515
- ''' FLSpiderBack.x = FLSpiderBack.x - 95 'fine tune position
- '' FLSpiderBack.y = FLSpiderBack.y + 25 'fine tune position
- ' FLSpiderBack.Height = 164
- ' FLSpiderBack.ImageA = "black_back"
- ' FLSpiderBack.ImageB = "flare_clear"
- ' FLSpiderBack.Filter = "Overlay" 'Filter Overlay 30%
- ' FLSpiderBack.Amount = 30
- ' FLSpiderBack.Opacity = 92 ' 92% opacity
- FlSpider.x = 535.8914
- FlSpider.y = 1503.128
- FlSpider.Height = 166
- FlSpider.RotX = 0
- FlSpider.RotZ = 0
- FlSpider.RotY = 0
- FLSpider.x = FLSpider.x - 95 'fine tune position
- end sub
- Sub INITWheel
- Set WheelMech = New cvpmMech
- With WheelMech
- .MType = vpmMechStepSol + vpmMechCircle + vpmMechLinear + vpmMechFast
- .Sol1 = 39
- .Sol2 = 40
- .Length = 200
- .Steps = 48
- .CallBack = GetRef("UpdateWheel")
- .AddSw 12, 0, 0
- .Start
- End With
- End Sub
- Dim lednr, np, FSspider
- Sub UpdateWheel(aNewPos, aSpeed, aLastPos)
- DOF 101, DOFPulse
- np=aNewPos+12:If np>47 Then np=np-48
- lednr=int(np/4.8)
- if lednr>4 then lednr=lednr-5
- DOF 201+lednr, DOFPulse
- if FSSpiderenabled then
- if bip = 1 and bsSpider.balls > 0 Then Setlamp cSpiderFade, 1
- 'Else
- ' SetLamp 398, 0
- 'end if
- end if
- ' dim temp : if IsObject(bsSpider) then temp = bsspider.balls
- ' tb.text = aNewPos & " " & aspeed & " " & aLastPos & vbnewline & _
- ' "bip " & bip & " bsSpider.Balls:" & temp
- End Sub
- Sub SpiderFS(nr)
- 'if SingleScreenFS = 0 then Exit Sub
- 'if SingleScreenFS = 0 or Desktopmode then Exit Sub
- dim x
- Select Case FadingLevel(nr)
- case 4
- FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
- If FlashLevel(nr) < FlashMin(nr) Then
- FlashLevel(nr) = FlashMin(nr)
- FadingLevel(nr) = 0 'completely off
- End If
- for each x in WheelAwards
- x.opacity = FlashLevel(nr) * 100
- next
- FLspider.intensityscale = FlashLevel(nr)
- Flspiderback.intensityscale = FlashLevel(nr)
- case 5
- FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
- If FlashLevel(nr) > FlashMax(nr) Then
- FlashLevel(nr) = FlashMax(nr)
- FadingLevel(nr) = 1 'completely on
- End if
- for each x in WheelAwards
- x.opacity = FlashLevel(nr) * 100
- next
- FLspider.intensityscale = FlashLevel(nr)
- Flspiderback.intensityscale = FlashLevel(nr)
- End Select
- End Sub
- Sub tbspider_Timer()
- End Sub
- '
- 'sub NspiderFS(nr) 'handles spider opacity fading in Single-Screen FS
- ' dim xx
- ' if SingleScreenFS = 0 or desktopmode = True Then exit sub
- ' Select Case FadingLevel(nr)
- ' Case 1
- ' if bip = 1 and bsSpider.balls Then
- ' exit Sub
- ' Else
- ' setlamp 398, 0 'debug
- ' end If
- ' case 4
- ' FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
- ' If FlashLevel(nr) < FlashMin(nr) Then
- ' FlashLevel(nr) = FlashMin(nr)
- ' FadingLevel(nr) = 0 'completely off
- ' End If
- ' case 5
- ' FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
- ' If FlashLevel(nr) > FlashMax(nr) Then
- ' FlashLevel(nr) = FlashMax(nr)
- ' FadingLevel(nr) = 1 'completely on
- ' End if
- ' end select
- ' for each xx in WheelAwards
- ' xx.opacity = FlashLevel(nr) * 100
- ' next
- '' FLspider.opacity = FlashLevel(nr) * 100
- '' Flspiderback.opacity = FlashLevel(nr) * 100
- ' FLspider.intensityscale = FlashLevel(nr)
- ' Flspiderback.intensityscale = FlashLevel(nr)
- 'end sub
- 'flspiderback.intensityscale = 0
- 'Sub UpdateWheel(aNewPos, aSpeed, aLastPos)
- ' DOF 101, DOFPulse
- ' np=aNewPos+12:If np>47 Then np=np-48
- ' lednr=int(np/4.8)
- ' if lednr>4 then lednr=lednr-5
- ' DOF 201+lednr, DOFPulse
- 'End Sub
- '*******************
- '* Solendoid Callbacks
- '*******************
- Set GICallback = GetRef("UpdateGIon")
- Set GICallback2 = GetRef("UpdateGI")
- SolCallback(sLRFlipper) = "SolRFlipper"
- SolCallback(sLLFlipper) = "SolLFlipper"
- SolCallback(1) = "AutoPlunge"
- 'SolCallback(2) = "SolLoopGate" 'kickback in prototype, this sol moved to 25
- SolCallback(2) = "Sol2"
- Sub Sol2(enabled) 'Kickback / SolLoopGate
- if Proto then
- if enabled then
- kickback.Fire
- PlaySound SoundFX("Ball Launch",DOFContactors), 0, LVL(0.3),0.06,0.05
- Else
- kickback.Pullback
- end If
- Else
- SolLoopGate enabled
- end If
- End Sub
- kickback.pullback
- SolCallback(3) = "SolSpiderPopper"
- SolCallback(4) = "SolCoffinPopper"
- SolCallback(5) = "SolCoffinDoor"
- SolCallback(6) = "SolCrateKickout"
- SolCallback(7) = "vpmSolSound SoundFX(""Knocker"",DOFKnocker),"
- 'SolCallback(8) = "CratePostPower" 'crate 'flip' coil. not necessary? -nf
- SolCallback(9) = "SolBallRelease"
- SolCallback(10) = "SolLeftSling"
- SolCallback(11) = "SolRightSling"
- SolCallBack(12) = "SolBumper2"
- SolCallBack(13) = "SolBumper1"
- SolCallBack(14) = "SolBumper3"
- 'SolCallBack(15) = "SolUpperSling"
- SolCallback(16) = "CratePostHold"
- SolCallback(33) = "LDiverterPower"
- SolCallback(34) = "LDiverterHold"
- 'Flashers
- SolModCallback(17) = "SetModLampM 117," 'Top Bumper Flash
- SolModCallback(18) = "SetModLampM 118," 'Mid Bumper Flash
- SolModCallback(19) = "SetModLampM 119," 'Bottom Bumper Flash
- 'SolModCallback(20) = "SetModLamp 120," 'Bolts Flash
- SolModCallback(20) = "Sol20" 'Bolts Flasher / Aux Board Enabled
- Sub Sol20(value)
- if Proto then Exit Sub
- SetModLamp 120, value
- End Sub
- 'SolModCallback(21) = "SetModLamp 121," 'Bone Pile Flasher 1 'added
- SolModCallback(21) = "Sol21" 'Bone Pile Flasher Blue / Backbox Spider (is this the motor? TODO)
- Sub Sol21(value)
- if Proto then Exit Sub
- SetModLamp 121, value
- End Sub
- SolModCallback(22) = "SetModLampM 122," 'Upper Right Flasher
- SolModCallback(23) = "SetModLamp 123," 'Skull Flasher
- SolModCallback(24) = "SetModLampM 124," 'Mid Left Flasher
- 'SolModCallback(25) = "SetModLamp 125," 'Bone Pile Flasher 2
- SolModCallback(25) = "Sol25" 'Bone Pile Flsaher #2 (White) \ SolLoopGate
- Sub Sol25(value)
- if Proto then
- SolLoopGate cBool(value)
- Else
- SetModLamp 125, value
- end If
- End Sub
- SolModCallback(26) = "SetModLamp 126," 'TVFlasher
- SolModCallback(27) = "SetModLampM 127," 'Up Left Flasher
- SolModCallback(28) = "SetModLampM 128," 'Mid Right Flasher
- SolModCallback(35) = "SetModLampM 135," 'Bottom Left Flasher
- SolModCallback(36) = "SetModLampM 136," 'Bottom Right Flasher
- '================VP10 Fading Lamps Script
- Dim LampState(440), FadingLevel(440)
- Dim FlashSpeedUp(440), FlashSpeedDown(440), FlashMinw(440), FlashMin(440), FlashMax(440), FlashLevel(440), FlashSpeedUp2(440), FlashSpeedDown2(440), fBlinkPattern(440)
- dim tIntervalNext(440) '??
- dim SolModValue(440)
- dim LightFallOff(440, 4) '2d array to hold alt falloff values in different columns
- dim FlashersOpacity(440)
- dim insertfading(440, 2): 'columns : 0 = name 1 = fadeup 2 = fadedown
- 'dim FlashersFalloff(340) '??? (could use multiply? or some other kind of mixing?...)
- dim GIscale(4) '4 gi strings. only 0 used for now
- 'Dim FlashersOpacity(200)
- Sub SetModLamp(nr, value)
- If value <> SolModValue(nr) Then
- SolModValue(nr) = value
- if value > 0 then LampState(nr) = 1 else LampState(nr) = 0
- FadingLevel(nr) = LampState(nr) + 4
- End If
- End Sub
- Sub SetModLampM(nr, value) 'setlamp NR, but also NR + 50
- If value <> SolModValue(nr) Then
- SolModValue(nr) = value
- if value > 0 then LampState(nr) = 1 else LampState(nr) = 0
- FadingLevel(nr) = LampState(nr) + 4
- End If
- If value <> SolModValue(nr+50) Then
- SolModValue(nr+50) = value
- if value > 0 then LampState(nr+50) = 1 else LampState(nr+50) = 0
- FadingLevel(nr+50) = LampState(nr+50) + 4
- End If
- End Sub
- Sub SetFlashSpeedUp(lwr,uppr,value) 'subs for adjusting flasher speed in the debugger
- dim x
- for x = lwr to uppr 'primarly fading speeds for flashers 'intensityscale per 10MS
- FlashSpeedUp(x) = value
- ' FlashSpeedDown(x) = 1
- next
- End Sub
- Sub SetFlashSpeedDown(lwr,uppr,value)
- dim x
- for x = lwr to uppr 'primarly fading speeds for flashers 'intensityscale per 10MS
- ' FlashSpeedUp(x) = 1
- FlashSpeedDown(x) = value
- next
- End Sub
- InitLamps
- Sub InitLamps()
- Dim x
- For x = 0 to 440
- LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
- FadingLevel(x) = 4 ' used to track the fading state
- FlashSpeedUp(x) = 0.1 ' faster speed when turning on the flasher
- FlashSpeedDown(x) = 0.1 '0.3 ' slower speed when turning off the flasher
- FlashMin(x) = 0 ' the minimum value when off, usually 0
- FlashMax(x) = 1 ' the maximum value when on, usually 1
- FlashLevel(x) = 0.001 ' the intensity of the flashers, usually from 0 to 1
- ' fBlinkPattern(x) = "01" 'this was cool but not used anymore
- Next
- for x = 0 to 440
- On Error Resume Next
- SolModValue(x) = 0
- FlashersOpacity(x) = 0
- ' FlashersFalloff(x) = 0 '??? (could use multiply? or some other kind of mixing?...)
- LightFallOff(x, 0) = 0
- LightFallOff(x, 1) = 0
- LightFallOff(x, 2) = 0
- LightFallOff(x, 3) = 0
- LightFallOff(x, 4) = 0
- Giscale(x) = 1.61 '1.61x when gi is fully off
- next
- for x = 340 to 398 'SpiderFS
- FlashSpeedUp(x) = 0.1
- FlashSpeedUp(x) = 0.1
- FlashLevel(x) = 0
- next
- for x = 11 to 90 'inserts
- FlashSpeedUp(x) = 0.015*1.2
- FlashSpeedDown(x) = 0.009*1.2
- Next
- ' FlashSpeedUp(56) = 0.08 'lock
- ' FlashSpeedDown(56) = 0.02
- for x = 111 to 186 'primary fading speeds for flashers 'intensityscale per 10MS
- FlashSpeedUp(x) = 1.1*0.9
- FlashSpeedDown(x) = 0.9*0.9
- next
- FlashSpeedUp(120) = 1.1*0.6 'insert - bolts
- FlashSpeedDown(120) = 0.9*0.6
- FlashSpeedUp(126) = 1.1*0.6 'insert - TV
- FlashSpeedDown(126) = 0.9*0.6
- FlashSpeedUp(123) = 1.1*0.7 'beast
- FlashSpeedDown(123) = 0.9*0.7
- ' for x = 117 to 119 : FlashSpeedUp(x) = 1 : FlashSpeedDown(x) = 0.81 : next 'bumpers
- ' FlashSpeedUp(167) = 1.2 'bumpers
- ' FlashSpeedDown(167) = 0.81
- ' FlashSpeedUp(168) = 1.2
- ' FlashSpeedDown(168) = 0.81
- ' FlashSpeedUp(169) = 1.2
- ' FlashSpeedDown(169) = 0.81 'bumpers
- FlashSpeedUp(172) = 1.3 '6 flashers (Bulbs)
- FlashSpeedDown(172) = 0.7
- FlashSpeedUp(174) = 1.3
- FlashSpeedDown(174) = 0.7
- FlashSpeedUp(177) = 1.3
- FlashSpeedDown(177) = 0.7
- FlashSpeedUp(178) = 1.3
- FlashSpeedDown(178) = 0.7
- FlashSpeedUp(185) = 1.3
- FlashSpeedDown(185) = 0.7
- FlashSpeedUp(186) = 1.3
- FlashSpeedDown(186) = 0.7
- for x = 204 to 210 'Animations
- FlashSpeedUp(x) = 0.01
- FlashSpeedDown(x) = 0.008
- next
- for x = 304 to 307 'More Animations (boogie rotations)
- FlashLevel(x) = 0
- FlashSpeedUp(x) = 0.03
- FlashSpeedDown(x) = 0.01
- next
- FlashMin(304) = -1 '0
- FlashMin(305) = -1
- FlashMax(304) = 16 '17
- FlashMax(305) = 16 'boogiemen RotX min/max rotations
- FlashSpeedUp(304) = FlashSpeedUp(304) * FlashMax(304)
- FlashSpeedUp(305) = FlashSpeedUp(305) * FlashMax(305)
- FlashSpeedDown(304) = FlashSpeedDown(304) * FlashMax(304)
- FlashSpeedDown(305) = FlashSpeedDown(305) * FlashMax(305)
- ' BoogiemanAnim(nr, Object, Frames)
- BoogieDuration = 550 '450 'special fadingspeeds for boogiemen animation, total duration
- for x = 308 to 310 'Sling Rubber animations
- FlashSpeedUp(x) = 0.2'0.0267
- FlashSpeedDown(x) = 0.009'0.008
- next
- for x = 200 to 203 'GI relay on / off
- FlashSpeedUp(x) = 0.01
- FlashSpeedDown(x) = 0.008
- Next
- for x = 300 to 303 'GI 8 step modulation
- FlashSpeedUp(x) = 0.01
- FlashSpeedDown(x) = 0.008
- Next
- flashspeedup(cCardDT) = 0.005 : flashspeedup(cCardFS) = flashspeedup(cCardDT) 'card speeds
- flashspeedDown(cCardDT) = 0.006 : flashspeedDown(cCardFS) = flashspeedDown(cCardDT)
- for x = 0 to (aFlashers.Count - 1)
- On Error Resume Next
- If aFlashers(x).Opacity > 0 then aFlashers(x).uservalue = aFlashers(x).Opacity
- If aFlashers(x).Intensity > 0 then aFlashers(x).UserValue = aFlashers(x).Intensity
- ' aFlashers(x).state = 1 'nf todo
- Next
- for x = 0 to (aFlashers.Count - 1) 'Put Flasher Opacity in an Array for FadeGI scaling brightness up when GI is off
- On Error Resume Next
- FlashersOpacity(x) = aFlashers(x).Uservalue
- Next
- for x = 0 to (Lamps.Count - 1)
- On Error Resume Next
- If Lamps(x).Opacity > 0 then Lamps(x).uservalue = Lamps(x).Opacity
- If Lamps(x).Intensity > 0 then Lamps(x).UserValue = Lamps(x).Intensity
- Next
- 'Put light-based insert intensity into array along with fading speed
- for x = 0 to (Lamps.Count - 1)
- On Error Resume Next
- InsertFading(x, 0) = Lamps(x).UserValue
- insertfading(x, 1) = Lamps(x).FadeSpeedUp
- insertfading(x, 2) = Lamps(x).FadeSpeedDown
- Next
- ' dim s, i 'old array where I apparently thought it was very important to order the names correctly
- ' i = 0
- ' for each x in Lamps 'setup array
- ' On Error Resume Next
- ' s = mid(x.name, 2, 2) 'take L off the lamp
- '' if s = "lS" then Continue For 'skip some garbage in the lamp collection
- ' i = cInt(s) 'convert string to integer to get the lampnumber
- ' insertfading(i, 0) = i
- ' insertfading(i, 1) = x.fadespeedup
- ' insertfading(i, 2) = x.fadespeeddown
- ' next
- End Sub
- '======================
- 'Animation constants
- '======================
- 'Update states
- Const cCoffin = 205
- Const cCadaver = 206
- Const cCrate = 207
- 'Animations
- Const cBoogieL = 304 'Boogie L body
- Const cBoogieR = 305 'Boogie R body
- Const cBoogieLarms = 306 'Boogie L arms
- Const cBoogieRarms = 307 'Boogie R arms
- Const cLeftSling = 308
- Const cRightSling = 309
- Const cTopSling = 310
- Const cCardDT = 311 'ScoreCard DT
- Const cCardFS = 312 'ScoreCard FS
- 'Fading
- Const cSpiderFade = 398 ' Spider fade up/down (in Single-Screen FS)
- Const cGIon = 200
- Const cGIMod = 300
- dim CGT, InitFadeTime(1)
- Sub GameTimer_Timer()
- cgt = gametime - InitFadeTime(0)
- Dim chgLamp, num, chg, ii
- chgLamp = Controller.ChangedLamps
- If Not IsEmpty(chgLamp) Then
- For ii = 0 To UBound(chgLamp)
- LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
- FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
- Next
- End If
- UpdateLamps
- spiderFS cSpiderFade 'handles spider opacity fading in Single-Screen FS
- FadeAnimation cCardDT, ScoreCardDT
- FadeAnimation cCardFS, ScoreCardFS
- UpdateFlippers
- UpdateCoffin cCoffin
- UpdateCadaver cCadaver
- UpdateCrate cCrate
- ' FadeAnimationRotXm(Nr, Object1, object2, input) 'primitive animate RotX - Set up start and endpoints in FlashMin and FlashMax
- FadeAnimRotX cBoogieL, Boogie1, BoogieArms1, 100 'nr, object1, object2, auto loop / delay
- FadeAnimRotX cBoogieR, Boogie2, BoogieArms2, 100
- BoogieManAnim cBoogieLarms, Boogiearms1, 4
- BoogieManAnim cBoogieRarms, BoogieArms2, 4
- '2 frame animation for rubber (0 = resting, 1 = extended) + RotX sling kicker rotation
- ' AnimateSlingshot 308, Sling1, SlingK1, 23, 16 'nr, rubber, kicker, kicker RotX, MS Delay
- ' AnimateSlingshot 309, Sling2, SlingK2, 23, 16 'Right Sling
- ' AnimateSlingshot 310, Sling3, SlingK3, 23, 16 'Top Sling
- FadeAnimShowFrame cLeftSling, Sling1, SlingK1, 23, 100 'nr, rubber, kicker, kicker RotX, MS Delay
- FadeAnimShowFrame cRightSling, Sling2, SlingK2, 23, 100 'Right Sling
- FadeAnimShowFrame cTopSling, Sling3, SlingK3, 23, 100 'Top Sling
- ' FadeGi 0, 100 'Top 'On-Off relay, 0-8 step (via SolModValue)
- ' FadeGi 1, 101 'Middle
- '''' FadeGI 2, 102 'Bottom 'right now everything playfield related is handled by this one
- ' FadeGI 3, 103 'backglass
- FadeGI cGIon
- ModGI cGImod
- UpdateGIObjects cGIon, cGImod, GI2, GIscale(2) '(nr, nr2, GIarray, GIscaleOff)
- FadeLut cGIon, cGImod, "LutCont_", 27
- ' FadeLut 200, 300, "LutSF_", 21 'Nr1(on/off), Nr2(Mod), LUT name prefix, max number of luts
- nModFlashInterp 167, f17f, 15, 0.8 'bulb flasher
- nModFlashInterp 117, f17, 0, 0.5 'X ambient flasher
- nModFlashMInterp 117, f17t 'Transmit
- nModFlashInterp 168, f18f, 15, 0.8 'bulb flasher
- nModFlashInterp 118, f18, 0, 0.5 'X ambient flasher
- nModFlashMInterp 118, f18t 'Transmit
- nModFlashInterp 169, f19f, 15, 0.8 'bulb flasher
- nModFlashInterp 119, f19, 0, 0.5 'X ambient flasher
- nModFlashMInterp 119, f19t 'Transmit
- nModFlashMAvgM Bumperw, 117, 118, 119 'f17, f18, f19 sidewall. avg'd together
- nModFlashInterp 120, f20n, 0, 0 'ballsave Flasher
- nModFlashMInterp 120, f20a1
- nModFlashMInterp 120, f20a2
- nModFlashInterp 121, f21F, 0, 0 'deadheads 1
- nModFlashInterp 123, f23, 0, 0 'Bony Beast
- nModFlashInterp 125, f25F, 0, 0 'deadheads 2
- nModFlashInterp 126, f26n, 0, 0 'insert (TV flasher)
- nModFlashInterp 177, f27f, 9, 1 'bulb falsher
- nModFlashInterp 127, F27N, 0, 0.67
- nModFlashMInterp 127, F27side 'Ambient / sidewalls
- nModFlashMInterp 127, F27a
- nModFlashMInterp 127, f27t 'skeleton transmit
- nModFlashInterp 172, F22F, 9, 1', 9, 0.6
- nModFlashInterp 122, f22N, 0, 0.67
- nModFlashMInterp 122, F22side
- nModFlashMInterp 122, F22a
- nModFlashMInterp 122, f22t 'skeleton transmit
- nModFlashInterp 174, f24f, 9, 1 'bulb falsher
- nModFlashInterp 124, F24N, 0, 0.67', 9, 0.6
- nModFlashMInterp 124, F24side
- nModFlashMInterp 124, F24a
- nModFlashInterp 178, f28f, 9, 1 'bulb falsher
- nModFlashInterp 128, F28N, 0, 0.67', 9, 0.6
- nModFlashMInterp 128, F28side
- nModFlashMInterp 128, F28a
- nModFlashMInterp 128, f28t 'skeleton transmit
- nModFlashInterp 185, f35f, 9, 1 'old bulb falsher
- nModFlashInterp 135, f35n, 0, 0.67 'transmit orb
- nModFlashMInterp 135, F35side
- nModFlashMInterp 135, F35a
- nModFlashInterp 186, f36f, 9, 1 'bulb falsher
- nModFlashInterp 136, F36N, 0, 0.67', 9, 0.6
- nModFlashMInterp 136, F36side
- nModFlashMInterp 136, F36a
- nModFlashMInterp 136, f36t 'skeleton transmit
- InitFadeTime(0) = gametime
- End Sub
- Sub nModFlashMAvgM(object, nr1, nr2, nr3) 'one object, contribution from three solmod flashlevels
- If FadingLevel(nr1) < 2 and FadingLevel(nr2) < 2 and FadingLevel(nr3) < 2 then exit Sub
- dim avg
- avg = ((FlashLevel(nr1) + FlashLevel(nr2) + FlashLevel(nr3)) /3)
- if avg < 0 then avg = 0
- avg = ScaleLights(avg, 0)
- ' tb.text = avg
- object.IntensityScale = avg
- End Sub
- '***********
- ' Update GI
- '***********
- 'Sub UpdateGIOn(no, Enabled) : Setlamp no+200, cInt(enabled) : End Sub
- Sub UpdateGIOn(no, Enabled) : Setlamp no+200, cInt(enabled) : End Sub 'cGIon = 200 'cGImod = 300
- Sub UpdateGI(no, step)
- Dim ii, x', i
- If step = 0 then exit sub 'only values from 1 to 8 are visible and reliable. 0 is not reliable and 7 & 8 are the same so...
- SetModLamp no+300, ScaleGI(step, 0)
- LampState((no+300)) = 0
- ' if no = 2 then tb.text = no & vbnewline & step & vbnewline & ScaleGI(step,0) & SolModValue(102)
- End Sub
- dim LSstate : LSstate = False 'fading sub handles SFX
- Sub FadeGI(nr) 'in On/off 'Updates nothing but flashlevel
- Select Case FadingLevel(nr)
- Case 3
- FadingLevel(nr) = 0
- Case 4 'off
- ' If Not LSstate then Playsound "FX_Relay_Off",0, LVL(0.1) : LSstate = True 'handle SFX
- FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * CGT)
- If FlashLevel(nr) < FlashMin(nr) Then
- FlashLevel(nr) = FlashMin(nr)
- FadingLevel(nr) = 3 'completely off
- ' LSstate = False
- End if
- Case 5 ' on
- ' If Not LSstate then Playsound "FX_Relay_On",0, LVL(0.1) : LSstate = True 'handle SFX
- FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * CGT)
- If FlashLevel(nr) > FlashMax(nr) Then
- FlashLevel(nr) = FlashMax(nr)
- FadingLevel(nr) = 6 'completely on
- ' LSstate = False
- End if
- Case 6
- FadingLevel(nr) = 1
- End Select
- End Sub
- Sub ModGI(nr2) 'in 0->1 'Updates nothing but flashlevel 'never off
- dim DesiredFading
- Select Case FadingLevel(nr2)
- case 3 'workaround - wait a frame to let M sub finish fading
- FadingLevel(nr2) = 0
- ' Case 4 'off -disabled off, only gicallback1 can turn off GI(?)
- ' FadingLevel(nr2) = 3
- Case 5, 4 ' Fade (Dynamic)
- DesiredFading = SolModValue(nr2)
- if FlashLevel(nr2) < DesiredFading Then '+
- FlashLevel(nr2) = FlashLevel(nr2) + (FlashSpeedUp(nr2) * cgt )
- If FlashLevel(nr2) >= DesiredFading Then FlashLevel(nr2) = DesiredFading : FadingLevel(nr2) = 1
- elseif FlashLevel(nr2) > DesiredFading Then '-
- FlashLevel(nr2) = FlashLevel(nr2) - (FlashSpeedDown(nr2) * cgt )
- If FlashLevel(nr2) <= DesiredFading Then FlashLevel(nr2) = DesiredFading : FadingLevel(nr2) = 6
- End If
- Case 6
- FadingLevel(nr2) = 1
- End Select
- End Sub
- Sub UpdateGIobjects(nr, nr2, a, GIscaleOff)
- ' tbgi.text = "GI: " & SolModValue(nr) & " " & FlashLevel(nr) & " " & FadingLevel(nr) & vbnewline & _
- ' "ModGI: " & SolModValue(nr2) & " " & FlashLevel(nr2) & " " & FadingLevel(nr2) & vbnewline & _
- ' "Solmodvalue, Flashlevel, Fading step"
- If FadingLevel(nr) > 1 or FadingLevel(nr2) > 1 Then
- dim OutputF : OutputF = InterpolateV(FlashLevel(nr2) * FlashLevel(nr) )
- dim OutputL : OutputL = Interpolate(FlashLevel(nr2) * FlashLevel(nr) )
- dim GiscalerF, giscalerL, x
- 'Update GI
- for each x in a
- x.IntensityScale = OutputL
- next
- GiscalerF = ((Giscaleoff-1) * (ABS(OutputF-1) ) ) + 1 'fade GIscale the opposite direction
- GiscalerL = ((Giscaleoff-1) * (ABS(OutputL-1) ) ) + 1 'fade GIscale the opposite direction
- 'Handle Compensate Flashers
- for x = 0 to (aFlashers.Count - 1)
- On Error Resume Next
- AFlashers(x).Opacity = FlashersOpacity(x) * GiscalerF
- AFlashers(x).Intensity = FlashersOpacity(x) * GiscalerF
- next
- for x = 0 to (BallReflections.Count - 1)
- BallReflections(x).IntensityScale = OutputL
- next
- for x = 0 to (Lamps.Count - 1)
- On Error Resume Next
- Lamps(x).Opacity = InsertFading(x, 0) * GiscalerL
- Lamps(x).Intensity = InsertFading(x, 0) * GiscalerL
- Lamps(x).FadeSpeedUp = InsertFading(x, 1) * GiscalerL
- Lamps(x).FadeSpeedDown = InsertFading(x, 2) * GiscalerL
- Next
- ' tbbb.text = giscaler & " on:" & FadingLevel(nr) & vbnewline & "flash: " & output & " onmod:" & FadingLevel(nr2) & vbnewline & l37.intensity
- ' tbbb1.text = FadingLevel(nr) & vbnewline & FadingLevel(nr2)
- ' tbgi1.text = Output & " giscale:" & giscaler 'debug
- End If
- ' tbbb1.text = FLashLevel(nr) & vbnewline & FlashLevel(nr2)
- end Sub
- Sub FadeLUT(nr, nr2, LutName, LutCount) 'fade lookuptable NOTE- this is a bad idea for darkening your table as
- If FadingLevel(nr) >2 or FadingLevel(nr2) > 2 Then '-it will strip the whites out of your image
- dim GoLut
- GoLut = cInt(LutCount * (FlashLevel(nr)*FlashLevel(nr2) ) )
- Table1.ColorGradeImage = LutName & GoLut
- ' tbgi2.text = Table1.ColorGradeImage & vbnewline & golut 'debug
- End If
- End Sub
- Sub nModFlash(nr, object, scaletype, offscale) 'Fading using intensityscale with modulated callbacks 'gametime compensated
- dim DesiredFading
- Select Case FadingLevel(nr)
- case 3 'workaround - wait a frame to let M sub finish fading
- FadingLevel(nr) = 0
- Case 4 'off
- If Offscale = 0 then Offscale = 1
- FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * cgt ) * offscale
- If FlashLevel(nr) < 0 then FlashLevel(nr) = 0 : FadingLevel(nr) = 3
- Object.IntensityScale = ScaleLights(FlashLevel(nr),0 )
- Case 5 ' Fade (Dynamic)
- DesiredFading = ScaleByte(SolModValue(nr), scaletype)
- if FlashLevel(nr) < DesiredFading Then '+
- FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * cgt )
- If FlashLevel(nr) >= DesiredFading Then FlashLevel(nr) = DesiredFading : FadingLevel(nr) = 1
- elseif FlashLevel(nr) > DesiredFading Then '-
- FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * cgt )
- If FlashLevel(nr) <= DesiredFading Then FlashLevel(nr) = DesiredFading : FadingLevel(nr) = 6
- End If
- Object.Intensityscale = ScaleLights(FlashLevel(nr),0 )' * GIscale * Nmult(nr)
- Case 6
- FadingLevel(nr) = 1
- End Select
- End Sub
- Sub nModFlashInterp(nr, object, scaletype, offscale) 'Fading using intensityscale with modulated callbacks 'gametime compensated
- dim DesiredFading
- Select Case FadingLevel(nr)
- case 3 'workaround - wait a frame to let M sub finish fading
- FadingLevel(nr) = 0
- Case 4 'off
- If Offscale = 0 then Offscale = 1
- FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * cgt ) * offscale
- If FlashLevel(nr) < 0 then FlashLevel(nr) = 0 : FadingLevel(nr) = 3
- Object.IntensityScale = ScaleLights(FlashLevel(nr),0 )
- Case 5 ' Fade (Dynamic)
- DesiredFading = ScaleByte(SolModValue(nr), scaletype)
- if FlashLevel(nr) < DesiredFading Then '+
- FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * cgt )
- If FlashLevel(nr) >= DesiredFading Then FlashLevel(nr) = DesiredFading : FadingLevel(nr) = 1
- elseif FlashLevel(nr) > DesiredFading Then '-
- FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * cgt )
- If FlashLevel(nr) <= DesiredFading Then FlashLevel(nr) = DesiredFading : FadingLevel(nr) = 6
- End If
- Object.Intensityscale = InterpolateV(ScaleLights(FlashLevel(nr),0 ) )' * GIscale * Nmult(nr)
- Case 6
- FadingLevel(nr) = 1
- End Select
- ' tb.text = f27n.intensityscale
- End Sub
- Sub nModFlashMInterp(nr, Object)
- Select Case FadingLevel(nr)
- Case 3, 4, 5, 6
- Object.Intensityscale = InterpolateV(ScaleLights(FlashLevel(nr),0 ) )' * GIscale(nr)
- End Select
- End Sub
- Function Interpolate(x) 'smooth, subtle 0-1 interpolation
- ' Interpolate = -x^3/3 + x^2/2 + (5*x)/6 '0-0-1-1
- Interpolate = -x^3/3 + x^2/2 + (5*x)/6 '0-0-1-1
- End Function
- Function InterpolateV(x) 'The V stands for 'very much' interpolation
- ' InterpolateV = -0.217469*x^3 + 1.10481*x^2 + 0.112656*x - 2.22045*10^-16 'Very low-end heavy
- 'InterpolateV = -1.94137*x^3 + 2.91206*x^2 + 0.0293147*x + 0 'Balanced but heavy
- 'InterpolateV = 2*x - x^2 'Top heavy
- 'InterpolateV = (4*x)/3 - x^3/3 'Top heavy 2
- InterpolateV = -(2*x^3)/3 + x^2 + (2*x)/3'balanced
- if InterpolateV < 0 then InterpolateV = 0
- End Function
- Sub nModFlashM(nr, Object)
- Select Case FadingLevel(nr)
- Case 3, 4, 5, 6
- Object.Intensityscale = ScaleLights(FlashLevel(nr),0 )' * GIscale(nr)
- End Select
- End Sub
- Sub Flashc(nr, object)
- Select Case FadingLevel(nr)
- Case 3
- FadingLevel(nr) = 0
- Case 4 'off
- FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * CGT)
- If FlashLevel(nr) < FlashMin(nr) Then
- FlashLevel(nr) = FlashMin(nr)
- FadingLevel(nr) = 3 'completely off
- End if
- Object.IntensityScale = Interpolate(FlashLevel(nr) )
- Case 5 ' on
- FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * CGT)
- If FlashLevel(nr) > FlashMax(nr) Then
- FlashLevel(nr) = FlashMax(nr)
- FadingLevel(nr) = 6 'completely on
- End if
- Object.IntensityScale = Interpolate(FlashLevel(nr) )
- Case 6
- FadingLevel(nr) = 1
- End Select
- End Sub
- Sub Flashm(nr, object) 'multiple flashers, it just sets the flashlevel
- select case FadingLevel(nr)
- case 3, 4, 5, 6
- Object.IntensityScale = Interpolate(FlashLevel(nr) )
- end select
- End Sub
- Function ScaleLights(value, scaletype) 'returns an intensityscale-friendly 0->100% value out of 255
- dim i
- Select Case scaletype 'select case because bad at maths 'TODO: Simplify these functions. B/c this is absurdly bad.
- case 0
- i = value * (1 / 255) '0 to 1
- case 6 '0.0625 to 1
- i = (value + 17)/272
- case 9 '0.089 to 1
- i = (value + 25)/280
- case 15
- i = (value / 300) + 0.15
- case 20
- i = (4 * value)/1275 + (1/5)
- case 25
- i = (value + 85) / 340
- case 37 '0.375 to 1
- i = (value+153) / 408
- case 40
- i = (value + 170) / 425
- case 50
- i = (value + 255) / 510 '0.5 to 1
- case 75
- i = (value + 765) / 1020 '0.75 to 1
- case Else
- i = 10
- End Select
- ScaleLights = i
- End Function
- Function ScaleByte(value, scaletype) 'returns a number between 1 and 255
- dim i
- Select Case scaletype
- case 0
- i = value * 1 '0 to 1
- case 9 'ugh
- i = (5*(200*value + 1887))/1037
- case 15
- i = (16*value)/17 + 15
- case else
- i = (3*(value + 85))/4 '63.75 to 255
- End Select
- ScaleByte = i
- End Function
- Function ScaleGI(value, scaletype) 'returns an intensityscale-friendly 0->100% value out of 1>8 'it does go to 8
- dim i
- Select Case scaletype 'select case because bad at maths
- case 0
- i = value * (1/8) '0 to 1
- case 25
- i = (1/28)*(3*value + 4)
- case 50
- i = (value+5)/12
- case else
- ' x = (4*value)/3 - 85 '63.75 to 255
- End Select
- ScaleGI = i
- End Function
- Function ScaleFalloff(value, nr)
- select case nr
- ' case 122, 124, 127, 128, 135, 136
- ' ScaleFalloff = (value+170)/425 '0.4 to 1
- case 123
- ScaleFalloff = 1
- case else
- ScaleFalloff = (value + 765) / 1020 '0.75 to 1
- end select
- End Function
- '=============================
- 'Animation Subs (Fading Script)
- '=============================
- Sub FadeAnimation(Nr, Object) 'primitive animation - Set up start and endpoints in FlashMin and FlashMax (here it's used just between frame 0 and 1)
- Select Case FadingLevel(nr)
- Case 4
- FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * CGT)
- If FlashLevel(nr) < FlashMin(nr) Then
- FlashLevel(nr) = FlashMin(nr)
- FadingLevel(nr) = 0 'completely off
- End if
- Object.ShowFrame InterpolateV(FlashLevel(nr) )
- Case 5
- FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * CGT)
- If FlashLevel(nr) > FlashMax(nr) Then
- FlashLevel(nr) = FlashMax(nr)
- FadingLevel(nr) = 1 'completely on
- End if
- Object.ShowFrame InterpolateV(FlashLevel(nr) )
- End Select
- End Sub
- '
- 'dim ms : ms = 0
- 'Sub tbC_Timer()
- ' dim x
- ' x = "hi"
- ' ms = ms + 1 * CGT
- '
- ' tbc.text = ms & vbnewline & _
- ' "Frametime: " & CGT & vbnewline & _
- ' x
- '
- 'End Sub
- ' '2 frame animation for rubber (0 = resting, 1 = extended) + RotX sling kicker rotation
- ' AnimateSlingshot 101, Sling1, SlingK1, 23, 12 'nr, rubber, kicker, kicker RotX, MS Delay
- Sub AnimateSlingShot(nr, object1, object2, rotation, delay)
- Select Case FadingLevel(nr)
- Case 4
- FadingLevel(nr) = 0
- Case 5 'Part 1 - Extend immediately
- FlashLevel(nr) = 1
- object1.ShowFrame FlashLevel(nr)'1
- Object2.RotX = FlashLevel(nr) * rotation
- SolModValue(nr) = 0 + CGT
- FadingLevel(nr) = 6
- LampState(nr) = 0 'ignore lampstate
- Case 6 'Handle Delay (crude)
- if cgt < (delay/2) Then FadingLevel(nr) = 7 else FadingLevel(nr) = 8
- case 7' 'Handle Delay (Crude)
- FadingLevel(nr) = 8
- case 8 'linear falloff
- FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr)*CGT)
- If FlashLevel(nr) < FlashMin(nr) Then
- FlashLevel(nr) = FlashMin(nr)
- FadingLevel(nr) = 0 'completely off
- End if
- object1.Showframe FlashLevel(nr)
- object2.RotX = FlashLevel(nr)*rotation
- End Select
- End Sub
- dim LeftOvers(450)
- Dim EndPoint(450)
- Sub FadeAnimRotX(Nr, Object1, object2, input) 'primitive animate RotX - Set up start and endpoints in FlashMin and FlashMax
- dim KeyframeMult
- Select Case FadingLevel(nr)
- Case 5 'init
- 'frames = 4
- LampState(nr) = 0
- FlashLevel(nr) = 0
- SolModValue(nr) = 0
- SolModValue(nr) = SolModValue(nr) + CGT 'Track ms
- KeyframeMult = 1
- FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * KeyframeMult * CGT)
- object1.RotX = FlashLevel(nr)
- object2.RotX = FlashLevel(nr)
- FadingLevel(nr) = 6
- ' debug.print FlashLevel(nr) & " " & FadingLevel(nr)
- ' tbL.text = "Step:" & fadinglevel(nr) & vbnewline & _
- ' "Lvl: " & FlashLevel(nr) & vbnewline & _
- ' "ms : " & SolModValue(nr) & vbnewline & _
- ' "endpoint: " & EndPoint(nr) & vbnewline & _
- ' "delay: " & input & vbnewline & _
- ' "leftovers: " & LeftOvers(nr) & vbnewline & _
- ' SolModValue(nr) - EndPoint(nr) + LeftOvers(nr)
- Case 6 'dive forward
- SolModValue(nr) = SolModValue(nr) + CGT 'update MS counter
- KeyFrameMult = 1
- FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * KeyframeMult * CGT)
- If FlashLevel(nr) > FlashMax(nr) then
- leftovers(nr) = FlashLevel(nr) - FlashMax(nr)
- FlashLevel(nr) = FlashMax(nr)
- if input < 0 then 'if less than 0, end script
- FadingLevel(nr) = 1
- Else
- EndPoint(nr) = SolModValue(nr)
- FadingLevel(nr) = 7 'otherwise, reverse direction
- End If
- End If
- object1.RotX = FlashLevel(nr)
- object2.RotX = FlashLevel(nr)
- ' debug.print FlashLevel(nr) & " " & FadingLevel(nr)
- ' tbL.text = "Step:" & fadinglevel(nr) & vbnewline & _
- ' "Lvl: " & FlashLevel(nr) & vbnewline & _
- ' "ms : " & SolModValue(nr) & vbnewline & _
- ' "endpoint: " & EndPoint(nr) & vbnewline & _
- ' "delay: " & input & vbnewline & _
- ' "leftovers: " & LeftOvers(nr) & vbnewline & _
- ' SolModValue(nr) - EndPoint(nr) + LeftOvers(nr)
- Case 7 'Delay, Swing Back
- SolModValue(nr) = SolModValue(nr) + CGT 'update MS counter
- 'If new Timer < Delay
- if SolModValue(nr) - EndPoint(nr) + LeftOvers(nr) <= input Then 'if MS < delay, DELAY
- KeyFrameMult = 0
- elseif SolModValue(nr) - EndPoint(nr) >= input + CGT Then
- Leftovers(nr) = 0
- KeyFrameMult = 1
- elseif SolModValue(nr) - EndPoint(nr) >= input - CGT then 'delay over, add leftovers to flashlevel
- Leftovers(nr) = (SolModValue(nr) - EndPoint(nr) ) - input '35 - 16 - 16
- Else
- ' tb.text = "???"
- End If
- FlashLevel(nr) = FlashLevel(nr) - ((FlashSpeedDown(nr) - Leftovers(nr) ) * KeyframeMult * CGT)
- If FlashLevel(nr) < FlashMin(nr) then
- FlashLevel(nr) = FlashMin(nr)
- FadingLevel(nr) = 0
- End If
- object1.RotX = FlashLevel(nr)
- object2.RotX = FlashLevel(nr)
- ' debug.print FlashLevel(nr) & " " & FadingLevel(nr)
- ' tbL.text = "Step:" & fadinglevel(nr) & vbnewline & _
- ' "Lvl: " & FlashLevel(nr) & vbnewline & _
- ' "ms : " & SolModValue(nr) & vbnewline & _
- ' "endpoint: " & EndPoint(nr) & vbnewline & _
- ' "delay: " & input & vbnewline & _
- ' "leftovers: " & LeftOvers(nr) & vbnewline & _
- ' SolModValue(nr) - EndPoint(nr) + LeftOvers(nr)
- End Select
- End Sub
- Sub FadeAnimShowFrame(nr, object1, object2, rotation, input) 'primitive animate RotX - Set up start and endpoints in FlashMin and FlashMax
- dim KeyframeMult
- Select Case FadingLevel(nr)
- Case 5 'init
- 'frames = 4
- LampState(nr) = 0
- FlashLevel(nr) = 0
- SolModValue(nr) = 0
- SolModValue(nr) = SolModValue(nr) + CGT 'Track ms
- KeyframeMult = 1
- FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * KeyframeMult * CGT)
- object1.ShowFrame FlashLevel(nr)
- object2.RotX = FlashLevel(nr) * Rotation
- FadingLevel(nr) = 6
- ' debug.print FlashLevel(nr) & " " & FadingLevel(nr)
- ' tbL.text = "Step:" & fadinglevel(nr) & vbnewline & _
- ' "Lvl: " & FlashLevel(nr) & vbnewline & _
- ' "ms : " & SolModValue(nr) & vbnewline & _
- ' "endpoint: " & EndPoint(nr) & vbnewline & _
- ' "delay: " & input & vbnewline & _
- ' "leftovers: " & LeftOvers(nr) & vbnewline & _
- ' SolModValue(nr) - EndPoint(nr) + LeftOvers(nr)
- Case 6 'dive forward
- SolModValue(nr) = SolModValue(nr) + CGT 'update MS counter
- KeyFrameMult = 1
- FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * KeyframeMult * CGT)
- If FlashLevel(nr) > FlashMax(nr) then
- leftovers(nr) = FlashLevel(nr) - FlashMax(nr)
- FlashLevel(nr) = FlashMax(nr)
- if input < 0 then 'if less than 0, end script
- FadingLevel(nr) = 1
- Else
- EndPoint(nr) = SolModValue(nr)
- FadingLevel(nr) = 7 'otherwise, reverse direction
- End If
- End If
- object1.ShowFrame FlashLevel(nr)
- object2.RotX = FlashLevel(nr) * Rotation
- ' debug.print FlashLevel(nr) & " " & FadingLevel(nr)
- ' tbL.text = "Step:" & fadinglevel(nr) & vbnewline & _
- ' "Lvl: " & FlashLevel(nr) & vbnewline & _
- ' "ms : " & SolModValue(nr) & vbnewline & _
- ' "endpoint: " & EndPoint(nr) & vbnewline & _
- ' "delay: " & input & vbnewline & _
- ' "leftovers: " & LeftOvers(nr) & vbnewline & _
- ' SolModValue(nr) - EndPoint(nr) + LeftOvers(nr)
- Case 7 'Delay, Swing Back
- SolModValue(nr) = SolModValue(nr) + CGT 'update MS counter
- 'If new Timer < Delay
- if SolModValue(nr) - EndPoint(nr) + LeftOvers(nr) <= input Then 'if MS < delay, DELAY
- KeyFrameMult = 0
- elseif SolModValue(nr) - EndPoint(nr) >= input + CGT Then
- Leftovers(nr) = 0
- KeyFrameMult = 1
- elseif SolModValue(nr) - EndPoint(nr) >= input - CGT then 'delay over, add leftovers to flashlevel
- Leftovers(nr) = (SolModValue(nr) - EndPoint(nr) ) - input '35 - 16 - 16
- Else
- ' tb.text = "???"
- End If
- FlashLevel(nr) = FlashLevel(nr) - ((FlashSpeedDown(nr) - Leftovers(nr) ) * KeyframeMult * CGT)
- If FlashLevel(nr) < FlashMin(nr) then
- FlashLevel(nr) = FlashMin(nr)
- FadingLevel(nr) = 0
- End If
- object1.ShowFrame FlashLevel(nr)
- object2.RotX = FlashLevel(nr) * Rotation
- ' debug.print FlashLevel(nr) & " " & FadingLevel(nr)
- ' tbL.text = "Step:" & fadinglevel(nr) & vbnewline & _
- ' "Lvl: " & FlashLevel(nr) & vbnewline & _
- ' "ms : " & SolModValue(nr) & vbnewline & _
- ' "endpoint: " & EndPoint(nr) & vbnewline & _
- ' "delay: " & input & vbnewline & _
- ' "leftovers: " & LeftOvers(nr) & vbnewline & _
- ' SolModValue(nr) - EndPoint(nr) + LeftOvers(nr)
- End Select
- End Sub
- dim BoogieDuration' : BoogieDuration = 100
- Sub BoogiemanAnim(nr, Object, Frames) ' 'More complicated keyframe animation
- dim KeyframeMult
- Select Case FadingLevel(nr)
- Case 5
- ' Dim KeyframeMult
- 'frames = 4
- ' Duration = FlashSpeedUp(106)
- LampState(nr) = 0
- FlashLevel(nr) = 0
- SolModValue(nr) = 0
- SolModValue(nr) = SolModValue(nr) + CGT 'Track ms
- FlashSpeedUp(nr) = Frames / (BoogieDuration / CGT) '0.32 at 8 frame time
- KeyframeMult = 2.29167'Always 0 to Start
- FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * KeyframeMult)
- object.ShowFrame FlashLevel(nr)
- FadingLevel(nr) = 6
- ' debug.print FlashLevel(nr)
- Case 6
- if SolModValue(nr) > (0.45*BoogieDuration) Then
- KeyFrameMult = 0.605
- Elseif SolModValue(nr) > (0.14*BoogieDuration) then
- KeyFrameMult = 1.06765
- Else
- KeyFrameMult = 2.2917
- End If
- SolModValue(nr) = SolModValue(nr) + CGT
- FlashSpeedUp(nr) = Frames / (BoogieDuration / CGT) '0.32 at 8 frame time
- FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * KeyframeMult)
- If FlashLevel(nr) > Frames then
- FlashLevel(nr) = Frames
- FadingLevel(nr) = 1
- End If
- object.ShowFrame FlashLevel(nr)
- ' debug.print FlashLevel(nr)
- 'Keyframes (in %)
- 'frame 0 -> 1
- '....14.54545454545454% 'arching back
- 'i 42.72727272727273
- 'frame 1 -> 2
- '...30.909091% 'stretching forward
- 'i 34.5454545
- 'frame 2 -> 3
- '...54.54545454545455% 'Resetting back to 0
- 'i 22.72727272727273
- '14.545
- '45.45454545454545
- '100
- End Select
- End Sub
- '=============================
- '=============================
- 'flasher locations:
- 'f27 f22
- 'f24 f28
- 'f35 f36
- ''***********
- '' Update GI
- ''***********
- 'Sub UpdateGIOn(no, Enabled) : Setlamp no, cInt(enabled) : tb.text = no & vbnewline & cInt(enabled) : End Sub
- 'Sub UpdateGI(no, step)
- ' Dim ii, x', i
- ' If step = 0 then exit sub 'only values from 1 to 8 are visible and reliable. 0 is not reliable and 7 & 8 are the same so...
- ' SetModLamp no+100, ScaleGI(step, 0)
- ' if no = 2 then tb.text = step & vbnewline & ScaleGI(step,0)
- 'End Sub
- 'cutting down the intensity a bit
- 'min 50% intensityscale
- 'x = intensityscale y = gistep
- 'x1= 0.5 y1= 1
- 'x2= 1 y2= 7
- 'solve for slope
- ''m = (y2 - y1) / (x2 - x1)
- ' (7 - 1) / (1 - 0.5)
- ' 6 / 0.5
- 'm = 12
- 'point slope formula
- 'y - y1 = m(x-x1)
- ' y - 1 = 12(x-0.5)
- 'y = 12x -5
- 'x = (y+5)/12
- Sub DebugLampsOn(i)
- dim x
- for each x in Lamps
- x.state = i
- next
- End Sub
- Sub DebugFlashers(x)
- ' setlamp 122, x
- ' Setlamp 127, x
- ' setlamp 124, x
- ' setlamp 128, x
- ' setlamp 135, x
- ' setlamp 136, x
- '
- ' setlamp 172, x
- ' Setlamp 177, x
- ' setlamp 174, x
- ' setlamp 178, x
- ' setlamp 185, x
- ' setlamp 186, x
- ' f22.state = x
- ' f22b.state = x
- ' f27.state = x
- ' f27b.state = x
- ' F24.state = x
- ' f24b.state = x
- ' F28.state = x
- ' f28b.state = x
- ' F35.state = x
- ' f35b.state = x
- ' f36.state = x
- ' f36b.state = x
- End Sub
- 'Turn up inserts and flashers when GI is off Init
- dim FlashersA, FlashersB
- 'FlashersA = array(f22, f24, f27, f28, f35, F36)
- 'FlashersB = array(f22b, f24b, f27b, f28b, f35b, F36b)
- sub tweakflashers(input)
- dim x
- for each x in FlashersB
- x.intensity = input
- Next
- tb.text = "intensity: " & input
- End Sub
- '***************** Debug Stuff *************
- 'Sub Textboxnf_timer()
- 'dim i
- 'i = ((f35f.opacity / f35fI)) * 100
- 'i = cInt(i)
- 'textboxnf.text = "opacity:" & i & vbnewline & "Scale:" & f35f.intensityscale * 100 & _
- ' vbnewline & vbnewline & "FadeUp:" & f35.fadespeedup & vbnewline & "FadeDown" & f35.fadespeeddown
- 'end Sub
- 'flasher locations:
- 'f27 f22
- 'f24 f28
- 'f35 f36
- '======================
- 'Solenoid Callbacks
- '======================
- Dim LockPower, LockHold
- 'Solenoid routines
- Sub LDiverterPower(enabled)
- LockPower = enabled
- If enabled Then
- Lock.RotateToEnd
- If Lock.CurrentAngle < 207 then PlaySound SoundFX("DiverterLeft_Open",DOFContactors), 0, LVL(0.17), -0.06, 0.1
- End If
- If Not enabled AND Not LockHold Then
- Lock.RotateToStart
- PlaySound SoundFX("DiverterLeft_Close",DOFContactors), 0, LVL(0.05), -0.06, 0.1
- End If
- End Sub
- Sub LDiverterHold(enabled)
- LockHold = enabled
- If Not enabled AND Not LockPower Then Lock.RotateToStart
- End Sub
- 'Sub SolUpperSling(enabled)
- ' If Enabled Then
- ' PlaySound SoundFX("LeftSlingShotTrimmed",DOFContactors), 0, LVL(0.68), -0.005, 0.2
- ' Setlamp 310, 1
- ' End If
- 'End Sub
- Sub SolLeftSling(enabled)
- If Enabled Then
- PlaySound SoundFX("LeftSlingShotTrimmed",DOFContactors), 0, LVL(0.2), -0.015, 0.2
- setlampmm cBoogieL, cBoogieLarms, cLeftSling, 1 'Rubber/Kicker, Boogie Rot, Boogie Showframe Anim
- End If
- End sub
- Sub SolRightSling(enabled)
- If Enabled Then
- PlaySound SoundFX("RightSlingShot",DOFContactors), 0, LVL(0.2), 0.01, 0.2
- setlampmm cBoogieR, cBoogieRarms, cRightSling, 1 'Rubber/Kicker, Boogie Rot, Boogie Showframe Anim
- End If
- End Sub
- Sub SolCoffinPopper(Enabled)
- dim x
- If Enabled Then
- If bsCoffin.Balls Then
- bsCoffin.ExitSol_On
- BIP = BIP + 1
- FadingLevel(cCadaver) = 5
- ' TiCadaver.enabled = 1
- CoffinKicker.TimerEnabled = 1
- CoffinKicker.TimerInterval = 1500
- Playsound SoundFX("Kicker_Release",DOFContactors), 0, LVL(0.2), -0.015
- End If
- End If
- End Sub
- Sub SolLoopGate(Enabled)
- LoopGate.Open = Enabled
- End Sub
- Sub AutoPlunge(enabled)
- If Enabled Then
- IMAutoPlunger.Autofire
- playsound SoundFX("Kicker_Release",DOFcontactors), 0, LVL(0.3), 0.06,0.05
- if BallInPlunger then
- PlaySound SoundFX("Plunger3",0),0, LVL(0.3),0.06,0.05
- Else
- PlaySound SoundFX("plunger",0),0, LVL(0.3),0.06,0.05
- end if
- End if
- End Sub
- 'Sub CratePostPower(Enabled)
- ' If(Enabled) Then
- ' debugpower = 1
- '' sw57.IsDropped = 1
- '' Gate4.timerenabled = 1
- ' Else
- ' debugpower = 0
- '' CrateOpen = 0
- ' End If
- 'End Sub
- dim debughold, debugpower
- Sub CratePostHold(Enabled)
- ' sw57.IsDropped = Enabled
- sw57.Collidable = Not Enabled
- ' sw57.Visible = Enabled
- ' tb.text = "crateposthold: " & enabled & "sw57: " & sw57.collidable
- If enabled then
- debughold = 1
- CrateTrigger.Timerinterval = 1200
- CrateTrigger.timerenabled = 1
- ' crateopen = 1
- else
- debughold = 0
- CrateTrigger.Timerinterval = 1200
- CrateTrigger.timerenabled = 1
- end if
- ' if CratePostHold(enabled) Then
- ' sw57.IsDropped = Enabled
- ' Else
- ' sw57.IsDropped = Enabled
- ' Gate4.timerenabled = 1
- ' sw57.IsDropped = Enabled
- ' CrateOpen = Enabled
- End Sub
- sub CrateTrigger_Timer() 'helps transition animation
- if sw57.Collidable = False then
- crateopen = 1
- Else
- crateopen = 0
- end if
- ' textbox2.text = "crate updated"
- me.timerenabled = 0
- end sub
- Sub SolBallRelease(Enabled) 'trough release. Ballrelease
- If Enabled Then
- If bsTrough.Balls Then
- PlaySound SoundFX("BallReleaseRS",DOFcontactors), 0, LVL(0.4), 0.03
- vpmTimer.PulseSw 31
- bsTrough.ExitSol_On
- BIP = BIP + 1
- End If
- End If
- End Sub
- Dim CoffinDir
- Sub SolCoffinDoor(Enabled)
- If Enabled Then
- CoffinDir = -1
- Else
- CoffinDir = 1
- End If
- FadingLevel(cCoffin) = 5
- End Sub
- Sub UpdateCoffin(nr) 'gametimer
- Select Case FadingLevel(nr)
- case 5
- PrCoffinLid.RotY = PrCoffinLid.RotY + ((1.5*cgt )*CoffinDir) 'adjust speed here
- If PrCoffinLid.RotY <= -110 Then
- FadingLevel(nr) = 0
- PrCoffinLid.RotY = -110
- End If
- If PrCoffinLid.RotY >= 0 Then
- FadingLevel(nr) = 0
- PrCoffinLid.RotY = 0
- End If
- End Select
- End Sub
- '***************
- '* Lights
- '***************
- Sub UpdateLamps()
- FlashC 11, l11n
- FlashC 12, l12n
- FlashC 13, l13n
- FlashC 14, l14n
- FlashC 15, l15n
- FlashC 16, l16n
- FlashC 17, l17n
- If Not Proto then NFadeL 18, l18 'a beast eye
- FlashC 21, l21n
- FlashC 22, L22n
- FlashC 23, L23n
- FlashC 24, L24n
- FlashC 25, L25n'(l25, l26, l27, l51, l52, l53, l57, l58, l61, l62, l63)
- FlashC 26, L26n
- FlashC 27, L27n
- FlashC 28, L28n
- If Not Proto then NFadeLm 31, l31 'crate eyes
- If Not Proto then NFadeLm 32, l32
- If Not Proto then NFadeLm 33, l33
- If Not Proto then NFadeLm 34, l34
- If Not Proto then NFadeLm 31, l31a
- If Not Proto then NFadeLm 32, l32a
- If Not Proto then NFadeLm 33, l33a
- If Not Proto then NFadeLm 34, l34a
- FlashC 35, L35r 'prototype only kickback reflection
- Flashm 35, L35n
- FlashC 36, l36n
- FlashC 37, l37n
- FlashC 38, l38n
- FlashC 41, l41n
- FlashC 42, l42n
- FlashC 43, l43n
- If Not Proto then NFadeL 44, l44 'Ramp Right Eye (ss05)
- FlashC 45, l45r 'Telepathetic Power reflection
- Flashm 45, L45n
- FlashC 46, L46n
- FlashC 47, L47n
- FlashC 48, L48n
- If Not Proto then NFadeLmM 51, FlSkull6_1
- If Not Proto then NFadeLmM 51, FlSkull6_2
- FlashC 51, l51n
- If Not Proto then NFadeLmM 52, FlSkull5_1
- If Not Proto then NFadeLmM 52, FlSkull5_2
- FlashC 52, l52n
- If Not Proto then NFadeLmM 53, FlSkull4_1
- If Not Proto then NFadeLmM 53, FlSkull4_2
- FlashC 53, L53n
- ' FlashC 54, l54 'coffin light - special
- nFadeL 54, L54
- FlashC 55, L55n
- FlashC 56, l56n ' lock light - special
- Flashm 56, l56a ' lock light - special
- FlashC 57, L57n
- FlashC 58, L58n
- If Not Proto then NFadeLmM 61, FlSkull2_3
- If Not Proto then NFadeLmM 61, FlSkull2_4
- FlashC 61, L61n
- If Not Proto then NFadeLmM 62, FlSkull2_5
- If Not Proto then NFadeLmM 62, FlSkull2_6
- FlashC 62, L62n 'Top skull
- If Not Proto then NFadeLmM 63, FlSkull2_1
- If Not Proto then NFadeLmM 63, FlSkull2_2
- FlashC 63, L63n
- nFlashW 64, l64
- nFlashW 65, l65
- nFlashW 66, l66
- nFlashW 67, l67
- nFlashW 68, l68
- nFlashW 71, l71
- nFlashW 72, l72
- nFlashW 73, l73
- nFlashW 74, l74
- nFlashW 75, l75
- nFlashW 76, l76
- nFlashW 77, l77
- nFlashW 78, l78
- nFlashW 81, l81
- nFlashW 82, l82
- nFlashW 83, l83
- ' Skull Lanes
- FlashC 84, L84_1
- FLashm 84, L84_2
- FLashm 84, L84_0
- Flashm 84, l84n
- FlashC 85, L85r
- Flashm 85, l85n
- FlashC 86, L86r
- Flashm 86, l86n
- '87 - Buy In Button (Pre-production rom only)
- if Proto then
- nFadeL 18, Lbolt1 'Left Bolt
- nFadeL 31, L18 'ramp Left eye
- nFadeL 32, L44 'ramp Right eye
- nFadeL 33, Lbolt2 'Right Bolt
- nFadeL 34, LCandle1'Left Candle (backglass?)
- nFadeL 44, LCandle2'Right Candle (backglass?)
- 'These lamps don't work right now
- '---------------------------------
- nFadeL 91, l34 'crate eyes, right to left
- nFadeLm 91, L34a
- nFadeL 92, l33
- nFadeLm 92, L33a
- nFadeL 93, l32
- nFadeLm 93, L32a
- nFadeL 94, l31
- nFadeLm 94, L31a
- 'Skull LEDs
- 'bottom to top / left to right... (not sure the correct order)
- ' nFadeL 95, FlSkull2_5'#11
- ' nFadeL 96, FlSkull2_6'#12
- ' nFadeL 97, FlSkull2_4'#10
- ' nFadeL 98, FlSkull2_3'#9
- ' nFadeL 101, FlSkull6_2'#6
- ' nFadeL 102, FlSkull6_1'#5
- ' nFadeL 103, FlSkull5_2 '#4
- ' nFadeL 104, FlSkull5_1 '#3
- ' nFadeL 105, FlSkull4_2 '#2
- ' nFadeL 106, FlSkull4_1 '#1
- ' nFadeL 107, FlSkull2_1'#7
- ' nFadeL 108, FlSkull2_2'#8
- 'Top to bottom, left to right...
- nFadeL 95, FlSkull6_1'#11
- nFadeL 96, FlSkull6_2'#12
- nFadeL 97, FlSkull5_2'#10
- nFadeL 98, FlSkull5_1'#9
- nFadeL 1, FlSkull2_4'#6
- nFadeL 2, FlSkull2_3'#5
- nFadeL 3, FlSkull2_2'#4
- nFadeL 4, FlSkull2_1'#3
- nFadeL 5, FlSkull2_6'#2
- nFadeL 6, FlSkull2_5'#1
- nFadeL 7, FlSkull4_1'#7
- nFadeL 8, FlSkull4_2'#8
- '--------------------------------
- End If
- End sub
- Sub TBF_timer():me.text = "GiStep:" & gistep & vbnewline & "Desired LUT:" & DesiredGI & vbnewline & " GiFadeStep:" & GiFadeStep _
- & vbnewline & "fadinglevel" & FadingLevel(199) & vbnewline & "lampstate" & lampstate(199) & vbnewline & LUTtimer.enabled & vbnewline & Table1.ColorGradeImage: End Sub
- Sub AllLampsOff 'debug
- Dim x
- For x = 0 to 340
- SetLamp x, 0
- Next
- End Sub
- Sub SetLamp(nr, value)
- If value <> LampState(nr) Then
- LampState(nr) = abs(value)
- FadingLevel(nr) = abs(value) + 4
- End If
- End Sub
- Sub SetLampm(nr, nr2, value) 'set 2 lamps
- If value <> LampState(nr) Then
- LampState(nr) = abs(value)
- FadingLevel(nr) = abs(value) + 4
- End If
- If value <> LampState(nr2) Then
- LampState(nr2) = abs(value)
- FadingLevel(nr2) = abs(value) + 4
- End If
- End Sub
- Sub SetLampmm(nr, nr2, nr3, value) 'set 3 lamps
- If value <> LampState(nr) Then
- LampState(nr) = abs(value)
- FadingLevel(nr) = abs(value) + 4
- End If
- If value <> LampState(nr2) Then
- LampState(nr2) = abs(value)
- FadingLevel(nr2) = abs(value) + 4
- End If
- If value <> LampState(nr3) Then
- LampState(nr3) = abs(value)
- FadingLevel(nr3) = abs(value) + 4
- End If
- End Sub
- Sub NFadeL(nr, object)
- Select Case FadingLevel(nr)
- Case 3:object.state = 0:FadingLevel(nr) = 0
- Case 4:object.state = 0:FadingLevel(nr) = 3
- Case 5:object.state = 1:FadingLevel(nr) = 6
- Case 6:object.state = 1:FadingLevel(nr) = 1
- End Select
- End Sub
- Sub NFadeLm(nr, object) ' used for multiple lights
- Select Case FadingLevel(nr)
- Case 3:object.state = 0
- Case 4:object.state = 0
- Case 5:object.state = 1
- Case 6:object.state = 1
- End Select
- End Sub
- Sub NFadeLmM(nr, object) ' used for multiple lights, Mod
- if SkullLEDMod = 0 then Exit Sub
- Select Case FadingLevel(nr)
- Case 4:object.state = 0
- Case 5:object.state = 1
- End Select
- End Sub
- Sub nFlashW(nr, object) 'simple flashing light for wheel
- Select Case FadingLevel(nr)
- Case 4 'off
- object.intensityscale = 0.5
- FadingLevel(nr) = 0
- Case 5 ' on
- object.intensityscale = 3
- FadingLevel(nr) = 1
- End Select
- End Sub
- '***************
- '***************
- '* Triggers and Switches
- '***************
- 'vpmCreateEvents Triggers
- sub sw16_hit():controller.Switch(16) = 1:end sub 'Kickback
- sub sw16_unhit():controller.Switch(16) = 0:end sub
- sub sw17_hit():controller.Switch(17) = 1:end sub 'Right Flipper Lane
- sub sw17_unhit():controller.Switch(17) = 0:end sub
- dim BallInPlunger :BallInPlunger = False
- sub PlungerLane_hit():ballinplunger = True: End Sub
- Sub PlungerLane_unhit():BallInPlunger = False : End Sub
- sub sw18_hit():controller.Switch(18) = 1:end sub 'Shooter Lane
- sub sw18_unhit():controller.Switch(18) = 0:end sub
- sub sw25_hit():controller.Switch(25) = 1:end sub 'Extra Ball Lane
- sub sw25_unhit():controller.Switch(25) = 0:end sub
- sub sw26_hit():controller.Switch(26) = 1:end sub 'Left Flipper Lane
- sub sw26_unhit():controller.Switch(26) = 0:end sub
- sub sw27_hit():controller.Switch(27) = 1:end sub 'Right Outlane
- sub sw27_unhit():controller.Switch(27) = 0:end sub
- sub sw28_hit():vpmTimer.PulseSw 28:end sub 'Right Standup
- 'sub sw28_unhit():controller.Switch(28) = 0:end sub
- sub sw38_hit():controller.Switch(38) = 1:end sub 'Crate Enter
- sub sw38_unhit():controller.Switch(38) = 0:end sub
- sub sw41_hit():controller.Switch(41) = 1:end sub 'Coffin left
- sub sw41_unhit():controller.Switch(41) = 0:end sub
- sub sw42_hit():controller.Switch(42) = 1:end sub 'Coffin middle
- sub sw42_unhit():controller.Switch(42) = 0:end sub
- sub sw43_hit():controller.Switch(43) = 1:end sub 'Coffin right
- sub sw43_unhit():controller.Switch(43) = 0:end sub
- sub sw44_hit():controller.Switch(44) = 1: end sub 'Left Ramp Entry
- sub sw44_unhit():controller.Switch(44) = 0:end sub
- sub sw46_hit() :controller.Switch(46) = 1:end sub 'Left Ramp Made
- sub sw46_unhit():controller.Switch(46) = 0:end sub
- 'Sub LeftRampEnd_Hit():playsound "drop_mono", 0, LVL(0.5), 0.05:end sub
- sub sw45_hit():controller.Switch(45) = 1:end sub 'Right Ramp Enter
- sub sw45_unhit():controller.Switch(45) = 0:end sub
- sub sw47_hit():controller.Switch(47) = 1:end sub 'Right Ramp Made
- sub sw47_unhit():controller.Switch(47) = 0:end sub
- 'Sub RightRampEnd_Hit():playsound "drop_mono", 0, LVL(0.5), -0.05 :end sub'name,loopcount,volume,pan,randompitch
- Sub RHelp1_hit():if me.timerenabled = 0 then playsound "drop_mono", 0, LVL(0.05), -0.045 :me.timerenabled = 1 :activeball.vely = activeball.vely*0.5:end if :end sub'name,loopcount,volume,pan,randompitch
- Sub RHelp1_Timer():me.timerenabled = 0:end sub
- Sub RHelp2_hit():if me.timerenabled = 0 then playsound "drop_mono", 0, LVL(0.05), 0.045 :me.timerenabled = 1:activeball.vely = activeball.vely*0.5 :end if :end sub'name,loopcount,volume,pan,randompitch
- Sub RHelp2_Timer():me.timerenabled = 0:end sub
- '- moved these to light sequence area
- Sub LeftSlingShot_Slingshot():me.timerenabled = True : controller.Switch(51) = 1 : End Sub
- Sub LeftSlingShot_Timer() : me.timerenabled = False : controller.Switch(51) = 0 : End Sub
- Sub RightSlingShot_Slingshot():me.timerenabled = True : controller.Switch(52) = 1 : End Sub
- Sub RightSlingShot_Timer() : me.timerenabled = False : controller.Switch(52) = 0 : End Sub
- Sub SolBumper1(enabled)
- If enabled Then
- if BumperArea.BallCntOver > 0 then Exit Sub 'bumper hack
- Bumper1.PlayHit()
- PlaySound SoundFX("TopBumper_Hit",DOFContactors), 0, LVL(0.3), 0.053, 0.1
- End If
- End Sub
- Sub SolBumper2(enabled)
- If enabled Then
- if BumperArea.BallCntOver > 0 then Exit Sub 'bumper hack
- Bumper2.PlayHit()
- PlaySound SoundFX("LeftBumper_Hit",DOFContactors), 0, LVL(0.3), 0.043, 0.1
- End If
- End Sub
- Sub SolBumper3(enabled)
- If enabled Then
- if BumperArea.BallCntOver > 0 then Exit Sub 'bumper hack
- Bumper3.PlayHit()
- PlaySound SoundFX("RightBumper_Hit",DOFContactors), 0, LVL(0.3), 0.053, 0.1
- End If
- End Sub
- sub Bumper1_hit() 'Upper Jet
- vpmtimer.PulseSw 53
- Bumper1.PlayHit()
- PlaySound SoundFX("TopBumper_Hit",DOFContactors), 0, LVL(0.3), 0.053, 0.1
- end sub
- sub Bumper2_hit() 'Center Jet
- vpmtimer.PulseSw 54
- Bumper2.PlayHit()
- PlaySound SoundFX("LeftBumper_Hit",DOFContactors), 0, LVL(0.3), 0.043, 0.1
- end sub
- sub Bumper3_hit() 'Lower Jet
- vpmtimer.PulseSw 55
- Bumper3.PlayHit()
- PlaySound SoundFX("RightBumper_Hit",DOFContactors), 0, LVL(0.3), 0.053, 0.1
- end sub
- '*****************************
- 'Sub SW56_SlingShot():vpmTimer.PulseSw 56:End Sub 'Upper slingshot
- Sub SW56_SlingShot()
- vpmTimer.PulseSw 56
- PlaySound SoundFX("LeftSlingShotTrimmed",DOFContactors), 0, LVL(0.3), -0.005, 0.2
- Setlamp cTopSling, 1
- End Sub
- sub sw57_hit() 'Crate Sensor. Crate spinner also trips this switch
- controller.Switch(57) = 1
- TiCratesw.Timerinterval=1200 'may help
- dim finalspeed : finalspeed=BallVel(activeball)'SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- If finalspeed > 12 then
- playsound "woodhitaluminium", 0, LVL(Vol(ActiveBall)*5), Pan(ActiveBall), 0, SlopeIt(finalspeed, 12,12500, 23,19000), 1, 0
- Elseif finalspeed > 1 then
- playsound "metalhit2", 0, LVL(Vol(ActiveBall)*5), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
- End If
- 'tb.text = finalspeed
- end sub
- sub sw57_unhit():controller.Switch(57) = 0:end sub
- sub sw58_hit():controller.Switch(58) = 1:end sub 'Left Loop
- sub sw58_unhit():controller.Switch(58) = 0:end sub
- sub sw61_hit():vpmTimer.PulseSw 61:end sub 'Three bank upper
- sub sw62_hit():vpmTimer.PulseSw 62:end sub 'Three bank middle
- sub sw63_hit():vpmTimer.PulseSw 63:end sub 'Three bank lower
- sub Col_Rubber_Band_sw67_hit():controller.Switch(67) = 1:end sub 'Left Ramp 10 point
- sub Col_Rubber_Band_sw67_unhit():controller.Switch(67) = 0:end sub
- sub sw68_hit():controller.Switch(68) = 1:end sub 'Right Loop
- sub sw68_unhit():controller.Switch(68) = 0:end sub
- sub sw71_hit():controller.Switch(71) = 1:end sub 'Left Skull Lane
- sub sw71_unhit():controller.Switch(71) = 0:end sub
- sub sw72_hit():controller.Switch(72) = 1:end sub 'Center Skull Lane
- sub sw72_unhit():controller.Switch(72) = 0:end sub
- sub sw73_hit():controller.Switch(73) = 1:end sub 'Right Skull Lane
- sub sw73_unhit():controller.Switch(73) = 0:end sub
- sub sw74_hit():controller.Switch(74) = 1:end sub 'Secret Passage
- sub sw74_unhit():controller.Switch(74) = 0:end sub
- Sub Drain_Hit()
- PLaySound "ball_trough", 0, LVL(0.06)
- bsTrough.AddBall Me
- BIP = BIP - 1
- End Sub
- Sub CoffinEntrance_Hit() 'important for lock / multiball start routines
- vpmTimer.PulseSw 48
- PlaySound "Scoop_Enter2", 0, LVL(0.5), -0.03, 0.1
- bsCoffin.Addball Me
- BIP = BIP - 1
- End Sub
- '****************
- '* Hole Handling by nFozzy
- '****************
- 'Method:
- 'Replicates square holes in the playfield by using square triggers to enable kickers
- 'Some use two triggers to better emulate the square shape of the holes
- '-------------
- 'Crate
- '-------------
- 'Uses fallthrough holes and a submarine switch
- 'The crate switch, sw38, is handled by automatic switch handling
- 'sub CrateTrigger_hit() 'star-shaped
- ' CrateHole1.Enabled = 1
- ' CrateHole2.Enabled = 1
- ' CrateHole3.Enabled = 1
- ' CrateHole4.Enabled = 1
- 'end sub
- '
- 'Sub CrateHole1_Hit()
- ' me.enabled = 0
- 'end sub
- 'sub CrateTrigger_Unhit() 'square
- ' CrateHole1.Enabled = 0
- ' CrateHole2.Enabled = 0
- ' CrateHole3.Enabled = 0
- ' CrateHole4.Enabled = 0
- 'end sub
- Sub cratetrigger_hit()
- activeball.z = -30
- activeball.vely = activeball.vely * 0.5
- activeball.velz = 0
- playsound "Trough3", 0, LVL(Vol(ActiveBall) ), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
- end Sub
- Sub cratetrigger2_hit() 'catches stuck balls. hopefully temporary
- activeball.z = -35
- end Sub
- sub sw37_dropwall_hit()
- if bsLeftKick.balls > 0 then playsound "fx_collide", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall)
- end sub
- sub cratetriggerexit_unhit()
- end sub
- '-------------
- 'Crate Kickout / Skillshot
- '-------------
- sub sw37Trigger_hit():sw37a.enabled = 1:end sub
- sub sw37Trigger_unhit():sw37a.enabled = 0:end sub
- Dim aBalla, aBallb, aBallc
- Dim aZpos
- Sub sw37a_Hit()
- Set aBalla = ActiveBall
- aZpos = 50
- Me.TimerInterval = 2
- Me.TimerEnabled = 1
- me.enabled = 0
- sw37_dropwall.isdropped = 0
- end sub
- Sub sw37a_Timer
- aBalla.Z = aZpos
- aZpos = aZpos-2
- If aZpos <0 Then '40
- Me.TimerEnabled = 0
- Me.DestroyBall
- if bsLeftKick.balls > 0 then playsound "fx_collide", 0, LVL(0.3), -0.01
- bsLeftKick.AddBall Me
- PlaySound "Scoop_Enter", 0, LVL(0.3), -0.005, 0.1
- End If
- end sub
- Sub sw37_Hit() 'left kickout from crate
- ' PlaySound "Scoop_Enter", 0, LVL(1), -0.2, 0.2
- sw37_dropwall.isdropped = 0
- Me.DestroyBall
- bsLeftKick.AddBall Me
- End Sub
- Sub SolCrateKickout(Enabled) 'Solenoid Callback
- ' If Enabled Then
- ' If bsLeftKick.Balls Then
- ' bsLeftKick.ExitSol_On
- ' End If
- ' End If
- ' sw37a.enabled = 0 'turns off the entry kicker for kickout
- ' sw37Trigger.timerinterval = 150
- ' sw37Trigger.timerenabled = 1
- ' .InitExitSnd SoundFX("Kicker_Release",DOFContactors), SoundFX("FlipperUpLeft",DOFContactors)
- if bsLeftKick.balls > 0 then PlaySound SoundFX("Kicker_Release",DOFContactors), 0, LVL(0.3), -0.015' else Playsound SoundFX("Kicker_Release",DOFContactors), 0, 1, -0.01, 5
- bsLeftKick.ExitSol_On
- sw37_dropwall.isdropped = 1
- End Sub
- 'Sub sw37Trigger_Timer() 'actually don't think this is necessary. The default state of the fallthrough kicker should be 0!
- ' sw37a.enabled = 1
- ' me.timerenabled = 0
- 'end sub
- '-------------
- 'Spider hole
- '-------------
- 'The players:
- 'Prim_RampDiverter2 --- animated primitive
- 'RampGateFlipper --- for animation, goes from 0 to -40
- 'sw36 --- the kicker (not enabled!)
- 'sw36a and sw36b --- top kicker and bottom kicker, respectively
- 'sw36trigger --- rectangular Trigger
- 'sw36triggerexit --- big star-shaped trigger
- 'RaLeft_Closed --- ramp gate when open
- 'RaLeft_Open --- ramp gate when closed
- 'Square triggers enabling the hole
- sub sw36trigger_hit():sw36a.enabled=1:sw36b.enabled=1:end sub
- sub sw36triggerexit_unhit():sw36a.enabled=0:sw36b.enabled=0:end sub
- Sub sw36a_Hit() 'Holes themselves
- Set aBallb = ActiveBall
- aZpos = 60 'lil deeper
- Me.TimerInterval = 2
- Me.TimerEnabled = 1
- me.enabled = 0
- end sub
- Sub sw36a_Timer
- aBallb.Z = aZpos
- aZpos = aZpos-2
- If aZpos <0 Then '40
- Me.TimerEnabled = 0
- Me.DestroyBall
- bsSpider.AddBall Me
- ' CheckMultiballTimer.enabled = 1 'for multiball start award (might not work)
- ' CheckMultiballTimer.enabled = 600
- ' CrateSeqHelp = 1
- ' SpiderLockSequenceChecker.enabled = 1
- PlaySound "Trough1", 0, LVL(0.2), 0.03, 0.1
- End If
- end sub
- Sub sw36b_Hit() 'Holes themselves
- Set aBallc = ActiveBall
- aZpos = 50
- Me.TimerInterval = 2
- Me.TimerEnabled = 1
- me.enabled = 0
- end sub
- Sub sw36b_Timer
- aBallc.Z = aZpos
- aZpos = aZpos-2
- If aZpos <0 Then '40
- Me.TimerEnabled = 0
- Me.DestroyBall
- bsSpider.AddBall Me
- ' CrateSeqHelp = 1
- ' SpiderLockSequenceChecker.enabled = 1
- PlaySound "Trough2", 0, LVL(0.2), 0.03, 0.1
- End If
- end sub
- 'Solenoid Callback
- Sub SolSpiderPopper(Enabled)
- If Enabled Then
- If bsSpider.Balls Then
- if FSSpiderenabled then setlamp cSpiderFade, 0
- bsSpider.ExitSol_On
- Playsound SoundFX("Kicker_Release",DOFContactors), 0, LVL(0.2), 0.03, 0.1
- RaLeft_Closed.collidable = 0
- RaLeft_Open.collidable = 1
- sw36a.enabled = 0
- sw36b.enabled = 0
- ' sw36trigger.enabled = 0 'necessary?
- sw36.timerinterval = 75 'Closes the gate again after a timer
- sw36.timerenabled = 1 'Closes the gate again after a timer
- RampGateFlipper.timerinterval = -1
- RampGateFlipper.timerenabled = 1
- ' RampGateFlipper.CurrentAngle = RampGateFlipper.CurrentAngle -0.01
- RampGateFlipper.rotatetoend
- ' SpiderLockSequenceChecker.enabled = 0
- ' sw36.Enabled = 0 'disable the kicker to do not accept more balls during the animation
- ' Set spiderBall = sw36a.Createball
- ' spiderZpos = 0
- ' sw36a.TimerInterval = 1
- ' sw36a.TimerEnabled = 1
- End If
- End If
- End Sub
- sub RampGateFlipper_Timer() 'Animates ramp popper gate
- ' if rampgateflipper.timerinterval = 50 then RampGateFlipper.rotatetoend:RampGateFlipper.timerinterval = 16 'timer is both a delay and a 16ms update
- ' if RampGateFlipper.Timerinterval = 16 and RampGateFlipper.CurrentAngle < -39 then rampgateflipper.timerinterval = 35:
- ' if RampGateFlipper.Timerinterval = 35 and RampGateFlipper.CurrentAngle < -39 then rampgateflipper.timerinterval = 50
- 'todo optimize
- Prim_RampDiverter2.RotX = RampGateFlipper.currentangle
- if RampGateFlipper.CurrentAngle = RampGateFlipper.StartAngle then me.Enabled = 0 'todo this might not work
- ' if RampGateFlipper.CurrentAngle < -39 then rampgateflipper.rotatetostart end if
- ' if RampGateFlipper.currentangle > -1 then
- end sub
- sub sw36_Timer() 'Closes the gate again after a timer
- ' sw36trigger.enabled = 1
- RampGateFlipper.rotatetostart
- RaLeft_Closed.collidable = 1
- RaLeft_Open.collidable = 0
- if sw36.timerinterval = 750 then me.timerenabled = 0:RampGateFlipper.timerenabled = 0 'disables both timers
- if sw36.timerinterval = 75 then sw36.timerinterval = 750 'reuses the timer for disabling updates after 3/4s of a second
- end sub
- '****************
- '* Animations
- '* Rstep and Lstep are the variables that increment the animation
- '****************
- dim FrogDir1, frogdir2, frogdir3
- frogdir1 = 1
- frogdir2 = 1
- frogdir3 = 1
- Sub sw64_Hit 'Left leaper
- Frog1Vel = SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- vpmTimer.PulseSw 64
- ' tb.text = frog1vel
- sw64t.Enabled = 1
- Playsound SoundFX("LockupPin",DOFTargets), 0, LVL(0.1), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0
- End Sub
- Sub sw65_Hit 'Center Leaper
- vpmTimer.PulseSw 65
- Frog2Vel = SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- sw65t.Enabled = 1
- Playsound SoundFX("LockupPin",DOFTargets), 0, LVL(0.1), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0
- End Sub
- Sub sw66_Hit 'Right Leaper
- vpmTimer.PulseSw 66
- Frog3Vel = SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- sw66t.Enabled = 1
- Playsound SoundFX("LockupPin",DOFTargets), 0, LVL(0.1), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0
- End Sub
- 'ideal rotations?
- 'prfrog 1:
- '-40 to 20
- 'prfrog2:
- '-60 to 20
- 'prfrog3:
- '-20 to 60
- Dim Dir1, chdir1, updown1, slowmo
- slowmo = 1'.98 'Make this number lower for slow-mo frogs
- Dir1 = 1
- updown1 = 1
- ChDir1 = 0
- Sub Sw64t_Timer()
- dim rotdir
- If updown1 = -1 AND ChDir1 = 0 Then ChDir1 = 1
- If ChDir1 = 1 Then
- If PrLeaper1.Z >= 160 Then PlaySound "metalhit2", 0, LVL(0.1), -0.5, 0:ChDir1 = 2
- If PrLeaper1.Z >= 155 AND PrLeaper1.Z < 160 Then PlaySound "metalhit2", 0, LVL(0.1), -0.01, 0:ChDir1 = 2
- If PrLeaper1.Z >= 150 AND PrLeaper1.Z < 155 Then PlaySound "metalhit2", 0, LVL(0.05), -0.01, 0:ChDir1 = 2
- End If
- PrLeaper1.Z = dSin(dir1) * Frog1Vel * 2 + 55
- if PrLeaper1.Rotz > 20 then
- ' frogdir1 = -1
- frogdir1 = 1
- elseif prleaper1.rotz < -40 Then
- frogdir1 = 1
- end if
- ' PrLeaper1.RotZ = PrLeaper1.RotZ + (Frog1Vel * 0.005 * frogdir1) 'simple rotation
- PrLeaper1.RotZ = PrLeaper1.RotZ + (Frog1Vel * 0.05 * frogdir1) 'simple rotation
- If dir1 >= 80 Then updown1 = -1
- ' debug.Print dir1
- dir1 = dir1 + dCos(dir1) * updown1 * slowmo
- If PrLeaper1.Z <= 55 Then
- PrLeaper1.Z = 55
- Me.Enabled = 0
- Dir1 = 1
- ChDir1 = 0
- updown1 = 1
- End If
- End Sub
- Dim Dir2, chdir2, updown2
- Dir2 = 1
- updown2 = 1
- ChDir2 = 0
- Sub Sw65t_Timer()
- If updown2 = -1 AND ChDir2 = 0 Then ChDir2 = 1
- If ChDir2 = 1 Then
- If PrLeaper2.Z >= 160 Then PlaySound "metalhit2", 0, LVL(0.1), -0.2, 0:ChDir2 = 2
- If PrLeaper2.Z >= 155 AND PrLeaper2.Z < 160 Then PlaySound "metalhit2", 0, LVL(0.1), 0, 0:ChDir2 = 2
- If PrLeaper2.Z >= 150 AND PrLeaper2.Z < 155 Then PlaySound "metalhit2", 0, LVL(0.05), 0, 0:ChDir2 = 2
- End If
- PrLeaper2.Z = dSin(dir2) * Frog2Vel * 2 + 55
- if PrLeaper2.Rotz > 40 then
- ' frogdir2 = -1
- frogdir2 = 1
- elseif prleaper2.rotz < -60 Then
- frogdir2 = 1
- end if
- PrLeaper2.RotZ = PrLeaper2.RotZ + (Frog2Vel * 0.05 * frogdir2)
- If dir2 >= 80 Then updown2 = -1
- dir2 = dir2 + dCos(dir2) * updown2 * slowmo
- If PrLeaper2.Z <= 55 Then
- PrLeaper2.Z = 55
- Me.Enabled = 0
- Dir2 = 1
- ChDir2 = 0
- updown2 = 1
- End If
- End Sub
- Dim Dir3, chdir3, updown3
- Dir3 = 1
- updown3 = 1
- ChDir3 = 0
- Sub Sw66t_Timer()
- If updown3 = -1 AND ChDir3 = 0 Then ChDir3 = 1
- If ChDir3 = 1 Then
- If PrLeaper3.Z >= 160 Then PlaySound "metalhit2", 0, LVL(0.1), 0.4, 0:ChDir3 = 2
- If PrLeaper3.Z >= 155 AND PrLeaper3.Z < 160 Then PlaySound "metalhit2", 0, LVL(0.08), 0.01, 0:ChDir3 = 2
- If PrLeaper3.Z >= 150 AND PrLeaper3.Z < 155 Then PlaySound "metalhit2", 0, LVL(0.05), 0.01, 0:ChDir3 = 2
- End If
- PrLeaper3.Z = dSin(dir3) * Frog3Vel * 2 + 55
- if PrLeaper3.Rotz > 60 then
- ' frogdir3 = -1
- frogdir3 = 1
- elseif prleaper3.rotz < -20 Then
- frogdir3 = 1
- end if
- PrLeaper3.RotZ = PrLeaper3.RotZ + (Frog3Vel * 0.05 * frogdir3)
- If dir3 >= 80 Then updown3 = -1
- dir3 = dir3 + dCos(dir3) * updown3 * slowmo
- If PrLeaper3.Z <= 55 Then
- PrLeaper3.Z = 55
- Me.Enabled = 0
- Dir3 = 1
- ChDir3 = 0
- updown3 = 1
- End If
- End Sub
- '*****************
- '* Maths Functions
- '*****************
- Dim Pi
- Pi = Round(4 * Atn(1), 6)
- Function dSin(degrees)
- dsin = sin(degrees * Pi/180)
- if ABS(dSin) < 0.000001 Then dSin = 0
- if ABS(dSin) > 0.999999 Then dSin = 1' * sgn(dSin)
- End Function
- Function dCos(degrees)
- dcos = cos(degrees * Pi/180)
- if ABS(dCos) < 0.000001 Then dCos = 0
- if ABS(dCos) > 0.999999 Then dCos = 1' * sgn(dCos)
- End Function
- Function dTan(degrees)
- dTan = tan(degrees*Pi/180)
- If ABS(dTan) < 0.000001 AND ABS(dTan) > -0.000001 Then dTan = 0
- ' If ABS(dTan) > 0.999999 Then dTan = 1'*sgn(dTan)
- End Function
- '*****************
- '*****************
- '* Timers
- '*****************
- 'Redesigned Crate Door -nf
- '
- 'Trigger in front of the crate turns on/off the prim update timer
- 'sub TiCratesw_Hit():TiCrate.enabled = 1:Me.Timerinterval=1200:Me.timerenabled = 1:end sub
- 'Sub TiCratesw_Timer():TiCrate.Enabled = 0:Me.timerenabled = 0:end sub 'disables update after an interval
- sub TiCratesw_Hit():FadingLevel(cCrate) = 5:Me.Timerinterval=2000:Me.timerenabled = 1:end sub
- Sub TiCratesw_Timer():FadingLevel(cCrate) = 0:Me.timerenabled = 0:end sub 'disables update after an interval
- 'sw57a
- crateopen = False
- 'Sub TiCrate_Timer() 'updates door
- ' if CrateOpen = False Then
- '' if sw57.isdropped = True Then
- ' PrCrateDoor.RotX = -CrateSpinner_Closed.CurrentAngle
- ' Else
- ' PrCrateDoor.RotX = -CrateSpinner_Open.CurrentAngle
- ' end if
- ' if PrCrateDoor.RotX < -5 then controller.switch(57) = 1 else controller.Switch(57) = 0
- 'End SUb
- Sub UpdateCrate(nr)
- Select Case FadingLevel(nr)
- case 5
- if CrateOpen = False Then
- PrCrateDoor.RotX = -CrateSpinner_Closed.CurrentAngle
- Else
- PrCrateDoor.RotX = -CrateSpinner_Open.CurrentAngle
- end if
- if PrCrateDoor.RotX < -5 then controller.switch(57) = 1 else controller.Switch(57) = 0
- End Select
- End Sub
- sub UpdateCadaver(nr)
- Select Case FadingLevel(nr)
- case 5 : PrCadaver.RotX = CadaverSpinner.CurrentAngle - 30
- end Select
- End Sub
- sub CoffinKicker_Timer() 'starts with bscoffin.exitsol. 1500ms shut off Prcadaver tracking
- me.enabled = 0
- ' TiCadaver.enabled = 0
- FadingLevel(cCadaver) = 0
- end sub
- Sub UpdateFlippers()
- PrLeftFlipper.RotZ = LeftFlipper.CurrentAngle
- PrRightFlipper.RotZ = RightFlipper.CurrentAngle
- FlSpider.RotZ = WheelMech.position * 7.5 + 18 '+20
- UpdateBallShadow
- End Sub
- 'Ballshadow routine by Ninuzzu
- Dim BallShadow
- BallShadow = Array (BallShadow1, BallShadow2, BallShadow3, BallShadow4, BallShadow5, BallShadow6)
- Sub UpdateBallShadow() 'called by -1 lamptimer
- On Error Resume Next
- Dim BOT, b
- BOT = GetBalls
- dim CenterPoint : CenterPoint = 425'Table1.Width/2
- ' render the shadow for each ball
- For b = 0 to UBound(BOT)
- If BOT(b).X < CenterPoint Then
- BallShadow(b).X = ((BOT(b).X) - (50/6) + ((BOT(b).X - (CenterPoint))/7)) + 10
- Else
- BallShadow(b).X = ((BOT(b).X) + (50/6) + ((BOT(b).X - (CenterPoint))/7)) - 10
- End If
- BallShadow(b).Y = BOT(b).Y + 20
- BallShadow(b).Z = 1
- If BOT(b).Z > 20 Then
- BallShadow(b).visible = 1
- Else
- BallShadow(b).visible = 0
- End If
- Next
- End Sub
- sub k033(x,y,z) : k033k.CreateSizedBallwithMass ballsize/2, z : k033k.kick x, y : End Sub
- sub k148(x,y,z) : k148k.CreateSizedBallwithMass ballsize/2, z : k148k.kick x, y : End Sub
- sub k236(x,y,z) : k148k.CreateSizedBallwithMass ballsize/2, z : k148k.kick x, y : End Sub
- sub k1037(x,y,z): k1037k.CreateSizedBallwithMass ballsize/2, z : k1037k.kick x, y : End Sub
- sub k1044(x,y,z): k1044k.CreateSizedBallwithMass ballsize/2, z : k1044k.kick x, y : End Sub
- 'sub k1141(x,y,z): k1141k.CreateSizedBallwithMass ballsize/2, z : k1141k.kick x, y : End Sub
- sub k1610(x,y,z): k1037k.CreateSizedBallwithMass ballsize/2, z : k1037k.kick x, y : End Sub
- sub k1614(x,y,z): k1037k.CreateSizedBallwithMass ballsize/2, z : k1037k.kick x, y : End Sub
- sub k1821(x,y,z): k1821k.CreateSizedBallwithMass ballsize/2, z : k1821k.kick x, y : End Sub
- sub k1846(x,y,z): k1846k.CreateSizedBallwithMass ballsize/2, z : k1846k.kick x, y : End Sub
- sub k1953(x,y,z): k1953k.CreateSizedBallwithMass ballsize/2, z : k1953k.kick x, y : End Sub
- sub k2023(x,y,z): k1044k.CreateSizedBallwithMass ballsize/2, z : k1044k.kick x, y : End Sub
- sub k2144(x,y,z): k2144k.CreateSizedBallwithMass ballsize/2, z : k2144k.kick x, y : End Sub
- sub k2226(x,y,z): k2226k.CreateSizedBallwithMass ballsize/2, z : k2226k.kick x, y : End Sub
- sub k2341(x,y,z): k2341k.CreateSizedBallwithMass ballsize/2, z : k2341k.kick x, y : End Sub
- sub k2415(x,y,z): k2341k.CreateSizedBallwithMass ballsize/2, z : k2341k.kick x, y : End Sub
- 'sub k2544(x,y,z): k2544k.CreateSizedBallwithMass ballsize/2, z : k2544k.kick x, y : End Sub
- sub k2549(x,y,z): k2549k.CreateSizedBallwithMass ballsize/2, z : k2549k.kick x, y : End Sub
- sub k2555(x,y,z): k2549k.CreateSizedBallwithMass ballsize/2, z : k2549k.kick x, y : End Sub
- sub k2620(x,y,z): k2620k.CreateSizedBallwithMass ballsize/2, z : k2620k.kick x, y : End Sub
- sub k2627(x,y,z): k2627k.CreateSizedBallwithMass ballsize/2, z : k2627k.kick x, y : End Sub
- sub k2812(x,y,z): k2341k.CreateSizedBallwithMass ballsize/2, z : k2341k.kick x, y : End Sub
- sub k2903(x,y,z): k2903k.CreateSizedBallwithMass ballsize/2, z : k2903k.kick x, y : End Sub
- sub k3007(x,y,z): k2627k.CreateSizedBallwithMass ballsize/2, z : k2627k.kick x, y : End Sub
- sub k3130(x,y,z): k2226k.CreateSizedBallwithMass ballsize/2, z : k2226k.kick x, y : End Sub
- dim EndPointL : EndPointL = 379.34 'X position of the very end of the flipper
- dim EndPointR : EndPointR = 498.5795'489.7015'-25'X position of the very end of the flipper
- '==,ggggggggggg,=========================================================================
- 'dP"""88""""""Y8, ,dPYb, I8
- 'Yb, 88 `8b IP'`Yb I8
- ' `" 88 ,8P I8 8I gg 88888888
- ' 88aaaad8P" I8 8' "" I8
- ' 88""""" ,ggggg, I8 dP ,gggg,gg ,gggggg, gg I8 gg gg
- ' 88 dP" "Y8ggg I8dP dP" "Y8I dP""""8I 88 I8 I8 8I
- ' 88 i8' ,8I I8P i8' ,8I ,8' 8I 88 ,I8, I8, ,8I
- ' 88 ,d8, ,d8' ,d8b,_ ,d8, ,d8b,,dP Y8,_,88,_ ,d88b, ,d8b, ,d8I
- ' 88 P"Y8888P" 8P'"Y88P"Y8888P"`Y88P `Y88P""Y888P""Y88P""Y88P"888
- '===============================================================================,d8I'====
- ' ,dP'8I
- 'Tracks balls, Adjusts ball velocity and adjusts shot angle ,8" 8I
- 'Part 1 - Ball velocity Hack I8 8I
- 'Part 2 - Polarity and Velocity Adjustments on 3 or 5-point envelopes `8, ,8I
- ' `Y8P"
- 'Setup -
- 'Triggers tight to the flippers TriggerLF and TriggerRF. Timers as low as possible, but > 80ms
- 'Debug box TBpl
- 'On Flipper Call:
- ' ProcessballsL
- ' ...
- ' ProcessballsR
- 'set up flipper end X coords in variables EndpointL / EndpointR (or in FTS flipper test script)
- '-----------Configuration---------------
- dim PolarityMod(5, 1), VelMod(5, 1), Ydiminish(3, 1), VelXmod(5, 1)
- 'Coord PolarityMod, 1, x, y
- Sub Coord(N,A,X,Y):a(n, 0) = x :a(n,1) = y : End Sub 'Point #, Array name, XCoord, YCoord
- PolarityMod(0,0) = "PolarityMod"
- VelMod(0,0) = "VelMod"
- Ydiminish(0,0) = "Ydiminish"
- VelXmod(0,0) = "VelXmod"
- 'x = % Position of Flipper
- 'Y = Output Coefficient for calculation
- polarityenabled = True'False
- 'Stern
- 'm1 = 1 : m2 = 1 : m3 = 50 : m4 = 0.93 'Setup Vel Falloff Line
- 'Coord 1, PolarityMod, 0.38, -4.5 'Early1
- 'Coord 2, PolarityMod, 0.65, -4 'Early2
- 'Coord 3, PolarityMod, 0.84, 0 'Middle
- 'Coord 4, PolarityMod, 0.97, 3.2 'Late3
- 'Coord 5, PolarityMod, 1.05, 7 'Late4
- '
- 'Coord 1, VelMod, 0.30, 0.9 'Early1
- 'Coord 2, VelMod, 0.596, 1'0.97 'Early2
- 'Coord 3, VelMod, 0.782, 1 'Middle
- 'Coord 4, VelMod, 0.941, 0.95'0.9 'Late3
- 'Coord 5, VelMod, 1.1, 0.825'0.85 'Late4
- 'WPC Steep (71.1/120)
- m1 = 1 : m2 = 1 : m3 = 10 : m4 = 0.935
- Coord 1, PolarityMod, 0.38, -3.5 'Early1
- Coord 2, PolarityMod, 0.596, -5 'Early2
- Coord 3, PolarityMod, 0.8, -2 'Middle
- Coord 4, PolarityMod, 0.97, -1.5 'Late3
- Coord 5, PolarityMod, 1.05, 0 'Late4
- 'kinda improper. Adjust speed so that these cap out at 1!
- Coord 1, VelMod, 0.30, 0.9 'Early1
- Coord 2, VelMod, 0.596, 0.95'0.97 'Early2
- Coord 3, VelMod, 0.745, 0.965 'Middle
- Coord 4, VelMod, 0.941, 0.95'0.9 'Late3
- Coord 5, VelMod, 1.1, 0.95'0.85 'Late4
- 'all
- Coord 1, Ydiminish, RightFlipper.Y-65, 0 ' Earliest Flipper (keep at 1)
- Coord 2, Ydiminish, RightFlipper.Y-11, 1 ' Mid Point
- Coord 3, Ydiminish, RightFlipper.Y, 1 ' Latest Flipper
- 'Part 1 - Overall Velocity Hack
- '***************************
- Dim LFon, RFon, RF1on, SpeedLimit, M1, M2, M3, M4
- Sub TriggerLF_Timer(): LFon = False : me.TimerEnabled = 0 : End Sub
- Sub TriggerRF_Timer(): RFon = False : me.TimerEnabled = 0 : End Sub
- Sub TriggerRF1_Timer(): RF1on = False : me.TimerEnabled = 0 : End Sub
- Sub TriggerRF1_UnHit(): if RF1on then FlipSpeedHack m1, m2, m3, m4, False End If : End Sub
- Sub FlipSpeedHack(X1, Y1, X2, Y2, CutoffBool) 'Two points
- if CutoffBool then if activeball.vely > 0 then exit sub 'if ball is going Down, exit sub (inappropriate for upper flippers)
- Dim FinalSpeed : FinalSpeed = BallSpeed(ActiveBall) : if FinalSpeed < x1 then Exit Sub
- Dim VelCoef : VelCoef = SlopeIt(FinalSpeed,X1,Y1,X2,Y2)
- if VelCoef < Y1 then VelCoef = Y1 'Clamp Low
- if VelCoef > Y2 then VelCoef = Y2 'Clamp High
- activeball.velx = activeball.velx * VelCoef
- activeball.vely = activeball.vely * VelCoef
- Dim DebugString : DebugString = "Flip" & vbnewline
- FalloffDebugBox TBflipper, Finalspeed, BallSpeed(ActiveBall), VelCoef, DebugString
- End Sub
- Sub TBflipper_Timer():me.timerenabled = False : me.text = Empty : End Sub
- '=====================================
- 'Part 2
- 'Ball Tracking Polarity Correction
- '=====================================
- '0.09a
- ' - Improved Envelope Functions
- ' - fixed greater than / less than errors
- '0.09b - script cleanup, removed unused stuff
- Dim Lballstack(9, 5)
- Dim Rballstack(9, 5)
- '0 = Object reference
- '1 = ballID kept in integer (trigger unhit compares this to activeball.ID for wiping ball from stack)
- '2 = Ball X pos (set by flip for Polarity correction, wiped on trigger unhit)
- '3 = Ball Y pos (TODO)
- '4 = Ball X vel
- '5 = Partial Flip Coefficient (kept in 0, 5 only)
- Initballstacks
- Sub Initballstacks() : dim x: for x = 0 to 9 : Set Lballstack(x,0) = Nothing : Set Rballstack(x,0) = Nothing : next : End Sub
- 'Left Flipper ====================================
- Sub TriggerLF_Hit() 'add a ball to the stack
- ' tb.text = activeball.mass
- dim x : for x = 0 to 9
- if Typename(Lballstack(x, 0)) = "Nothing" then
- Set Lballstack(x, 0) = activeball
- Lballstack(x, 1) = activeball.id
- exit For
- End If
- Next
- End Sub
- Sub TriggerLF_UnHit() 'proc Polarity Correction, then wipe X coords from column 2
- if LFon then 'FalloffNF
- dim x : for x = 0 to 9 'If X position is set, call Polarity Correction for that object
- if Lballstack(x, 2) > 0 then
- PolarityCorrect Lballstack(x, 0), Lballstack(x, 2), Lballstack(x, 3), Lballstack(x, 4), Lballstack(0, 5), 0
- End If
- Next
- for x = 0 to 9 'wipe X Positions
- Lballstack(x, 2) = Empty
- Next
- FlipSpeedHack m1, m2, m3, m4, True
- End If
- for x = 0 to 9 'Remove ball from stack...
- if activeball.id = Lballstack(x, 1) then Set Lballstack(x, 0) = Nothing
- Next
- End Sub
- Sub ProcessballsL() 'note X position of balls in flipper area
- TriggerLF.TimerEnabled = 1
- LFon = True
- dim x : for x = 0 to 9 'Count X positions of balls in array
- if TypeName(Lballstack(x, 0)) = "IBall" then
- Lballstack(x, 2) = Lballstack(x, 0).X
- Lballstack(x, 3) = Lballstack(x, 0).Y
- Lballstack(x, 4) = Lballstack(x, 0).VelX
- End If
- Next
- 'dim totalrotation, currentangler, b
- 'CurrentAngler = (LeftFlipper.StartAngle - LeftFlipper.CurrentAngle)
- 'TotalRotation = (LeftFlipper.StartAngle - LeftFlipper.EndAngle)
- dim b
- b = ((LeftFlipper.StartAngle - LeftFlipper.CurrentAngle) / (LeftFlipper.StartAngle - LeftFlipper.EndAngle))
- b = abs(b-1) 'invert
- Lballstack(0, 5) = b 'Partial Flip Coefficient
- 'tb.text = LeftFlipper.StartAngle - LeftFlipper.EndAngle & vbnewline & leftflipper.CurrentAngle & vbnewline & b
- end Sub
- 'Right Flipper ====================================
- Sub TriggerRF_Hit() 'add a ball to the stack
- dim x : for x = 0 to 9
- if Typename(Rballstack(x, 0)) = "Nothing" then
- Set Rballstack(x, 0) = activeball
- Rballstack(x, 1) = activeball.id
- exit For
- End If
- Next
- End Sub
- Sub TriggerRF_UnHit() 'proc Polarity Correction, then wipe X coords from column 2
- if RFon then 'FalloffNF
- dim x : for x = 0 to 9 'If X position is set, call Polarity Correction for that object
- if Rballstack(x, 2) > 0 then
- PolarityCorrect Rballstack(x, 0), Rballstack(x, 2), Rballstack(x, 3) , Rballstack(x, 4), Rballstack(0, 5), 1
- End If
- Next
- for x = 0 to 9 'wipe X Positions
- Rballstack(x, 2) = Empty
- Next
- FlipSpeedHack m1, m2, m3, m4, True
- End If
- for x = 0 to 9 'Remove ball from stack...
- if activeball.id = Rballstack(x, 1) then Set Rballstack(x, 0) = Nothing
- Next
- End Sub
- Sub tbBS_Timer() 'debug textbox
- ' on error resume next
- dim y(9), x : for x = 0 to 9
- y(x) = Typename(Rballstack(x, 0))
- if TypeName(Rballstack(x, 0)) = "IBall" then y(x) = y(x) & " " & Rballstack(x, 0).ID
- y(x) = y(x) & " " & Rballstack(x, 2)
- Next
- me.text = "Ball 1: " & y(0) & " " & Rballstack(0,1) & vbnewline & _
- "Ball 2: " & y(1) & " " & Rballstack(1,1) & vbnewline & _
- "Ball 3: " & y(2) & " " & Rballstack(2,1) & vbnewline & _
- "Ball 4: " & y(3) & " " & Rballstack(3,1) & vbnewline & _
- "Ball 5: " & y(4) & " " & Rballstack(4,1) & vbnewline & _
- "Ball 6: " & y(5) & " " & Rballstack(5,1) & vbnewline & _
- "Ball 7: " & y(6) & " " & Rballstack(6,1) & vbnewline & _
- "Ball 8: " & y(7) & " " & Rballstack(7,1) & vbnewline & _
- "Ball 9: " & y(8) & " " & Rballstack(8,1) & vbnewline & _
- "Ball10: " & y(9) & " " & Rballstack(9,1) & vbnewline & _
- "..."
- End Sub
- Sub ProcessballsR() 'note X position of balls in flipper area
- TriggerRF.TimerEnabled = 1
- RFon = True
- dim x : for x = 0 to 9 'Count X positions of balls in array
- if TypeName(Rballstack(x, 0)) = "IBall" then
- Rballstack(x, 2) = Rballstack(x, 0).X
- Rballstack(x, 3) = Rballstack(x, 0).Y
- Rballstack(x, 4) = Rballstack(x, 0).VelX
- End If
- Next
- dim b
- b = ((RightFlipper.StartAngle - RightFlipper.CurrentAngle) / (RightFlipper.StartAngle - RightFlipper.EndAngle))
- b = abs(b-1) 'invert
- Rballstack(0, 5) = b 'Partial Flip Coefficient
- 'tb.text = RightFlipper.StartAngle - RightFlipper.EndAngle & vbnewline & RightFlipper.CurrentAngle & vbnewline & b
- end Sub
- 'Puts an input X through a five-point, four line envelope with flat clamping at the ends
- 'Function Procedures: Input X, 2D array, special (if True, inverts first two lines for polarity script)
- 'This 2d Array should start at 1 and end at 5.
- '0,0 is used to hold an identifying string for debug purposes
- 'This 2d Array should hold X data in (x, 0) & Y data in (x, 1)
- 'Input X, Output Y
- Function FivePointEnvelope(xInput, yArray)', special)
- dim y, testF
- If xInput < yArray(2,0) Then 'Setup X Points 'please keep array X coords sequential!
- y = SlopeIt(xInput, yArray(1,0), yArray(1,1), yArray(2,0), yArray(2, 1) )
- If yArray(1,1) > yArray(2,1) then
- if y > yArray(1,1) then y = yArray(1,1) 'Clamp Low End
- elseif yArray(1,1) <= yArray(2,1) then
- if y <= yArray(1,1) then y = yArray(1,1) 'Clamp Low End
- End If
- testF = yArray(0,0) & " L1 (early1) " & "x= " & xInput & " y= " & y
- elseif xInput < yArray(3,0) Then 'l2
- y = SlopeIt(xInput, yArray(2,0), yArray(2,1), yArray(3,0), yArray(3,1) )
- testF = yArray(0,0) & " L2 (early2)" & "x= " & xInput & " y= " & y
- Elseif xInput < yArray(4,0) Then 'l3
- y = SlopeIt(xInput, yArray(3,0), yArray(3,1), yArray(4,0), yArray(4,1) )
- testF = yArray(0,0) & " L3 (late3)" & "x= " & xInput & " y= " & y
- Elseif xInput >= yArray(4,0) Then 'l4
- y = SlopeIt(xInput, yArray(4,0), yArray(4,1), yArray(5,0), yArray(5,1) )
- If yArray(5,1) > yArray(4,1) then 'Clamp High End
- if y > yArray(5,1) then y = yArray(5,1)
- elseif yArray(5,1) <= yArray(4,1) then
- if y <= yArray(5,1) then y = yArray(5,1)
- End If
- testF = yArray(0,0) & " L4 (late4) " & " x= " & xInput & " y= " & y
- Else
- debug.print "5error: " & yArray(0,0) & ", xinput = " & xInput : y = 1
- End If
- FivePointEnvelope = y
- End Function
- dim TestSpecial
- Function ThreePointEnvelope(xInput, yArray)
- dim y, test
- If xInput < yArray(2,0) Then
- y = SlopeIt(xInput, yArray(1,0), yArray(1,1), yArray(2,0), yArray(2,1) )
- If yArray(1,1) > yArray(2,1) then 'Clamp Low End
- if y > yArray(1,1) then y = yArray(1,1)
- elseif yArray(1,1) <= yArray(2,1) then
- if y < yArray(1,1) then y = yArray(1,1)
- End If
- test = "L1 (earliest) " & yArray(0,0) & " x= " & xInput & " y= " & y
- Elseif xInput >= yArray(2,0) Then 'l2
- y = SlopeIt(xInput, yArray(2,0), yArray(2,1), yArray(3,0), yArray(3,1) )
- If yArray(3,1) > yArray(2,1) then 'Clamp High End
- if y > yArray(3,1) then y = yArray(3,1)
- elseif yArray(3,1) <= yArray(2,1) then
- if y < yArray(3,1) then y = yArray(3,1)
- End If
- test = "L3 (latest) " & yArray(0,0) & " x= " & xInput & " y= " & y
- Else
- 'debug.print "3error: " & yArray(0,0) & ", xinput = " & xInput
- y = 1
- End If
- 'debug.print test
- ThreePointEnvelope = y
- End Function
- dim PolarityEnabled : PolarityEnabled = True 'debug
- Sub PolarityCorrect(object, xpos, ypos, xvel, PartialFLipCoef, LR) 'Corrects angle/velocity using ball data captured at flip
- if TypeName(object) = "Nothing" then Exit Sub 'Bug - This happens when the ball wavers in and out of trigger maybe
- if object.vely > 0 then TBpl.text = "exit sub" : exit sub
- dim TestVar : TestVar = "Cutoff" 'debug string
- dim lrcoef : if lr = 1 then lrcoef = -1 else lrcoef = 1 end if 'Direction Coef- could be used to compress the script. readability tho
- dim Y 'output (% ball-on-flipper position, 0=base 1=tip)
- if xpos <0.15 then TBpl.text = "xpos<0.15, exit sub " & vbnewline & " y =" & round(y,3) : exit sub 'Cutoff super early
- Select Case LR 'return position of ball on flipper as a % (0=base, 1=tip)
- case 0 : y = SlopeIt(xpos, LeftFlipper.X, 0, EndpointL, 1) 'base flipper -> 0
- case 1 : y = SlopeIt(xpos, RightFlipper.X, 0, EndpointR, 1) 'End flipper -> 1
- End Select
- if y > 1.05 then y = 1.05 'Clamp high End
- ''''''''''''''declare Polarity Correction + safeties'''''''''''''''
- dim AddX 'Polarity correction
- dim Ycoef:Ycoef = 1 'Safety coef #1 - Cut down Correction if the ball is sufficiently above the flipper base
- if Y > 0.65 then ycoef = ThreePointEnvelope(ypos, Ydiminish) 'Calculate Safety coef #1- if ball is above the flipper
- 'PartialFLipCoef - 'Safety coef #2 - handled by processballs, another safety coefficient
- if not PolarityEnabled then 'If Disabled, Exit Sub Here
- TBpl.text = "%" & round(y,5) & vbnewline & "PolarityEnabled = " & PolarityEnabled
- Exit Sub
- End If
- ''''''''''''''''''''Apply Velocity Correction''''''''''''''
- dim velcoef 'Overall Velocity coefficient
- Velcoef = FivePointEnvelope(y, VelMod) 'five point velocity envelope based on Y (% on flipper)
- Object.Velx = Object.VelX * velcoef
- Object.Vely = Object.VelY * velcoef
- ''''''''''''''''''''Apply Polarity Correction''''''''''''''
- AddX = FivePointEnvelope(y, PolarityMod)*lrcoef 'AddX - Find polarity correction
- object.VelX = object.VelX + 1*(AddX*ycoef*PartialFlipcoef) 'gogo
- '''''''''''''''''''''''Debug Strings''''''''''''''''''''''
- Select Case LR
- case 0 : TestVar = "Left:" & round(1*(AddX*ycoef*PartialFlipcoef),3) 'debug string 'left flipper
- case 1 : TestVar = "Right:" & round(1*(AddX*ycoef*PartialFlipcoef),3) 'debug string 'Right Flipper
- End Select
- 'debug stuff
- dim d1, d2, d3
- if ycoef < 1 then d1 = "ycoef: " & round(ycoef,5) & vbnewline
- if y = 1.05 then d2 = "(MAX)"
- if PartialFlipcoef < 1 then d3 = "PartialFlipcoef: " & round(PartialFlipcoef,4) & vbnewline
- TBpl.text = "%" & round(y,3) & d2 & vbnewline & _
- TestVar & vbnewline & _
- d1 & d3 & vbnewline & _
- " "
- End Sub
- Function BallSpeed(ball) 'Calculates the ball speed
- BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
- End Function
- '======================================
- Function SlopeIt(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
- SlopeIt = Y
- End Function
- '======================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement