Advertisement
Guest User

Scared Stiff 1.31 with test nudge

a guest
Sep 30th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VBScript 129.54 KB | None | 0 0
  1. '***********************
  2. '* Scared Stiff for VPX
  3. '* By Shoopity
  4. '* With HEAVY borrowing from Dozer's Mod of JPSalas' table
  5. '***********************
  6. 'Shoopity, Hauntfreaks, ICPJuggla, nFozzy, Arngrim, Clark Kent
  7. 'Some SFX from Knorr, JP, Clark Kent
  8. 'Ramp Textures by Flupper1
  9. 'Flare flasher image by LoadedWeapon
  10. 'New DT Backdrop by Batch
  11. 'EOStimer script based on LFHM by WRD1972 and Rothbauer
  12.  
  13. Option Explicit
  14. Randomize
  15. 'Version 1.31
  16. 'Replaced a few light images with better quality ones (new images are FlashAmbient512 and FlashQuad512. Use them, should be good common resources)
  17. 'Proper soundFX gain pass
  18. 'Added animated scorecard
  19.  
  20. 'Version 1.3 Changelog by nFozzy
  21. 'Optimization
  22. '-new GI in 3 flavors: Soft White, Cool White, and Colorized
  23. 'New Boogiemen
  24. 'New physics
  25. 'Added (limited) Support for pre-production roms with the kickback
  26. '-The aux light board isn't emulated properly, so crate and deadhead LEDs are not working atm.
  27. '-these roms have very early code and therefore simplified game rules.
  28.  
  29. 'Notes:
  30. 'You can change the GI in-game by hitting the Right magnasave while holding down the left magnasave
  31. 'The dancing boogiemen feature must be toggled on in the ROM. It's Feature Adjustment 32.
  32. 'STUTTERING ON OLDER VIDEO CARDS: please consider utilizing 'max texture dimensions' in the video options
  33. '-this table utilizes an 8K(!) Playfield and may overload your ram as a result!
  34.  
  35. Dim GIselect, SoundLevelMult
  36.  
  37. 'OPTIONS
  38. '=======================
  39. 'Rom select - uncomment one
  40. 'Const cGameName = "SS_01" 'prototype rom with kickback 'works, missing a few lamps though
  41. Const cGameName = "SS_15" 'latest rom
  42.  
  43. 'Select type of GI
  44. GiSelect = 3    '0 = Random     '1 = #44 incandescent   '2 = Cool Whites    '3 = White '4 = Colorized GI
  45.  
  46. 'Table SFX multiplier - may cause some normalization
  47. 'make sure Table Sound Effect Volume (under Table Properties) is already at 100 before increasing this
  48. SoundLevelMult = 1
  49.  
  50. 'Optional mod for extra lamps in the skulls (default 0)
  51. const SkullLEDMod = 0
  52.  
  53. 'Single-Screen FS support (Puts spider on the playfield)
  54. const SingleScreenFS = 0
  55.  
  56. '*************************************************************
  57. 'Debug stuff
  58. Dim DebugFlippers : DebugFlippers = False
  59. dim aDebugBoxes : aDebugBoxes = array(TBflipper, tbl, tbll, TB1, tbpl, TB2, TBbounces,TBwr)
  60. Sub DebugF(input)
  61.     dim x
  62.     if input = 5 then for each x in aDebugBoxes : x.visible = cBool(input) : next : exit sub
  63.     input = cbool(input)
  64.     debugflippers = cbool(input)
  65.     'FlippersEnabled = DebugFlippers    'fastflips support
  66. '   TiltSol input
  67.     'RollingTimer.Enabled = Not Input
  68.     destroyer.enabled = input
  69.     Drain.enabled = not input
  70.     'Sw10.enabled = not input 'space station specific, disable trough
  71.     'if not input then Sw10.kick -10, 45 'space station specific
  72.     for each x in aDebugBoxes : x.visible = input : next
  73. end sub
  74. debugf 0
  75. 'debugf 5
  76.  
  77. sub GimmeF() : kl.createsizedballwithmass 25, ballmass : kl.kick 0, 5 : debugf 1 : end Sub
  78. sub Gimme() : kr.createsizedballwithmass 25, ballmass : kr.kick 0, 5 : debugf 1 : end Sub
  79. sub GimmeC() : kFeedHole.createsizedballwithmass 25, ballmass : kFeedHole.kick 270, 15 : debugf 1 : end Sub
  80. sub GimmeS() : kFeedShooter.createsizedballwithmass 25, ballmass : kFeedShooter.kick 180, 1 : debugf 1 : end Sub
  81.  
  82.  
  83. '________________________________________________________
  84. '    _____                      ______                  
  85. '    /    '    /    ,             /                      
  86. '---/__-------/------------__----/--------__----__---_/_-
  87. '  /         /    /      /   )  /       /___)  (_ `  /  
  88. '_/_________/____/______/___/__/_______(___ __(__)__(_ __
  89. '                      /                                                        
  90. 'Setup -              /
  91. 'Four Kickers named kiL, kL, kR, kiR placed in inlanes and on flippers
  92. 'Primitive FlipStick (make it a flat vertical stick with >1 opacity)
  93. 'Timer "FlipTest2"
  94. 'textbox "tb2"
  95.  
  96.  
  97. dim FTSball : set FTSball = Nothing
  98. dim FlipDir, FlipDelayV
  99. Sub FTS(dir, input) 'hopefully more accurate flipper test sub
  100.     debugf 1
  101. '   FlipperLagCompensation 0    'remember to set this
  102.     dim x : x = 0
  103.     FlipDir = dir
  104.     FlipDelayV = input
  105.     Select Case dir
  106.         case 0 : Set FTSball = kil.createsizedballwithmass(25, ballmass) : kil.kick 0, 0
  107.         case 1 : Set FTSball = Kl.CreateSizedBallWithMass(25, ballmass) : Kl.Kick 2, 5 : SolBFlipper True : x = 2000
  108.         case 2 : Set FTSball = kR.CreateSizedBallWithMass(25, ballmass) : Kr.Kick -2, 5 : SolBFlipper True : x = 2000
  109.         case Else : Set FTSball = kir.createsizedballwithmass(25, ballmass) : kir.kick 0, 0 : flipdir = 3' : SolBFlipper True : x = 2000
  110.     End Select
  111.     if x > 0 then
  112.         FlipDelayT1.Interval = x
  113.         FlipDelayT1.Enabled = 1
  114.     Else
  115.         FlipTestV input 'fire flipper after a delay
  116.     end if
  117. End Sub
  118.  
  119. Sub FlipDelayT1_Timer(): SolBFlipper False : FlipTestV FlipDelayV : me.enabled = 0 : End Sub
  120.  
  121.  
  122. Sub SolBFlipper(enabled)
  123.     On Error Resume Next
  124.     select case FlipDir
  125.         case 2, 3 : SolRFlipper enabled : x = (FTSball.x-RightFlipper.X) / (EndPointR - rightflipper.x)
  126.         case else : SolLFlipper enabled : x = (FTSball.x-LeftFlipper.X) / (EndPointL - LeftFlipper.x)
  127.     end select
  128.     if not enabled then exit sub
  129.     FlipStick.x = FTSball.x : FlipStick.Visible = True
  130.     x = RoundPercent(x)
  131.     tb2.text = tb2.text & vbnewline & "%" & x' & vbnewline & "  flip: " & LeftFlipper.x & " ball:" & FTSball.x
  132. End Sub
  133.  
  134. Function RoundPercent(input) : RoundPercent = mid(input, 1, 7)*100 : End Function   'round and mult by 100 for percentage
  135.  
  136. dim FlipInputV
  137. Sub FlipTestV(input)
  138.     tb2.text = "                          " & input & " MS"
  139.     FlipTest2.Interval = input : FlipTestOn = True
  140.     FlipTest2.Enabled = 1
  141. End Sub
  142.  
  143. dim FlipTestOn
  144. Sub FlipTest2_Timer()
  145.     if FlipTestOn then
  146.         SolBflipper True : me.interval = 100 : flipteston = False
  147.     Else
  148.         SolBflipper False
  149.         me.enabled = 0
  150.     end if
  151. End Sub
  152.  
  153.  
  154. '**********************************
  155.  
  156.  
  157.  
  158. '******************************************************************************
  159. '     _______.  ______    __    __  .__   __.  _______      _______ ___   ___
  160. '    /       | /  __  \  |  |  |  | |  \ |  | |       \    |   ____|\  \ /  /
  161. '   |   (----`|  |  |  | |  |  |  | |   \|  | |  .--.  |   |  |__    \  V  /  
  162. '    \   \    |  |  |  | |  |  |  | |  . `  | |  |  |  |   |   __|    >   <  
  163. '.----)   |   |  `--'  | |  `--'  | |  |\   | |  '--'  |   |  |      /  .  \  
  164. '|_______/     \______/   \______/  |__| \__| |_______/    |__|     /__/ \__\
  165. '                                                                            
  166. '******************************************************************************
  167.  
  168.  
  169. '10.4 playsound args - name,loopcount,volume,pan,randompitch,pitch,UseExisting,Restart,Fade
  170.  
  171. 'SoundFX with Falloff subs
  172. '**************************
  173. Sub Rubbers_Hit(idx)    'bands, native falloff
  174.     Playsound RandomBand, 0, LVL(Vol(ActiveBall)*1 ), Pan(ActiveBall)*50, 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall)
  175. End Sub
  176.  
  177. '   Post rounds
  178. Sub Posts_Hit(idx)
  179.     FalloffSimple r1, r2, r3, r4, "Posts"
  180.     PlaySound RandomPost, 0, LVL(Vol(ActiveBall)*1 ), Pan(ActiveBall)*50, 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
  181. End Sub
  182.  
  183. Sub Frogs_Hit(idx)
  184.     FalloffSimple f1, f2, f3, f4, "Frogs"
  185.     PlaySound SoundFX("target",DOFTargets), 0, LVL(Vol(ActiveBall)*1.5), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, Fade(ActiveBall)
  186. End Sub
  187.  
  188. Sub Targets_Hit (idx)
  189.     FalloffSimple t1, t2, t3, t4, "Targets"
  190.     PlaySound SoundFX("target",DOFTargets), 0, LVL(Vol(ActiveBall)*1.5), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, Fade(ActiveBall)
  191. '   PlaySound SoundFX("targethit",DOFTargets), 0, LVL(Vol(ActiveBall)*1.5), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, Fade(ActiveBall)
  192. End Sub
  193. 'SLeeves
  194.  
  195. Sub zCol_PostSleeves_Hit()
  196.     FalloffSimple s1, s2, s3, s4, "Sleeves"
  197.     PlaySound RandomPost, 0, LVL(Vol(ActiveBall)*1 ), Pan(ActiveBall)*50, 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
  198. End Sub
  199.  
  200. 'Other Sounds
  201. '**************************
  202. 'Sub Prim_CrateSubmarine_hit()
  203. '   PlaySound "WoodHitAluminium", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
  204. 'end sub
  205.  
  206. 'ramp sounds
  207. Sub RampSounds_Hit(idx)
  208.     PlaySound "ramp_hit1", 0, LVL(Vol(ActiveBall)/2), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
  209.     WireRampOn True 'Ramp SFX Tracking, True = Plastic
  210. end sub
  211.  
  212. Sub RampSounds2_Hit(idx)
  213.     If activeball.vely < -10 then
  214.         PlaySound "ramp_hit2", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall), 0, Pitch(ActiveBall)*10, 1, 0, Fade(ActiveBall)
  215.         WireRampOn True 'Ramp SFX Tracking, True = Plastic
  216.     Elseif activeball.vely > 3 then
  217.         PlaySound "PlayfieldHit", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
  218.     End If
  219. end sub
  220.  
  221. Sub Metals_Medium_Hit (idx)
  222.     PlaySound "metalhit_medium", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
  223. End Sub
  224.  
  225. Sub Metals2_Hit (idx)
  226.     PlaySound "metalhit2", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
  227. End Sub
  228.  
  229. Sub ApronWall_Hit() 'apron hit
  230.     PlaySound "WoodHitAluminium", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall) / 2, 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
  231. end sub
  232.  
  233. Sub Gates_Hit (idx)
  234.     PlaySound "gate4", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
  235. End Sub
  236.  
  237.  
  238. 'SFX (string) functions -SFX - Posts 1-5, Bands 1-4 and 11,22,33,44
  239. Function RandomPost() : RandomPost = "Post" & rndnum(1,5) : End Function
  240.  
  241. Function RandomBand()
  242.         dim x : x = rndnum(1,4)
  243.         if BallVel(activeball) > 30 then
  244.             RandomBand = "Rubber" & x & x   'ex. Playsound "Band44"
  245.         else
  246.             RandomBand = "Rubber" & x   'ex. Playsound "Band4"
  247.         End If
  248. End Function
  249.  
  250. 'Flipper collide sound
  251. Sub LeftFlipper_Collide(parm) : RandomSoundFlipper() : End Sub
  252. Sub RightFlipper_Collide(parm) : RandomSoundFlipper() : End Sub
  253. Sub RandomSoundFlipper()
  254.     dim x : x = RndNum(1,3)
  255.     PlaySound "flip_hit_" & x, 0, LVL(Vol(ActiveBall) ), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall)
  256. End Sub
  257.  
  258. ' Ball Collision Sound
  259. 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
  260.  
  261. '*****************************************
  262. '      JP's VP10 Rolling Sounds
  263. '*****************************************
  264. Const tnob = 9 ' total number of balls
  265. ReDim rolling(tnob)
  266. InitRolling : Sub InitRolling : Dim i : For i = 0 to tnob : rolling(i) = False : Next : End Sub
  267.  
  268. Sub RollingTimer_Timer
  269.     'On Error Resume Next
  270.    Dim BOT, b : BOT = GetBalls
  271.  
  272.     For b = UBound(BOT) + 1 to tnob ' stop the sound of deleted balls
  273.         rolling(b) = False
  274.         StopSound("tablerolling" & b)
  275.     Next
  276.  
  277.     If UBound(BOT) = -1 Then Exit Sub   ' exit the sub if no balls on the table
  278.  
  279.     For b = 0 to UBound(BOT)    ' play the rolling sound for each ball
  280.         If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  281.             rolling(b) = True
  282.             PlaySound("tablerolling" & b), -1, Vol(BOT(b) )*0.3, Pan(BOT(b) )*3, 0, BallPitch(BOT(b)), 1, 0,Fade(BOT(b))*3
  283.         Else
  284.             If rolling(b) = True Then
  285.                 StopSound("tablerolling" & b)
  286.                 rolling(b) = False
  287.             End If
  288.         End If
  289.     Next
  290. End Sub
  291.  
  292. Sub StopAllRolling()    'call this at table pause!!!
  293.     dim b : for b = 0 to tnob
  294.         StopSound("tablerolling" & b)
  295.         StopSound("RampLoop" & b)
  296.         StopSound("wireloop" & b)
  297.     next
  298. end sub
  299.  
  300. '=====================================
  301. '       Ramp Rolling SFX updates nf
  302. '=====================================
  303. 'Ball tracking ramp SFX 1.0
  304. '   Usage:
  305. '- Setup hit events with WireRampOn True or WireRampOn False (True = Plastic ramp, False = Wire Ramp)
  306. '- To stop tracking ball, use WireRampoff
  307. '-- Otherwise, the ball will auto remove if it's below 30 vp units
  308.  
  309. 'Example, from Space Station:
  310. 'Sub RampSoundPlunge1_hit() : WireRampOn  False : End Sub                       'Enter metal habitrail
  311. 'Sub RampSoundPlunge2_hit() : WireRampOff : WireRampOn True : End Sub           'Exit Habitrail, enter onto Mini PF
  312. 'Sub RampEntry_Hit() : If activeball.vely < -10 then WireRampOn True : End Sub  'Ramp enterance
  313. dim RampMinLoops : RampMinLoops = 4
  314. dim RampBalls(6,2)
  315. 'x,0 = ball x,1 = ID,   2 = Protection against ending early (minimum amount of updates)
  316. '0,0 is boolean on/off, 0,1 unused for now
  317. RampBalls(0,0) = False
  318.  
  319. dim RampType(6) 'Slapped together support for multiple ramp types... False = Wire Ramp, True = Plastic Ramp
  320.  
  321. Sub WireRampOn(input)  : Waddball ActiveBall, input : RampRollUpdate: End Sub
  322. Sub WireRampOff() : WRemoveBall ActiveBall.ID   : End Sub
  323.  
  324. Sub Waddball(input, RampInput)  'Add ball  
  325.     dim x : for x = 1 to uBound(RampBalls)  'Check, don't add balls twice
  326.         if RampBalls(x, 1) = input.id then
  327.             if Not IsEmpty(RampBalls(x,1) ) then Exit Sub   'Frustating issue with BallId 0. Empty variable = 0
  328.         End If
  329.     Next
  330.    
  331.     For x = 1 to uBound(RampBalls)
  332.         if IsEmpty(RampBalls(x, 1)) then
  333.             Set RampBalls(x, 0) = input
  334.             RampBalls(x, 1) = input.ID
  335.             RampType(x) = RampInput
  336.             RampBalls(x, 2) = 0
  337.             'exit For
  338.             RampBalls(0,0) = True
  339.             RampRoll.Enabled = 1     'Turn on timer
  340.             'RampRoll.Interval = RampRoll.Interval 'reset timer
  341.             exit Sub
  342.         End If
  343.         if x = uBound(RampBalls) then   'debug
  344.             Debug.print "WireRampOn error, ball queue is full: " & vbnewline & _
  345.                          RampBalls(0, 0) & vbnewline & _
  346.                          Typename(RampBalls(1, 0)) & " ID:" & RampBalls(1, 1) & "type:" & RampType(1) & vbnewline & _
  347.                          Typename(RampBalls(2, 0)) & " ID:" & RampBalls(2, 1) & "type:" & RampType(2) & vbnewline & _
  348.                          Typename(RampBalls(3, 0)) & " ID:" & RampBalls(3, 1) & "type:" & RampType(3) & vbnewline & _
  349.                          Typename(RampBalls(4, 0)) & " ID:" & RampBalls(4, 1) & "type:" & RampType(4) & vbnewline & _
  350.                          Typename(RampBalls(5, 0)) & " ID:" & RampBalls(5, 1) & "type:" & RampType(5) & vbnewline & _
  351.                          " "
  352.         End If
  353.     next
  354. End Sub
  355.  
  356. Sub WRemoveBall(ID)     'Remove ball
  357.     dim ballcount : ballcount = 0
  358.     dim x : for x = 1 to Ubound(RampBalls)
  359.         if ID = RampBalls(x, 1) then 'remove ball
  360.             Set RampBalls(x, 0) = Nothing
  361.             RampBalls(x, 1) = Empty
  362.             RampType(x) = Empty
  363.             StopSound("RampLoop" & x)
  364.             StopSound("wireloop" & x)
  365.         end If
  366.         'if RampBalls(x,1) = Not IsEmpty(Rampballs(x,1) then ballcount = ballcount + 1
  367.         if not IsEmpty(Rampballs(x,1)) then ballcount = ballcount + 1
  368.     next
  369.     if BallCount = 0 then RampBalls(0,0) = False    'if no balls in queue, disable timer update
  370. End Sub
  371.  
  372. Sub RampRoll_Timer():RampRollUpdate:End Sub
  373.  
  374. Sub RampRollUpdate()        'Timer update
  375.     dim x : for x = 1 to uBound(RampBalls)
  376.         if Not IsEmpty(RampBalls(x,1) ) then
  377.             if BallVel(RampBalls(x,0) ) > 1 then ' if ball is moving, play rolling sound
  378.                 If RampType(x) then
  379.                     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
  380.                     StopSound("wireloop" & x)
  381.                 Else
  382.                     StopSound("RampLoop" & x)
  383.                     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
  384.                 End If
  385.                 RampBalls(x, 2) = RampBalls(x, 2) + 1
  386.             Else
  387.                 StopSound("RampLoop" & x)
  388.                 StopSound("wireloop" & x)
  389.             end if
  390.             if RampBalls(x,0).Z < 30 and RampBalls(x, 2) > RampMinLoops then    'if ball is on the PF, remove  it
  391.                 StopSound("RampLoop" & x)
  392.                 StopSound("wireloop" & x)
  393.                 Wremoveball RampBalls(x,1)
  394.             End If
  395.         Else
  396.             StopSound("RampLoop" & x)
  397.             StopSound("wireloop" & x)
  398.         end if
  399.     next
  400.     if not RampBalls(0,0) then RampRoll.enabled = 0
  401.  
  402. End Sub
  403.  
  404.  
  405. Sub tbWR_Timer()    'debug textbox
  406.     me.text =   "on? " & RampBalls(0, 0) & " timer: " & RampRoll.Enabled & vbnewline & _
  407.                  "1 " & Typename(RampBalls(1, 0)) & " ID:" & RampBalls(1, 1) & " type:" & RampType(1) & " Loops:" & RampBalls(1, 2) & vbnewline & _
  408.                  "2 " & Typename(RampBalls(2, 0)) & " ID:" & RampBalls(2, 1) & " type:" & RampType(2) & " Loops:" & RampBalls(2, 2) & vbnewline & _
  409.                  "3 " & Typename(RampBalls(3, 0)) & " ID:" & RampBalls(3, 1) & " type:" & RampType(3) & " Loops:" & RampBalls(3, 2) & vbnewline & _
  410.                  "4 " & Typename(RampBalls(4, 0)) & " ID:" & RampBalls(4, 1) & " type:" & RampType(4) & " Loops:" & RampBalls(4, 2) & vbnewline & _
  411.                  "5 " & Typename(RampBalls(5, 0)) & " ID:" & RampBalls(5, 1) & " type:" & RampType(5) & " Loops:" & RampBalls(5, 2) & vbnewline & _
  412.                  "6 " & Typename(RampBalls(6, 0)) & " ID:" & RampBalls(6, 1) & " type:" & RampType(6) & " Loops:" & RampBalls(6, 2) & vbnewline & _
  413.                  " "
  414. End Sub
  415.  
  416. ' *********************************************************************
  417. '                      Ball & Sound Functions
  418. ' *********************************************************************
  419. '10.4 playsound args - name,loopcount,volume,pan,randompitch,pitch,UseExisting,Restart,Fade
  420.  
  421. '**************** 3D Audio Vp10.4 Functions ****************
  422. 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
  423.     Dim tmp
  424.     tmp = tableobj.y * 2 / table1.height-1
  425.     If tmp > 0 Then
  426.         Fade = Csng(tmp ^10)
  427.     Else
  428.         Fade = Csng(-((- tmp) ^10) )
  429.     End If
  430. End Function
  431.  
  432. 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
  433.     Dim tmp
  434.     tmp = y * 2 / table1.height-1
  435.     If tmp > 0 Then
  436.         FadeY = Csng(tmp ^10)
  437.     Else
  438.         FadeY = Csng(-((- tmp) ^10) )
  439.     End If
  440. End Function
  441.  
  442. '**************** Other sound functions ****************
  443. Function RndNum(min, max)
  444.     RndNum = Int(Rnd() * (max-min + 1) ) + min ' Sets a random number between min and max
  445. End Function
  446.  
  447. Function LVL(input) : LVL = Input * SoundLevelMult : End Function
  448.  
  449. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  450.    Vol = Csng(BallVel(ball) ^2 / 2000)
  451. End Function
  452.  
  453. Function Vol2(ball1, ball2) ' Calculates the Volume of the sound based on the speed of two balls
  454.    Vol2 = (Vol(ball1) + Vol(ball2) ) / 2
  455. End Function
  456.  
  457. Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
  458.    Dim tmp : tmp = ball.x * 2 / Table1.width-1
  459.     If tmp> 0 Then
  460.         Pan = Csng(tmp ^10)
  461.     Else
  462.         Pan = Csng(-((- tmp) ^10) )
  463.     End If
  464. End Function
  465.  
  466. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  467.    Pitch = BallVel(ball) * 20
  468. End Function
  469.  
  470. Function BallVel(ball) 'Calculates the ball speed
  471.    BallVel = INT(SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2) )
  472. End Function
  473.  
  474. Function BallSpeed(ball) 'Calculates the ball speed
  475.    BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
  476. End Function
  477.  
  478. 'new
  479. Function BallPitch(ball) ' Calculates the pitch of the sound based on the ball speed
  480.    BallPitch = SlopeIt(BallVel(ball), 1, -1000, 60, 10000)
  481. End Function
  482. Function BallPitchV(ball) ' Calculates the pitch of the sound based on the ball speed Variation
  483.    BallPitchV = SlopeIt(BallVel(ball), 1, -1000, 60, 30000)
  484. End Function
  485.  
  486.  
  487. '====ELASTICITY========================================================
  488. ' _______      ___       __       __        ______    _______  _______
  489. '|   ____|    /   \     |  |     |  |      /  __  \  |   ____||   ____|
  490. '|  |__      /  ^  \    |  |     |  |     |  |  |  | |  |__   |  |__  
  491. '|   __|    /  /_\  \   |  |     |  |     |  |  |  | |   __|  |   __|  
  492. '|  |      /  _____  \  |  `----.|  `----.|  `--'  | |  |     |  |    
  493. '|__|     /__/     \__\ |_______||_______| \______/  |__|     |__|                                                                          
  494. '======================================================================
  495. 'This script doesn't track ball angle like Jimmyfinger's script does so it may cause some weird ball movement on glancing shots
  496. 'Usage - Define a falloff line with two points, and then a string for debug purposes
  497. 'Falloffn x1,y1,x2,y2, DebugString
  498. '(x = Input velocity, y = output Coef)
  499. 'Debug box "TBbounces"
  500. 'Usage: falloffsimple 1,1, 54,0.5, "Targets"
  501. 'TODO might add 3 point and 5 point envelopes
  502.  
  503. Sub FalloffSimple(X1, Y1, X2, Y2, DebugString)  'Two points
  504.     Dim FinalSpeed : FinalSpeed = BallSpeed(ActiveBall) : if FinalSpeed < X1 then Exit Sub  'Cutoff Low
  505.     Dim BounceCoef : BounceCoef = SlopeIt(FinalSpeed,X1,Y1,X2,Y2)
  506.         if BounceCoef < Y2 then BounceCoef = Y2 : DebugString = DebugString & vbnewline & "Clamped" 'Clamp High
  507.         activeball.velx = activeball.velx * BounceCoef
  508.         activeball.vely = activeball.vely * BounceCoef
  509.        
  510.         DebugString = "FalloffSimple " & Debugstring & vbnewline
  511.         FalloffDebugBox TBbounces, Finalspeed, BallSpeed(ActiveBall), BounceCoef, DebugString
  512. End Sub
  513.  
  514. Sub FalloffDebugBox(object, input,output,Coef,debugstring)  'Debug Box
  515.     'if not debugflippers then Exit Sub
  516.     object.Text = Debugstring & round(input,4) & vbnewline & round(output,4) & vbnewline & "%" & round(coef,4)
  517.     object.TimerEnabled = 1
  518. End Sub
  519. TBbounces.TimerInterval = 3000  'reset debug textbox after this interval
  520. Sub TBbounces_Timer():me.timerenabled = 0 : me.text = Empty : End Sub
  521. TBFlipper.TimerInterval = 5000  'reset debug textbox after this interval
  522. Sub TBFlipper_Timer():me.timerenabled = 0 : me.text = Empty : End Sub
  523.  
  524. Dim r1, r2, r3, r4
  525. Dim S1, s2, s3, s4
  526. dim T1, t2, t3, t4
  527. Dim F1, f2, f3,f4
  528.  
  529. r1 = 18 : r2 = 1 : r3 = 58 : r4 = 0.3   'Posts
  530. s1 = 12 : s2 = 1 : s3 = 40 : s4 = 0.5   'Sleeves
  531. t1 = 2 : t2 = 1 : t3 = 50 : t4 = 0.4    'Targets
  532. f1 = 2 : f2 = 1 : f3 = 50 : f4 = 0.31   'Frogs
  533.  
  534.  
  535.  
  536. '===========================
  537.  
  538. dim Ballsize : BallSize = 50'49.9634
  539. dim BallMass : BallMass = 1.65'.3'1.69876
  540. const UseVPMModSol=true
  541.  
  542. On Error Resume Next
  543. ExecuteGlobal GetTextFile("controller.vbs")
  544. If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
  545. On Error Goto 0
  546.  
  547. LoadVPM "01530000", "WPC.VBS", 3.10
  548.  
  549.  
  550. '===========================
  551.  
  552. Const UseSolenoids = 1
  553. Const UseLamps = 0
  554. Const UseGI = 0
  555. Const UseSync = 0
  556. Const HandleMech = 1
  557. Const SCoin = "fx_Coin"
  558.  
  559. SideRails.Visible = Table1.ShowDT
  560.  
  561. 'if not Table1.ShowDT then Ramp37.visible = 0 : Ramp10.visible = 0  'remove glass in FS
  562. Lbolt1.visible = 0 : Lbolt2.Visible = 0 : L35r.visible = 0 : Lcandle1.visible = 0 : Lcandle2.visible = 0
  563. dim Proto : Proto = False
  564. If cGameName = "SS_01" then     'I made an honest attempt at this but unfortunately
  565.     'tb.text = "prototype running..."'the preproduction aux lamp board is not supported by pinmame
  566.     MetalProto.Visible = True
  567.     MetalProto.Collidable = True
  568.     Proto = True
  569.  
  570.     'get rid of left post
  571.     Col_Rubber_LeftAdjust.Collidable = False
  572.     Post_Adjustable1_Rubber.Visible = False
  573.     Post_Adjustable1.visible = False
  574.  
  575.     'Disable Skull Flashers
  576.     F21f.visible = 0
  577.     f25f.visible = 0
  578.     F20n.Visible = 0    'and Bolt flasher
  579.     'Enable Prototype Lamps
  580.     Lbolt1.visible = 1 : Lbolt2.Visible = 1 : L35r.visible = 1  'bolt lamps, and new metal wall reflection
  581.     Lcandle1.visible = 1 : Lcandle2.visible = 1 'backglass???
  582. End If
  583.  
  584.  
  585.  
  586. Dim Save2700K(200, 3)   '0 = color 1 = colorfull 2 = intensity 3 = GIreflections
  587. Save2700kvalues
  588. sub Save2700kvalues()   'keep default-editor 2700K colors in an array
  589.     dim x
  590.     for x = 0 to (gi2.count -1)
  591.         on error resume Next
  592.         save2700k(x, 0) = GI2(x).color
  593.         save2700k(x, 1) = GI2(x).colorfull
  594.         save2700k(x, 2) = GI2(x).intensity
  595.     Next
  596.     for x = 0 to (gi2.count -1)
  597.         on error resume Next
  598.         save2700k(x, 3) = BallReflections(x).color
  599.     Next
  600. End Sub
  601.        
  602. dim lastinput : lastinput = 0
  603. Sub GItype(input)
  604.     dim xg, xp, x, s, rnd
  605.     Select Case input
  606.         case 1  '2700k ACES
  607.             xg = "GI_2700K" : xp = "GIP_2700K"
  608.             for x = 0 to (gi2.count -1)
  609.                 On Error Resume Next
  610.                 GI2(x).color = save2700k(x, 0)
  611.                 GI2(x).colorfull = save2700k(x, 1)
  612.                 GI2(x).intensity = save2700k(x, 2)
  613.             Next
  614.             for x = 200 to 203      'GI relay on / off  Fading Speeds
  615.                 FlashSpeedUp(x) = 0.01
  616.                 FlashSpeedDown(x) = 0.008
  617.             Next
  618.             for x = 300 to 303      'GI 8 step modulation
  619.                 FlashSpeedUp(x) = 0.01
  620.                 FlashSpeedDown(x) = 0.008
  621.             Next
  622.             for x = 0 to (BallReflections.Count-1'ball reflections
  623.                 BallReflections(x).Color = save2700k(x, 3)
  624.             Next
  625.         case 2  '4100k ACES
  626.             xg = "GI_4100K" : xp = "GIP_4100K"
  627.             for each x in GI2
  628.                 On Error Resume Next
  629.                 s = mid(x.name, 3, 1)
  630.                 if s = "t" then 'transmit
  631.                     x.Color = RGB(44, 58, 77)
  632.                     x.ColorFull = RGB(188, 188, 155)
  633.                 end If
  634.             Next
  635.             git3.colorfull = rgb(255,239,232)   'bulbs
  636.             git3.color = rgb(253,227,151)
  637.             git4.colorfull = rgb(255,239,232)
  638.             git4.color = rgb(253,227,151)
  639.             git5.colorfull = rgb(255,239,232)
  640.             git5.color = rgb(253,227,151)
  641.             for x = 200 to 203      'GI relay on / off
  642.                 FlashSpeedUp(x) = 0.014
  643.                 FlashSpeedDown(x) = 0.014
  644.             Next
  645.             for x = 300 to 303      'GI 8 step modulation
  646.                 FlashSpeedUp(x) = 0.014
  647.                 FlashSpeedDown(x) = 0.014
  648.             Next
  649.             for x = 0 to (BallReflections.Count-1)
  650.                 BallReflections(x).Color = RGB(255,215,166)
  651.             Next
  652.         Case 3  'White
  653.             xg = "GI_White" : xp = "GIP_White"
  654.             for each x in GI2
  655.                 x.Color = RGB(255, 255, 255)
  656.                 On Error Resume Next
  657.                 s = mid(x.name, 3, 1)
  658.                 if s = "t" then 'transmit
  659.                     x.ColorFull = RGB(255, 255, 255)
  660.                 end If
  661.             Next
  662.             git3.colorfull = rgb(255,255,255)   'bulbs
  663.             git3.color = rgb(0,0,0) 'rgb(255,255,255)
  664.             git4.colorfull = rgb(255,255,255)
  665.             git4.color = rgb(0,0,0)'rgb(255,255,255)
  666.             git5.colorfull = rgb(255,255,255)
  667.             git5.color = rgb(0,0,0)'rgb(255,255,255)
  668.             for x = 200 to 203      'GI relay on / off
  669.                 FlashSpeedUp(x) = 0.014
  670.                 FlashSpeedDown(x) = 0.014
  671.             Next
  672.             for x = 300 to 303      'GI 8 step modulation
  673.                 FlashSpeedUp(x) = 0.014
  674.                 FlashSpeedDown(x) = 0.014
  675.             Next
  676.             for x = 0 to (BallReflections.Count-1)
  677.                 BallReflections(x).Color = RGB(215,226,255)
  678.             Next
  679.         case 4  'Colorized
  680.             xg = "GI_Color" : xp = "GIP_Color"
  681.             for each x in GI2
  682.                 x.color = rgb(0, 0, 0)
  683.             Next
  684.             gi.color = rgb(255,255,255)         'gi (always white, image modulates colors)
  685.             gip.color = rgb(255,255,255)        'gi plastics
  686.             git7.colorfull = rgb(250, 20, 250'inlanes
  687.             git8.colorfull = rgb(250, 20, 250'...
  688.             git3.colorfull = rgb(5,250,5)       'bulbs
  689.             git4.colorfull = rgb(5,250,5)       '...
  690.             git5.colorfull = rgb(250, 20, 250)      'bumper area bulb
  691.  
  692.             git1.colorfull = rgb(5,250,5)       'Sling Plastics
  693.             git2.colorfull = rgb(5,250,5)       '...
  694.             Git6.colorfull = rgb(250, 20, 250)  'Rollovers
  695.  
  696.             for x = 200 to 203      'GI relay on / off
  697.                 FlashSpeedUp(x) = 0.014
  698.                 FlashSpeedDown(x) = 0.014
  699.             Next
  700.             for x = 300 to 303      'GI 8 step modulation
  701.                 FlashSpeedUp(x) = 0.014
  702.                 FlashSpeedDown(x) = 0.014
  703.             Next
  704.             'GI reflections
  705.             dim sat : sat = 2
  706.             Gi_BallRefl1.Color = RGB(sat,sat,255)   'green
  707.             Gi_BallRefl2.Color = RGB(sat,sat,255)
  708.  
  709.             Gi_BallRefl3.Color = RGB(255,sat,255) 'pink
  710.             Gi_BallRefl4.Color = RGB(255,sat,255)
  711.             Gi_BallRefl5.Color = RGB(255,sat,255)
  712.             Gi_BallRefl6.Color = RGB(255,sat,255)
  713.             Gi_BallRefl7.Color = RGB(255,sat,255)
  714.  
  715.             Gi_BallRefl11.Color = RGB(255,sat,255)
  716.             Gi_BallRefl12.Color = RGB(255,sat,255)
  717.  
  718.             Gi_BallRefl8.Color = RGB(255,sat,sat)   'red
  719.  
  720.             Gi_BallRefl9.Color = RGB(sat,sat,255)   'blue
  721.             Gi_BallRefl10.Color = RGB(sat,sat,255)
  722.  
  723.         case 0  'Random
  724.             rnd = rndnum(1, 4)
  725.             if rnd <> lastinput then GItype rnd else gitype 0 end if
  726.             Exit Sub
  727.         Case 5 'Sequential
  728.             If LastInput > 3 then LastInput = 0
  729.             gitype (Lastinput+1)
  730.             Exit Sub
  731.         Case Else
  732.             Gitype 0 : exit sub
  733.     End Select
  734. '   dim temp
  735. '   temp = lastinput
  736.     lastinput = input
  737.     GI.ImageA = xg
  738.     GIP.ImageA = xp
  739.  
  740. '   tb.text = temp & " " & input    'debug
  741. End Sub
  742.  
  743. 'EOStimer (just switches elast falloff)
  744. '============
  745.  
  746. 'LFHM physics by wrd1972 and Rothbauer
  747. dim EOSAngle,ElastFalloffUp,ElastFalloffDown
  748.  
  749. 'This rules but it would be way better if it was elasticity and not elast falloff
  750. ElastFalloffup = LeftFlipper.ElasticityFalloff
  751. ElastFalloffdown = 0.25'0.7
  752.  
  753. 'EOS angle
  754. EOSAngle = 4
  755.  
  756. 'Flipper EOS timer (HMLF)
  757. dim LastAngle1, LastAngle2  '
  758. Sub eostimer_Timer()    'use -1 timer interval for this?
  759.     If LeftFlipper.CurrentAngle <> LastAngle1 then  'slight optimization
  760.         If LeftFlipper.CurrentAngle < LeftFlipper.EndAngle + EOSAngle Then
  761.             LeftFlipper.ElasticityFalloff = ElastFalloffup
  762.         Else
  763.             LeftFlipper.ElasticityFalloff = ElastFalloffdown    ' This works for flippers :D
  764.         End If
  765.     End If
  766.     If RightFlipper.CurrentAngle <> LastAngle2 then
  767.         If RightFlipper.CurrentAngle > RightFlipper.EndAngle - EOSAngle Then
  768.             RightFlipper.ElasticityFalloff = ElastFalloffup
  769.         Else
  770.             RightFlipper.ElasticityFalloff = ElastFalloffdown
  771.         End If
  772.     End If
  773.     LastAngle1 = LeftFlipper.CurrentAngle
  774.     LastAngle2 = RightFLipper.CurrentAngle
  775. End Sub
  776.  
  777.  
  778.  
  779. Sub SolLFlipper(Enabled)
  780.     If Enabled Then
  781.         PlaySound SoundFX("FlipperUpLeft",DOFContactors), 0, LVL(0.75), -0.0375, 0.1
  782.         LeftFlipper.RotateToEnd
  783.         ProcessballsL
  784.     Else
  785.         PlaySound SoundFX("FlipperDown",DOFContactors), 0, LVL(0.01), -0.0375, 0.1
  786.         LeftFlipper.RotateToStart
  787.     End If
  788. End Sub
  789.  
  790. Sub SolRFlipper(Enabled)
  791.     If Enabled Then
  792.         PlaySound SoundFX("FlipperUpLeft",DOFContactors), 0, LVL(0.75), 0.0375, 0.1
  793.         RightFlipper.RotateToEnd
  794.         ProcessballsR
  795.     Else
  796.         PlaySound SoundFX("FlipperDown",DOFContactors), 0, LVL(0.01), 0.0375, 0.1
  797.         RightFlipper.RotateToStart
  798.     End If
  799. End Sub
  800.  
  801.  
  802.  
  803.  
  804. 'Key input Stuff
  805. '==============
  806.  
  807. Dim DesktopMode:DesktopMode = Table1.ShowDT
  808. dim CardTex : CardTex = False 'False = Graphic Scorecard True = Default paper
  809. ScoreCardDT.Visible = DesktopMode : ScoreCardFS.Visible = Not DesktopMode
  810. sub Destroyer_hit():me.destroyball:end sub
  811.  
  812. Sub table1_Paused:Controller.Pause = 1: StopAllRolling :End Sub
  813. Sub table1_unPaused:Controller.Pause = 0:End Sub
  814. 'dim t0, T1
  815. 't0 = 180
  816. 't1 = 10
  817.  
  818. dim catchinput(1)
  819. Sub Table1_KeyDown(ByVal keycode)
  820.     If Keycode = StartGameKey then Controller.Switch(13) = 1
  821.     If keycode = PlungerKey Then PlaySound SoundFx("PlungerPull",0), 0, LVL(0.01), 0.06, 0.2:Plunger.Pullback:end if
  822.     'if keycode = 31 then SolLeftSling 1' : kicker1.createball:kicker1.kick t0, t1
  823. '   if keycode = 33 then SolRightSling 1
  824.     if KeyCode = KeyRules then if DeskTopMode then Setlamp cCardDT, 1 : else Setlamp cCardFS, 1 end if
  825.     If Keycode = RightFlipperKey then if DebugFlippers then SolRFlipper 1 : Exit Sub
  826.     If Keycode = LeftFlipperKey then if DebugFlippers then SolLFlipper 1 : Exit Sub
  827.     If keycode = LeftTiltKey Then nfNudge -1, 1.5'vpmnudge.doNudge 90, 3.5 : exit sub
  828.     If keycode = RightTiltKey Then nfNudge 1, 1.5'vpmnudge.doNudge 270, 3.5 : exit sub
  829.     If keycode = CenterTiltKey Then nfNudge 0, 1.5'vpmnudge.doNudge 0, 3.5 : exit sub
  830.     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)
  831.     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
  832.     If vpmKeyDown(keycode) Then Exit Sub
  833. End Sub
  834.  
  835. 'Nudge Script test thing
  836. 'Same idea as JP's old VP9 nudge script
  837. redim nfNudgeCache(99)
  838. Sub nfNudge(dir,Strength)   'dir = Left right coef. 0 = up. No vector calculation
  839.     dim counter,x : counter = 0
  840.     redim nfNudgeCache(99)
  841.     dim debugstr
  842.     for each x in getballs
  843.         if dir = 0 then
  844.             x.Vely = x.Vely + strength*-1
  845.             debugstr = "vely+"& round(x.Vely + strength*-1 , 2)
  846.         else
  847.             x.Velx = x.VelX + strength*dir
  848.             debugstr = "velx+"& round(x.Vely + strength*-1 , 2)
  849.         end if
  850.         'for shift back
  851.         set nfNudgeCache(counter) = x
  852.         'debug.print "ballid:" & x.id & " to " & "nfnudgecache(" & counter & ")"
  853.         counter = counter + 1
  854.     next
  855.     if counter = 0 then counter = 1
  856.     redim Preserve nfNudgeCache(Counter-1)
  857.     vpmtimer.addtimer 250, "nfNudgeBack" & " " & dir & ", "& strength/2 & "'"
  858. End Sub
  859.  
  860. Sub nfNudgeBack(dir,Strength)
  861.     if ubound(nfnudgecache) = 0 then exit sub
  862.     on error resume Next
  863.     dim x : for each x in nfNudgeCache
  864.         if Not IsEmpty(x) then
  865.             if dir = 0 then
  866.                 x.Vely = x.Vely + strength*-1*-1
  867.             else
  868.                 'if isEmpty(x.VelX) then debug.print "Xnull, exit sub. typename: "  & typename(x) & " " & "isempty x:" & IsEmpty(x): exit sub
  869.                 x.Velx = x.VelX + strength*dir*-1
  870.             end if
  871.         end if
  872.     next
  873. End Sub
  874.  
  875. Sub Table1_KeyUp(ByVal keycode)
  876.     If Keycode = StartGameKey then Controller.Switch(13) = 0
  877.     if KeyCode = KeyRules then if DeskTopMode then Setlamp cCardDT, 0 : else Setlamp cCardFS, 0 end if
  878.     If keycode = PlungerKey Then
  879.         Plunger.Fire
  880.         if BallInPlunger then
  881.             PlaySound SoundFX("Plunger3",0),0, LVL(0.3),0.06,0.05
  882.         Else
  883.             PlaySound SoundFX("plunger",0),0, LVL(0.3),0.06,0.05
  884.         end if
  885.     End If
  886.     If Keycode = RightFlipperKey then if DebugFlippers then SolRFlipper 0 : Exit Sub
  887.     If Keycode = LeftFlipperKey then if DebugFlippers then SolLFlipper 0 : Exit Sub
  888.     if keycode = LeftMagnaSave then catchinput(0) = False
  889.     if Keycode = RightMagnaSave then catchinput(1) = False
  890.     If vpmKeyUp(keycode) Then Exit Sub
  891. End Sub
  892.  
  893.  
  894. RandomColors
  895. Sub RandomColors()
  896.     dim a, x, x2
  897.     a = Array("boogin_Green", "Boogin_Red", "Boogin_Purple", "Boogin_Blue", "Boogin_Yellow")
  898.     x = cInt(rndnum(0, uBound(a))   )
  899.     x2 = x
  900.  
  901.     x = x + rndnum(1, uBound(a) )
  902.     if x > uBound(a) then x = x - uBound(a)
  903.     if x = x2 then  'try again if the boogies are the same
  904.         RandomColors 'bad idea
  905.         Exit Sub
  906.     End If
  907.  
  908.     Boogie1.Image = a(x2)
  909.     BoogieArms1.Image = a(x2)
  910.  
  911.     Boogie2.Image = a(x)
  912.     BoogieArms2.Image = a(x)
  913.  
  914. '   tb.text = boogie1.image & vbnewline & boogie2.image
  915. End Sub
  916.  
  917.  
  918. gip.x = 482
  919. gip.y = 775
  920.  
  921.  
  922. Bumperw.x = 976.55
  923. Bumperw.y = 525
  924. Bumperw.Height = 155
  925.  
  926. L84_0.x = 186.4640141
  927. L84_0.y = 60.6526099
  928. L84_1.x = 245.5639003
  929. L84_1.y = 34.6744886
  930. L84_2.x = 306.8235425
  931. L84_2.y = 25.5868251
  932. L85r.x = 384.2346585
  933. L85r.y = 27.7668062
  934. L86r.x = 478.6800507
  935. L86r.y = 34.9814888
  936. L35r.x = 22.75  'prototype kickback only
  937. L35r.y = 1584.5
  938. L45r.x = 864
  939. L45r.y = 1533.3037335
  940.  
  941. FlSkull2_5.bulbhaloheight =34.7'28
  942. FlSkull2_6.bulbhaloheight =35.1'28
  943. FlSkull2_5.x = 807'808.1973
  944. FlSkull2_6.x = 836  '838.3223
  945.  
  946.  
  947. FlSkull2_3.bulbhaloheight =33'29
  948. FlSkull2_4.bulbhaloheight =29'29
  949. FlSkull2_3.x = 837'838.39
  950. FlSkull2_4.x = 864  '860.765
  951.  
  952. FlSkull2_1.bulbhaloheight =32'28
  953. FlSkull2_2.bulbhaloheight =33   '30
  954. FlSkull2_1.x = 780'782.3
  955. FlSkull2_2.x = 804  '806.785
  956.  
  957.  
  958. FlSkull5_1.bulbhaloheight = 31.5'28
  959. FlSkull5_2.bulbhaloheight = 31.5'28
  960. FlSkull5_1.x =  805.5'807.7266
  961. 'FlSkull5_2.x = '834.085
  962.  
  963.  
  964. FlSkull4_1.bulbhaloheight = 29'28
  965. FlSkull4_2.bulbhaloheight = 29'28
  966. FlSkull4_1.x =  743'743.7
  967. FlSkull4_2.x =  772.2'774.3
  968. FlSkull4_1.y =  81'86.609
  969.  
  970.  
  971.  
  972.  
  973. f19f.x = 854'853.3457
  974. f19f.y = 697'696.2
  975. f18f.x = 703'695
  976. f18f.y = 555'550.6
  977.  
  978.  
  979. f17.x = 858.2477164
  980. f17.y = 355.0953586
  981. f18.x = 712.9653396
  982. f18.y = 502.0359103
  983. f19.x = 858.3208126
  984. f19.y = 648.2506583
  985.  
  986. f17f.x = 848'850.5333
  987. f17f.y = 420'424.1581
  988.  
  989. f23.x = 215'195
  990. f23.y = 600'527
  991.  
  992.  
  993. f26.falloffpower = 3.5'2.5
  994.  
  995. f21f.opacity = 2000 '1550
  996. f25f.opacity = 2000 '1550
  997.  
  998.  
  999. f22side.x = 0.1 'sidewalls
  1000. f24side.x = 0.1
  1001. f35side.x = 0.1
  1002.  
  1003. f27side.x = 976
  1004. f28side.x = 976
  1005. f36side.x = 976
  1006.  
  1007. f22side.y      = 164.7058   'sidewalls L
  1008. f22side.height = 235.394
  1009. f24side.y      = 905.1276
  1010. f24side.height = 155.195
  1011. f35side.y      = 1438.183
  1012. f35side.height = 155.651
  1013.  
  1014. f27side.y      = 235.294
  1015. f27side.height = 188.2352
  1016. f28side.y      = 815.1855836
  1017. f28side.height = 152.135
  1018. f36side.y      = 1461.3333459
  1019. f36side.height = 155.647
  1020.  
  1021. 'ambient flashers
  1022. f27a.x = 74.1650189 'left
  1023. f27a.y = 153.5833371
  1024. f27a.height = 290.9047391
  1025.  
  1026. f22a.x = 635.9062643    'right
  1027. f22a.y = 153.5833371
  1028. f22a.height = 290.9047391 +1
  1029.  
  1030. f24a.x = 37.9471029
  1031. f24a.y = 893.7202263
  1032. f24a.height = 232.9866935
  1033.  
  1034. f35a.x = 32.7692645
  1035. f35a.y = 1421.3283143
  1036. f35a.height = 193.043327
  1037.  
  1038. f28a.x = 916.99662
  1039. f28a.y = 843.8636384
  1040. f28a.height = 236.6003666
  1041.  
  1042. f36a.x = 838.7909472
  1043. f36a.y = 1442.2939137
  1044. f36a.height = 193.043327
  1045.  
  1046.  
  1047. Dim bsTrough, bsCoffin, bsLeftKick, bsSpider, Frog1Vel, Frog2Vel, Frog3Vel, WheelMech, IMAutoPlunger
  1048. Dim UseMech, CrateOpen, BIP, FSSpiderenabled
  1049. BIP = 0
  1050.  
  1051.  
  1052. ' Init table
  1053. Sub table1_Init()
  1054.     vpmInit Me
  1055.     Dim X
  1056.     InitWheel
  1057.     With Controller
  1058.         .GameName = cGameName
  1059.         If Err Then MsgBox "Can't start Game: " & cGameName & vbNewLine & Err.Description:Exit Sub
  1060.         .Games(cGameName).Settings.Value("rol") = 0 'rotated to the left
  1061.         .HandleMechanics = UseMech
  1062.         .ShowDMDOnly = 1
  1063.         .ShowFrame = 0
  1064.         .ShowTitle = 0
  1065.         .Hidden = 0
  1066.         '.SetDisplayPosition 0, 0, GetPlayerHWnd   'uncomment this line If you don't see the vpm window
  1067.         On Error Resume Next
  1068.         .Run GetPlayerHWnd
  1069.         If Err Then MsgBox Err.Description
  1070. '       On Error Goto 0
  1071.     End With
  1072.     Controller.Switch(22) = 1 ' coin door closed...
  1073.     Controller.Switch(24) = 1 ' and keep it closed
  1074.     Controller.Switch(48) = 1 ' turn on the coffin diode
  1075.  
  1076.     vpmNudge.TiltSwitch = 14
  1077.     vpmNudge.Sensitivity = 1'0.25
  1078.    vpmNudge.TiltObj = Array(bumper1, bumper2, bumper3, LeftSlingshot, RightSlingshot)
  1079.  
  1080.     ' Main Ball Trough
  1081.     set bsTrough = new cvpmBallStack
  1082.     With bsTrough
  1083.         .InitSw 0, 32, 33, 34, 35, 0, 0, 0
  1084.         .InitKick BallRelease, 90, 6
  1085. '       .InitExitSnd SoundFX("BallReleaseRS",DOFcontactors), SoundFX("FlipperUpLeft",DOFContactors)
  1086.         .Balls = 4
  1087.     End With
  1088.  
  1089.     ' Coffin
  1090.     set bsCoffin = new cvpmBallStack
  1091.     With bsCoffin
  1092.         .InitSw 0, 41, 42, 43, 0, 0, 0, 0
  1093.         .InitKick CoffinKicker, 170, 5
  1094.         '.InitExitSnd SoundFX("Kicker_Release",DOFContactors), SoundFX("FlipperUpLeft",DOFContactors)
  1095.     End With
  1096.  
  1097.     ' Spider
  1098.     Set bsSpider = New cvpmBallStack
  1099.     bsSpider.InitSw 0, 36, 0, 0, 0, 0, 0, 0
  1100.     bsSpider.InitKick sw36, 202, 40     '202, 35
  1101.     bsSpider.KickZ = 95
  1102. '   bsSpider.KickBalls = 2
  1103.     'bsSpider.InitExitSnd SoundFX("Kicker_Release",DOFContactors), SoundFX("FlipperUpLeft",DOFContactors)
  1104.  
  1105.     ' Left Kickout
  1106.     Set bsLeftKick = New cvpmBallStack
  1107. '   bsLeftKick.InitSw 0, 37, 0, 0, 0, 0, 0, 0
  1108. '   bsLeftKick.InitKick sw37, 91, 60    '84 66
  1109. '   bsLeftKick.KickZ = 80   '80
  1110. '   bsLeftKick.KickForceVar = 0.1   '5
  1111. '   bsLeftKick.KickAngleVar = 0.1   '0
  1112.     bsLeftKick.InitSw 0, 37, 0, 0, 0, 0, 0, 0
  1113.     bsLeftKick.InitKick sw37, 91, 63    '91,60
  1114.     bsLeftKick.KickZ = 80   '80
  1115.     bsLeftKick.KickForceVar = 8 '5
  1116.     bsLeftKick.KickAngleVar = 0.1   '0
  1117.  
  1118.  
  1119.     ' Impulse Plunger used as the autoplunger
  1120.     Set IMAutoPlunger = New cvpmImpulseP
  1121.     With IMAutoPlunger
  1122.         .InitImpulseP Sw18, 38, 0.4
  1123.         .Random 0.6
  1124. '       .InitExitSnd SoundFX("plunger",DOFContactors), SoundFX("FlipperUpLeft",DOFContactors)
  1125.         .CreateEvents "IMAutoPlunger"
  1126.         .Switch 18
  1127.     End With
  1128.  
  1129.     ' Main Timer init
  1130.     PinMAMETimer.Interval = PinMAMEInterval
  1131.     PinMAMETimer.Enabled = 1
  1132.  
  1133.     Frog1Vel = 0:Frog2Vel = 0:Frog3Vel = 0
  1134.    
  1135.     sw37_dropwall.isdropped = 1
  1136.  
  1137.     'Start gi on
  1138.     UpdateGIon 0, 1:UpdateGIon 1, 1: UpdateGIon 2, 1
  1139.     UpdateGI 0, 7:UpdateGI 1, 7:UpdateGI 2, 7
  1140.    
  1141.     gitype giselect
  1142.     'Wheel Placer
  1143.  
  1144.     'idk why this doesn't work whatever
  1145.     if DesktopMode = True then  'should be true just debugging
  1146.         flspiderback.visible = 0
  1147.         FlSpider.RotX = -Table1.Inclination 'broken in VP10.3
  1148. '       FlSpider.RotX = 0
  1149. '       FlSpiderback.RotX = FlSpider.RotX
  1150.         WheelPlacer l82, -90.1
  1151.         WheelPlacer l83, -67.5
  1152.         WheelPlacer l64, -45
  1153.         WheelPlacer l65, -22.5
  1154.         WheelPlacer l66, 0
  1155.         WheelPlacer l67, 22.5
  1156.         WheelPlacer l68, 45
  1157.         WheelPlacer l71, 67.5
  1158.         WheelPlacer l72, 90
  1159.         WheelPlacer l73, 112.5
  1160.         WheelPlacer l74, 135
  1161.         WheelPlacer l75, 157.5
  1162.         WheelPlacer l76, 179.9
  1163.         WheelPlacer l77, -157.5
  1164.         WheelPlacer l78, -135
  1165.         WheelPlacer l81, -112.5
  1166.         FadingLevel(cSpiderFade) = 9
  1167.         FSSpiderenabled = False
  1168.     Elseif Desktopmode = False then
  1169.         if SingleScreenFS = 1 Then FS_SingleScreen_Spider_Init
  1170.     End If
  1171.  
  1172.  
  1173. End Sub
  1174.  
  1175. 'tdebugbox2.timerenabled = 1
  1176. 'sub tdebugbox2_timer()
  1177. '   Tdebugbox2.text = "DT=" & DesktopMode & " moved?" & l78.height & " " & l78.opacity & "spiderboot" & spiderspinning
  1178. 'end sub
  1179.  
  1180. Dim WheelAwards
  1181. WheelAwards = Array(l82, l83, l64, l65, l66, l67, l68, l71, l72, l73, l74, l75, l76, l77, l78, l81)
  1182.  
  1183.  
  1184. Sub WheelPlacer(object, angle)
  1185.     Dim a, b, rad
  1186.     rad = (angle/180)*Pi                                                'Converts radians into degrees
  1187.     a = FlSpider.SizeX/2+75                                             'Set the width of the ellipse/circle
  1188.     b = FlSpider.SizeX/4+75                                             'Set the height of the ellipse
  1189.     object.RotX = FlSpider.RotX                                         'First, rotate to face the player
  1190. '   object.RotX = -Table1.Inclination                                   'First, rotate to face the player   'old
  1191.     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.)
  1192.     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
  1193.     object.Height = FlSpider.Height + a*-dSin(angle)                    'The Z coord is based off just the angle
  1194. End Sub
  1195.  
  1196. Sub FS_SingleScreen_Spider_Init 'spider rotation is enabled by spiderFS and setlamp 398, 1
  1197.     FSSpiderenabled = True
  1198.     FlashLevel(cSpiderFade) = 0
  1199.     FlashLevel(cSpiderFade) = 4
  1200.     'setlamp 398, 0
  1201.  
  1202.     FLspiderback.visible = 1
  1203.     FLspider.visible = 1
  1204.     dim x : for each x in Awards : x.opacity = 0 : next
  1205.     l82.x = 537.6
  1206.     l82.y = 1292.665
  1207.     l83.x = 624.8
  1208.     l83.y = 1316.84
  1209.     l64.x = 696.2
  1210.     l64.y = 1361.3
  1211.     l65.x = 744.27
  1212.     l65.y = 1418.82
  1213.     l66.x = 761.4
  1214.     l66.y = 1484.78
  1215.     l67.x = 741.9
  1216.     l67.y = 1550.73
  1217.     l68.x = 707.55
  1218.     l68.y = 1630.95
  1219.  
  1220.     l71.x = 639.89
  1221.     l71.y = 1676.413
  1222.     l72.x = 537.2
  1223.     l72.y = 1702.965    'bottom
  1224.     l73.x = 441.6
  1225.     l73.y = 1677.2
  1226.     l74.x = 374.34
  1227.     l74.y = 1623.15
  1228.     l75.x = 323.79
  1229.     l75.y = 1553.1  '
  1230.     l76.x = 309.82
  1231.     l76.y = 1485.08
  1232.     l77.x = 326.95
  1233.     l77.y = 1418.03
  1234.     l78.x = 373.3545
  1235.     l78.y = 1364.481
  1236.     l81.x = 447.93
  1237.     l81.y = 1318.427
  1238.     dim xx
  1239.     For each xx in WheelAwards
  1240.         xx.ModulateVsAdd = 0.1
  1241.         xx.Height = 165
  1242.         xx.RotX = 0
  1243.         xx.RotZ = 0
  1244.         xx.RotY = 0
  1245.         xx.x = xx.x - 90
  1246.         xx.y = xx.y - 10
  1247.     Next
  1248. ''' FLSpiderback.RotX = 0
  1249. ''' FLSpiderback.RotZ = 0
  1250. ''' FLSpiderback.RotY = 0
  1251. ''' FLSpiderback.x = 438.7415
  1252. ''' FLSpiderBack.y = 1479.515
  1253. ''' FLSpiderBack.x = FLSpiderBack.x - 95    'fine tune position
  1254. ''  FLSpiderBack.y = FLSpiderBack.y + 25    'fine tune position
  1255. '   FLSpiderBack.Height = 164
  1256. '   FLSpiderBack.ImageA = "black_back"
  1257. '   FLSpiderBack.ImageB = "flare_clear"
  1258. '   FLSpiderBack.Filter = "Overlay"     'Filter Overlay 30%
  1259. '   FLSpiderBack.Amount = 30
  1260. '   FLSpiderBack.Opacity = 92       '   92% opacity
  1261.  
  1262.     FlSpider.x = 535.8914
  1263.     FlSpider.y = 1503.128
  1264.     FlSpider.Height = 166
  1265.     FlSpider.RotX = 0
  1266.     FlSpider.RotZ = 0
  1267.     FlSpider.RotY = 0
  1268.     FLSpider.x = FLSpider.x - 95    'fine tune position
  1269. end sub
  1270.  
  1271. Sub INITWheel
  1272.     Set WheelMech = New cvpmMech
  1273.     With WheelMech
  1274.         .MType = vpmMechStepSol + vpmMechCircle + vpmMechLinear + vpmMechFast
  1275.         .Sol1 = 39
  1276.         .Sol2 = 40
  1277.         .Length = 200
  1278.         .Steps = 48
  1279.         .CallBack = GetRef("UpdateWheel")
  1280.         .AddSw 12, 0, 0
  1281.         .Start
  1282.     End With
  1283. End Sub
  1284.  
  1285. Dim lednr, np, FSspider
  1286.  
  1287.  
  1288. Sub UpdateWheel(aNewPos, aSpeed, aLastPos)
  1289.     DOF 101, DOFPulse
  1290.     np=aNewPos+12:If np>47 Then np=np-48
  1291.     lednr=int(np/4.8)
  1292.     if lednr>4 then lednr=lednr-5
  1293.     DOF 201+lednr, DOFPulse
  1294.  
  1295.     if FSSpiderenabled then
  1296.         if bip = 1 and bsSpider.balls > 0 Then Setlamp cSpiderFade, 1
  1297.         'Else
  1298.         '   SetLamp 398, 0
  1299.         'end if
  1300.     end if
  1301. '   dim temp : if IsObject(bsSpider) then temp = bsspider.balls
  1302. '   tb.text = aNewPos & " " & aspeed & " " & aLastPos & vbnewline & _
  1303. '           "bip " & bip & " bsSpider.Balls:" & temp
  1304. End Sub
  1305.  
  1306. Sub SpiderFS(nr)
  1307.     'if SingleScreenFS = 0 then Exit Sub
  1308.     'if SingleScreenFS = 0 or Desktopmode then Exit Sub
  1309.     dim x
  1310.     Select Case FadingLevel(nr)
  1311.         case 4
  1312.             FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
  1313.             If FlashLevel(nr) < FlashMin(nr) Then
  1314.                 FlashLevel(nr) = FlashMin(nr)
  1315.                 FadingLevel(nr) = 0 'completely off
  1316.             End If
  1317.             for each x in WheelAwards
  1318.                 x.opacity = FlashLevel(nr) * 100
  1319.             next
  1320.             FLspider.intensityscale = FlashLevel(nr)
  1321.             Flspiderback.intensityscale = FlashLevel(nr)
  1322.         case 5 
  1323.             FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
  1324.             If FlashLevel(nr) > FlashMax(nr) Then
  1325.                 FlashLevel(nr) = FlashMax(nr)
  1326.                 FadingLevel(nr) = 1 'completely on
  1327.             End if 
  1328.             for each x in WheelAwards
  1329.                 x.opacity = FlashLevel(nr) * 100
  1330.             next
  1331.             FLspider.intensityscale = FlashLevel(nr)
  1332.             Flspiderback.intensityscale = FlashLevel(nr)
  1333.     End Select
  1334. End Sub
  1335.  
  1336. Sub tbspider_Timer()
  1337.  
  1338. End Sub
  1339.  
  1340. '
  1341. 'sub NspiderFS(nr)  'handles spider opacity fading in Single-Screen FS
  1342. '   dim xx
  1343. '   if SingleScreenFS = 0 or desktopmode = True Then exit sub
  1344. '   Select Case FadingLevel(nr)
  1345. '       Case 1
  1346. '           if bip = 1 and bsSpider.balls Then
  1347. '               exit Sub
  1348. '           Else
  1349. '               setlamp 398, 0  'debug
  1350. '           end If
  1351. '       case 4
  1352. '            FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
  1353. '            If FlashLevel(nr) < FlashMin(nr) Then
  1354. '                FlashLevel(nr) = FlashMin(nr)
  1355. '               FadingLevel(nr) = 0 'completely off
  1356. '           End If
  1357. '       case 5
  1358. '           FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
  1359. '           If FlashLevel(nr) > FlashMax(nr) Then
  1360. '               FlashLevel(nr) = FlashMax(nr)
  1361. '               FadingLevel(nr) = 1 'completely on
  1362. '           End if
  1363. '   end select
  1364. '   for each xx in WheelAwards
  1365. '   xx.opacity = FlashLevel(nr) * 100
  1366. '   next
  1367. ''  FLspider.opacity = FlashLevel(nr) * 100
  1368. ''  Flspiderback.opacity = FlashLevel(nr) * 100
  1369. '   FLspider.intensityscale = FlashLevel(nr)
  1370. '   Flspiderback.intensityscale = FlashLevel(nr)
  1371. 'end sub
  1372. 'flspiderback.intensityscale = 0
  1373.  
  1374. 'Sub UpdateWheel(aNewPos, aSpeed, aLastPos)
  1375. '    DOF 101, DOFPulse
  1376. '    np=aNewPos+12:If np>47 Then np=np-48
  1377. '    lednr=int(np/4.8)
  1378. '    if lednr>4 then lednr=lednr-5
  1379. '    DOF 201+lednr, DOFPulse
  1380. 'End Sub
  1381.  
  1382.  
  1383. '*******************
  1384. '* Solendoid Callbacks
  1385. '*******************
  1386. Set GICallback = GetRef("UpdateGIon")
  1387. Set GICallback2 = GetRef("UpdateGI")
  1388.  
  1389. SolCallback(sLRFlipper) = "SolRFlipper"
  1390. SolCallback(sLLFlipper) = "SolLFlipper"
  1391.  
  1392. SolCallback(1) = "AutoPlunge"
  1393. 'SolCallback(2) = "SolLoopGate" 'kickback in prototype, this sol moved to 25
  1394. SolCallback(2) = "Sol2"
  1395. Sub Sol2(enabled)   'Kickback / SolLoopGate
  1396.     if Proto then
  1397.         if enabled then
  1398.             kickback.Fire
  1399.             PlaySound SoundFX("Ball Launch",DOFContactors), 0, LVL(0.3),0.06,0.05
  1400.         Else
  1401.             kickback.Pullback
  1402.         end If
  1403.     Else
  1404.         SolLoopGate enabled
  1405.     end If
  1406. End Sub
  1407. kickback.pullback
  1408.  
  1409. SolCallback(3) = "SolSpiderPopper"
  1410. SolCallback(4) = "SolCoffinPopper"
  1411. SolCallback(5) = "SolCoffinDoor"
  1412. SolCallback(6) = "SolCrateKickout"
  1413. SolCallback(7) = "vpmSolSound SoundFX(""Knocker"",DOFKnocker),"
  1414. 'SolCallback(8) = "CratePostPower"  'crate 'flip' coil. not necessary? -nf
  1415. SolCallback(9) = "SolBallRelease"
  1416. SolCallback(10) = "SolLeftSling"
  1417. SolCallback(11) = "SolRightSling"
  1418. SolCallBack(12) = "SolBumper2"
  1419. SolCallBack(13) = "SolBumper1"
  1420. SolCallBack(14) = "SolBumper3"
  1421. 'SolCallBack(15) = "SolUpperSling"
  1422. SolCallback(16) = "CratePostHold"
  1423.  
  1424. SolCallback(33) = "LDiverterPower"
  1425. SolCallback(34) = "LDiverterHold"
  1426.  
  1427.  
  1428. 'Flashers
  1429.  
  1430. SolModCallback(17) = "SetModLampM 117," 'Top Bumper Flash
  1431. SolModCallback(18) = "SetModLampM 118," 'Mid Bumper Flash
  1432. SolModCallback(19) = "SetModLampM 119," 'Bottom Bumper Flash
  1433. 'SolModCallback(20) = "SetModLamp 120," 'Bolts Flash
  1434. SolModCallback(20) = "Sol20" 'Bolts Flasher / Aux Board Enabled
  1435. Sub Sol20(value)
  1436.     if Proto then Exit Sub
  1437.     SetModLamp 120, value
  1438. End Sub
  1439.  
  1440.  
  1441. 'SolModCallback(21) = "SetModLamp 121,"                 'Bone Pile Flasher 1    'added
  1442. SolModCallback(21) = "Sol21" 'Bone Pile Flasher Blue / Backbox Spider (is this the motor? TODO)
  1443. Sub Sol21(value)
  1444.     if Proto then Exit Sub
  1445.     SetModLamp 121, value
  1446. End Sub
  1447.  
  1448.  
  1449. SolModCallback(22) = "SetModLampM 122,"     'Upper Right Flasher
  1450. SolModCallback(23) = "SetModLamp 123,"      'Skull Flasher
  1451. SolModCallback(24) = "SetModLampM 124,"     'Mid Left Flasher
  1452. 'SolModCallback(25) = "SetModLamp 125,"                 'Bone Pile Flasher 2
  1453. SolModCallback(25) = "Sol25"    'Bone Pile Flsaher #2 (White) \ SolLoopGate
  1454. Sub Sol25(value)
  1455.     if Proto then
  1456.         SolLoopGate cBool(value)
  1457.     Else
  1458.         SetModLamp 125, value
  1459.     end If
  1460. End Sub
  1461.  
  1462.  
  1463. SolModCallback(26) = "SetModLamp 126,"  'TVFlasher
  1464. SolModCallback(27) = "SetModLampM 127,"     'Up Left Flasher
  1465. SolModCallback(28) = "SetModLampM 128," 'Mid Right Flasher
  1466. SolModCallback(35) = "SetModLampM 135," 'Bottom Left Flasher
  1467. SolModCallback(36) = "SetModLampM 136," 'Bottom Right Flasher
  1468.  
  1469.  
  1470.  
  1471. '================VP10 Fading Lamps Script
  1472.  
  1473. Dim LampState(440), FadingLevel(440)
  1474. Dim FlashSpeedUp(440), FlashSpeedDown(440), FlashMinw(440), FlashMin(440), FlashMax(440), FlashLevel(440), FlashSpeedUp2(440), FlashSpeedDown2(440), fBlinkPattern(440)
  1475. dim tIntervalNext(440) '??
  1476. dim SolModValue(440)
  1477. dim LightFallOff(440, 4)    '2d array to hold alt falloff values in different columns
  1478. dim FlashersOpacity(440)
  1479. dim insertfading(440, 2):   'columns : 0 = name 1 = fadeup 2 = fadedown
  1480. 'dim FlashersFalloff(340)   '??? (could use multiply? or some other kind of mixing?...)
  1481. dim GIscale(4'4 gi strings. only 0 used for now
  1482. 'Dim FlashersOpacity(200)
  1483.  
  1484. Sub SetModLamp(nr, value)
  1485.     If value <> SolModValue(nr) Then
  1486.         SolModValue(nr) = value
  1487.         if value > 0 then LampState(nr) = 1 else LampState(nr) = 0
  1488.         FadingLevel(nr) = LampState(nr) + 4
  1489.     End If
  1490. End Sub
  1491.  
  1492. Sub SetModLampM(nr, value)  'setlamp NR, but also NR + 50
  1493.    If value <> SolModValue(nr) Then
  1494.         SolModValue(nr) = value
  1495.         if value > 0 then LampState(nr) = 1 else LampState(nr) = 0
  1496.         FadingLevel(nr) = LampState(nr) + 4
  1497.     End If
  1498.     If value <> SolModValue(nr+50) Then
  1499.         SolModValue(nr+50) = value
  1500.         if value > 0 then LampState(nr+50) = 1 else LampState(nr+50) = 0
  1501.         FadingLevel(nr+50) = LampState(nr+50) + 4
  1502.     End If
  1503. End Sub
  1504.  
  1505. Sub SetFlashSpeedUp(lwr,uppr,value)     'subs for adjusting flasher speed in the debugger
  1506.     dim x
  1507.     for x = lwr to uppr 'primarly fading speeds for flashers    'intensityscale per 10MS
  1508.         FlashSpeedUp(x) = value
  1509. '       FlashSpeedDown(x) = 1
  1510.     next
  1511. End Sub
  1512.  
  1513. Sub SetFlashSpeedDown(lwr,uppr,value)
  1514.     dim x
  1515.     for x = lwr to uppr 'primarly fading speeds for flashers    'intensityscale per 10MS
  1516. '       FlashSpeedUp(x) = 1
  1517.         FlashSpeedDown(x) = value
  1518.     next
  1519. End Sub
  1520. InitLamps
  1521. Sub InitLamps()
  1522.     Dim x
  1523.     For x = 0 to 440
  1524.         LampState(x) = 0        ' current light state, independent of the fading level. 0 is off and 1 is on
  1525.         FadingLevel(x) = 4      ' used to track the fading state
  1526.         FlashSpeedUp(x) = 0.1     ' faster speed when turning on the flasher
  1527.         FlashSpeedDown(x) = 0.1 '0.3 ' slower speed when turning off the flasher
  1528.  
  1529.         FlashMin(x) = 0         ' the minimum value when off, usually 0
  1530.         FlashMax(x) = 1         ' the maximum value when on, usually 1
  1531.  
  1532.         FlashLevel(x) = 0.001       ' the intensity of the flashers, usually from 0 to 1
  1533. '       fBlinkPattern(x) = "01"     'this was cool but not used anymore
  1534.    Next
  1535.  
  1536.     for x = 0 to 440
  1537.         On Error Resume Next
  1538.         SolModValue(x) = 0
  1539.         FlashersOpacity(x) = 0
  1540. '       FlashersFalloff(x) = 0  '??? (could use multiply? or some other kind of mixing?...)
  1541.         LightFallOff(x, 0) = 0
  1542.         LightFallOff(x, 1) = 0
  1543.         LightFallOff(x, 2) = 0
  1544.         LightFallOff(x, 3) = 0
  1545.         LightFallOff(x, 4) = 0
  1546.         Giscale(x) = 1.61   '1.61x when gi is fully off
  1547.     next
  1548.  
  1549.     for x = 340 to 398  'SpiderFS
  1550.         FlashSpeedUp(x) = 0.1
  1551.         FlashSpeedUp(x) = 0.1
  1552.         FlashLevel(x) = 0
  1553.     next
  1554.  
  1555.     for x = 11 to 90 'inserts
  1556.         FlashSpeedUp(x) = 0.015*1.2
  1557.         FlashSpeedDown(x) = 0.009*1.2
  1558.     Next
  1559. '   FlashSpeedUp(56) = 0.08     'lock
  1560. '   FlashSpeedDown(56) = 0.02
  1561.     for x = 111 to 186  'primary fading speeds for flashers 'intensityscale per 10MS
  1562.         FlashSpeedUp(x) = 1.1*0.9
  1563.         FlashSpeedDown(x) = 0.9*0.9
  1564.     next
  1565.     FlashSpeedUp(120) = 1.1*0.6 'insert - bolts
  1566.     FlashSpeedDown(120) = 0.9*0.6
  1567.     FlashSpeedUp(126) = 1.1*0.6 'insert - TV
  1568.     FlashSpeedDown(126) = 0.9*0.6
  1569.     FlashSpeedUp(123) = 1.1*0.7 'beast
  1570.     FlashSpeedDown(123) = 0.9*0.7
  1571.  
  1572. '   for x = 117 to 119 : FlashSpeedUp(x) = 1 : FlashSpeedDown(x) = 0.81 : next  'bumpers
  1573. '   FlashSpeedUp(167) = 1.2 'bumpers
  1574. '   FlashSpeedDown(167) = 0.81
  1575. '   FlashSpeedUp(168) = 1.2
  1576. '   FlashSpeedDown(168) = 0.81
  1577. '   FlashSpeedUp(169) = 1.2
  1578. '   FlashSpeedDown(169) = 0.81  'bumpers
  1579.  
  1580.     FlashSpeedUp(172) = 1.3 '6 flashers (Bulbs)
  1581.     FlashSpeedDown(172) = 0.7
  1582.     FlashSpeedUp(174) = 1.3
  1583.     FlashSpeedDown(174) = 0.7
  1584.     FlashSpeedUp(177) = 1.3
  1585.     FlashSpeedDown(177) = 0.7
  1586.     FlashSpeedUp(178) = 1.3
  1587.     FlashSpeedDown(178) = 0.7
  1588.  
  1589.     FlashSpeedUp(185) = 1.3
  1590.     FlashSpeedDown(185) = 0.7
  1591.     FlashSpeedUp(186) = 1.3
  1592.     FlashSpeedDown(186) = 0.7
  1593.  
  1594.  
  1595.     for x = 204 to 210  'Animations
  1596.         FlashSpeedUp(x) = 0.01
  1597.         FlashSpeedDown(x) = 0.008
  1598.     next
  1599.     for x = 304 to 307  'More Animations (boogie rotations)
  1600.         FlashLevel(x) = 0
  1601.         FlashSpeedUp(x) = 0.03
  1602.         FlashSpeedDown(x) = 0.01
  1603.     next
  1604.     FlashMin(304) = -1  '0
  1605.     FlashMin(305) = -1
  1606.     FlashMax(304) = 16  '17
  1607.     FlashMax(305) = 16  'boogiemen RotX min/max rotations
  1608.     FlashSpeedUp(304) = FlashSpeedUp(304) * FlashMax(304)
  1609.     FlashSpeedUp(305) = FlashSpeedUp(305) * FlashMax(305)
  1610.     FlashSpeedDown(304) = FlashSpeedDown(304) * FlashMax(304)
  1611.     FlashSpeedDown(305) = FlashSpeedDown(305) * FlashMax(305)
  1612.  
  1613. '   BoogiemanAnim(nr, Object, Frames)
  1614.     BoogieDuration = 550    '450    'special fadingspeeds for boogiemen animation,  total duration
  1615.  
  1616.  
  1617.  
  1618.     for x = 308 to 310  'Sling Rubber animations
  1619.         FlashSpeedUp(x) = 0.2'0.0267
  1620.         FlashSpeedDown(x) = 0.009'0.008
  1621.     next
  1622.  
  1623.     for x = 200 to 203      'GI relay on / off
  1624.         FlashSpeedUp(x) = 0.01
  1625.         FlashSpeedDown(x) = 0.008
  1626.     Next
  1627.     for x = 300 to 303  'GI 8 step modulation
  1628.         FlashSpeedUp(x) = 0.01
  1629.         FlashSpeedDown(x) = 0.008
  1630.     Next
  1631.     flashspeedup(cCardDT) = 0.005   : flashspeedup(cCardFS) = flashspeedup(cCardDT) 'card speeds
  1632.     flashspeedDown(cCardDT) = 0.006 : flashspeedDown(cCardFS) = flashspeedDown(cCardDT)
  1633.  
  1634.  
  1635.  
  1636.     for x = 0 to (aFlashers.Count - 1)
  1637.         On Error Resume Next
  1638.         If aFlashers(x).Opacity > 0 then aFlashers(x).uservalue = aFlashers(x).Opacity
  1639.         If aFlashers(x).Intensity > 0 then aFlashers(x).UserValue = aFlashers(x).Intensity
  1640. '       aFlashers(x).state = 1  'nf todo
  1641.     Next
  1642.  
  1643.     for x = 0 to (aFlashers.Count - 1'Put Flasher Opacity in an Array for FadeGI scaling brightness up when GI is off
  1644.         On Error Resume Next
  1645.         FlashersOpacity(x) = aFlashers(x).Uservalue
  1646.     Next
  1647.  
  1648.     for x = 0 to (Lamps.Count - 1)
  1649.         On Error Resume Next
  1650.         If Lamps(x).Opacity > 0 then Lamps(x).uservalue = Lamps(x).Opacity
  1651.         If Lamps(x).Intensity > 0 then Lamps(x).UserValue = Lamps(x).Intensity
  1652.     Next
  1653.  
  1654.     'Put light-based insert intensity into array along with fading speed
  1655.     for x = 0 to (Lamps.Count - 1)
  1656.         On Error Resume Next
  1657.         InsertFading(x, 0) = Lamps(x).UserValue
  1658.         insertfading(x, 1) = Lamps(x).FadeSpeedUp
  1659.         insertfading(x, 2) = Lamps(x).FadeSpeedDown
  1660.     Next
  1661.  
  1662. '   dim s, i    'old array where I apparently thought it was very important to order the names correctly
  1663. '   i = 0
  1664. '   for each x in Lamps 'setup array
  1665. '       On Error Resume Next
  1666. '       s = mid(x.name, 2, 2)           'take L off the lamp
  1667. ''      if s = "lS" then Continue For   'skip some garbage in the lamp collection
  1668. '       i = cInt(s) 'convert string to integer to get the lampnumber
  1669. '       insertfading(i, 0) = i
  1670. '       insertfading(i, 1) = x.fadespeedup
  1671. '       insertfading(i, 2) = x.fadespeeddown
  1672. '   next
  1673.  
  1674. End Sub
  1675.  
  1676. '======================
  1677. 'Animation constants
  1678. '======================
  1679. 'Update states
  1680. Const cCoffin = 205
  1681. Const cCadaver = 206
  1682. Const cCrate = 207
  1683. 'Animations
  1684. Const cBoogieL = 304    'Boogie L body
  1685. Const cBoogieR = 305    'Boogie R body
  1686. Const cBoogieLarms = 306    'Boogie L arms
  1687. Const cBoogieRarms = 307    'Boogie R arms
  1688. Const cLeftSling = 308
  1689. Const cRightSling = 309
  1690. Const cTopSling = 310
  1691. Const cCardDT = 311     'ScoreCard DT
  1692. Const cCardFS = 312     'ScoreCard FS
  1693. 'Fading
  1694. Const cSpiderFade = 398 ' Spider fade up/down (in Single-Screen FS)
  1695. Const cGIon = 200
  1696. Const cGIMod = 300
  1697.  
  1698. dim CGT, InitFadeTime(1)
  1699. Sub GameTimer_Timer()
  1700.     cgt = gametime - InitFadeTime(0)
  1701.  
  1702.     Dim chgLamp, num, chg, ii
  1703.     chgLamp = Controller.ChangedLamps
  1704.     If Not IsEmpty(chgLamp) Then
  1705.         For ii = 0 To UBound(chgLamp)
  1706.             LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1)       'keep the real state in an array
  1707.            FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
  1708.        Next
  1709.  
  1710.     End If
  1711.  
  1712.     UpdateLamps
  1713.  
  1714.     spiderFS cSpiderFade    'handles spider opacity fading in Single-Screen FS
  1715.  
  1716.     FadeAnimation cCardDT, ScoreCardDT
  1717.     FadeAnimation cCardFS, ScoreCardFS
  1718.  
  1719.     UpdateFlippers
  1720.     UpdateCoffin cCoffin
  1721.     UpdateCadaver cCadaver
  1722.     UpdateCrate cCrate
  1723.  
  1724. '   FadeAnimationRotXm(Nr, Object1, object2, input) 'primitive animate RotX - Set up start and endpoints in FlashMin and FlashMax
  1725.     FadeAnimRotX cBoogieL, Boogie1, BoogieArms1, 100    'nr, object1, object2, auto loop / delay
  1726.     FadeAnimRotX cBoogieR, Boogie2, BoogieArms2, 100
  1727.  
  1728.     BoogieManAnim cBoogieLarms, Boogiearms1, 4
  1729.     BoogieManAnim cBoogieRarms, BoogieArms2, 4
  1730.  
  1731.     '2 frame animation for rubber (0 = resting, 1 = extended) + RotX sling kicker rotation
  1732. '   AnimateSlingshot 308, Sling1, SlingK1, 23, 16   'nr, rubber, kicker, kicker RotX, MS Delay
  1733. '   AnimateSlingshot 309, Sling2, SlingK2, 23, 16   'Right Sling
  1734. '   AnimateSlingshot 310, Sling3, SlingK3, 23, 16   'Top Sling
  1735.     FadeAnimShowFrame cLeftSling, Sling1, SlingK1, 23, 100  'nr, rubber, kicker, kicker RotX, MS Delay
  1736.     FadeAnimShowFrame cRightSling, Sling2, SlingK2, 23, 100 'Right Sling
  1737.     FadeAnimShowFrame cTopSling, Sling3, SlingK3, 23, 100   'Top Sling
  1738.  
  1739.  
  1740. '   FadeGi 0, 100   'Top    'On-Off relay, 0-8 step (via SolModValue)
  1741. '   FadeGi 1, 101   'Middle
  1742. ''''    FadeGI 2, 102   'Bottom 'right now everything playfield related is handled by this one
  1743. '   FadeGI 3, 103   'backglass
  1744.  
  1745.     FadeGI cGIon
  1746.     ModGI  cGImod
  1747.     UpdateGIObjects cGIon, cGImod, GI2, GIscale(2'(nr, nr2, GIarray, GIscaleOff)
  1748.     FadeLut cGIon, cGImod, "LutCont_", 27
  1749. '   FadeLut 200, 300, "LutSF_", 21  'Nr1(on/off), Nr2(Mod), LUT name prefix, max number of luts
  1750.  
  1751.     nModFlashInterp 167, f17f, 15, 0.8 'bulb flasher
  1752.     nModFlashInterp 117, f17, 0, 0.5   'X ambient flasher
  1753.     nModFlashMInterp  117, f17t         'Transmit
  1754.  
  1755.     nModFlashInterp 168, f18f, 15, 0.8 'bulb flasher
  1756.     nModFlashInterp 118, f18, 0, 0.5   'X ambient flasher
  1757.     nModFlashMInterp  118, f18t         'Transmit
  1758.  
  1759.     nModFlashInterp 169, f19f, 15, 0.8 'bulb flasher
  1760.     nModFlashInterp 119, f19, 0, 0.5   'X ambient flasher
  1761.     nModFlashMInterp  119, f19t         'Transmit
  1762.  
  1763.     nModFlashMAvgM Bumperw, 117, 118, 119   'f17, f18, f19 sidewall. avg'd together
  1764.  
  1765.     nModFlashInterp 120, f20n, 0, 0 'ballsave Flasher
  1766.     nModFlashMInterp  120, f20a1
  1767.     nModFlashMInterp  120, f20a2
  1768.  
  1769.     nModFlashInterp 121, f21F, 0, 0 'deadheads 1
  1770.  
  1771.     nModFlashInterp 123, f23, 0, 0  'Bony Beast
  1772.  
  1773.     nModFlashInterp 125, f25F, 0, 0 'deadheads 2
  1774.  
  1775.     nModFlashInterp 126, f26n, 0, 0 'insert (TV flasher)
  1776.  
  1777.     nModFlashInterp 177, f27f, 9, 1 'bulb falsher
  1778.     nModFlashInterp  127, F27N, 0, 0.67
  1779.     nModFlashMInterp  127, F27side  'Ambient / sidewalls
  1780.     nModFlashMInterp  127, F27a
  1781.     nModFlashMInterp  127, f27t 'skeleton transmit
  1782.  
  1783.     nModFlashInterp 172, F22F, 9, 1',   9,  0.6
  1784.     nModFlashInterp  122, f22N, 0, 0.67
  1785.     nModFlashMInterp  122, F22side
  1786.     nModFlashMInterp  122, F22a
  1787.     nModFlashMInterp  122, f22t 'skeleton transmit
  1788.  
  1789.     nModFlashInterp 174, f24f, 9, 1 'bulb falsher
  1790.     nModFlashInterp  124, F24N, 0, 0.67',   9,  0.6
  1791.     nModFlashMInterp  124, F24side
  1792.     nModFlashMInterp  124, F24a
  1793.  
  1794.     nModFlashInterp 178, f28f, 9, 1 'bulb falsher
  1795.     nModFlashInterp  128, F28N, 0, 0.67',   9,  0.6
  1796.     nModFlashMInterp  128, F28side
  1797.     nModFlashMInterp  128, F28a
  1798.     nModFlashMInterp  128, f28t 'skeleton transmit
  1799.  
  1800.     nModFlashInterp 185, f35f, 9, 1 'old bulb falsher
  1801.     nModFlashInterp  135, f35n, 0, 0.67 'transmit orb
  1802.     nModFlashMInterp  135, F35side
  1803.     nModFlashMInterp  135, F35a
  1804.  
  1805.     nModFlashInterp 186, f36f, 9, 1 'bulb falsher
  1806.     nModFlashInterp  136, F36N, 0, 0.67',   9,  0.6
  1807.     nModFlashMInterp  136, F36side
  1808.     nModFlashMInterp  136, F36a
  1809.     nModFlashMInterp  136, f36t 'skeleton transmit
  1810.  
  1811.  
  1812.  
  1813.  
  1814.     InitFadeTime(0) = gametime
  1815. End Sub
  1816.  
  1817. Sub nModFlashMAvgM(object, nr1, nr2, nr3)   'one object, contribution from three solmod flashlevels
  1818.     If FadingLevel(nr1) < 2 and FadingLevel(nr2) < 2 and FadingLevel(nr3) < 2 then exit Sub
  1819.     dim avg
  1820.     avg = ((FlashLevel(nr1) + FlashLevel(nr2) + FlashLevel(nr3)) /3)
  1821.     if avg < 0 then avg = 0
  1822.     avg = ScaleLights(avg, 0)
  1823. '   tb.text = avg
  1824.     object.IntensityScale = avg
  1825. End Sub
  1826.  
  1827. '***********
  1828. ' Update GI
  1829. '***********
  1830. 'Sub UpdateGIOn(no, Enabled) : Setlamp no+200, cInt(enabled) : End Sub 
  1831. Sub UpdateGIOn(no, Enabled) : Setlamp no+200, cInt(enabled) : End Sub   'cGIon = 200 'cGImod = 300
  1832. Sub UpdateGI(no, step)
  1833.     Dim ii, x', i
  1834.    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...
  1835.     SetModLamp no+300, ScaleGI(step, 0)
  1836.     LampState((no+300)) = 0
  1837. '   if no = 2 then tb.text = no & vbnewline & step & vbnewline & ScaleGI(step,0) & SolModValue(102)
  1838. End Sub
  1839.  
  1840. dim LSstate : LSstate = False   'fading sub handles SFX
  1841. Sub FadeGI(nr) 'in On/off       'Updates nothing but flashlevel
  1842.    Select Case FadingLevel(nr)
  1843.         Case 3
  1844.             FadingLevel(nr) = 0
  1845.         Case 4 'off
  1846. '           If Not LSstate then Playsound "FX_Relay_Off",0, LVL(0.1) : LSstate = True   'handle SFX
  1847.            FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * CGT)
  1848.             If FlashLevel(nr) < FlashMin(nr) Then
  1849.                FlashLevel(nr) = FlashMin(nr)
  1850.                FadingLevel(nr) = 3 'completely off
  1851. '               LSstate = False
  1852.            End if
  1853.         Case 5 ' on
  1854. '           If Not LSstate then Playsound "FX_Relay_On",0, LVL(0.1) : LSstate = True    'handle SFX
  1855.            FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * CGT)
  1856.             If FlashLevel(nr) > FlashMax(nr) Then
  1857.                 FlashLevel(nr) = FlashMax(nr)
  1858.                 FadingLevel(nr) = 6 'completely on
  1859. '               LSstate = False
  1860.            End if
  1861.         Case 6
  1862.             FadingLevel(nr) = 1
  1863.     End Select
  1864. End Sub
  1865. Sub ModGI(nr2) 'in 0->1     'Updates nothing but flashlevel 'never off
  1866.     dim DesiredFading
  1867.     Select Case FadingLevel(nr2)
  1868.         case 3  'workaround - wait a frame to let M sub finish fading
  1869.             FadingLevel(nr2) = 0
  1870. '       Case 4  'off    -disabled off, only gicallback1 can turn off GI(?)
  1871. '           FadingLevel(nr2) = 3
  1872.         Case 5, 4 ' Fade (Dynamic)
  1873.             DesiredFading = SolModValue(nr2)
  1874.             if FlashLevel(nr2) < DesiredFading Then '+
  1875.                 FlashLevel(nr2) = FlashLevel(nr2) + (FlashSpeedUp(nr2)  * cgt   )
  1876.                 If FlashLevel(nr2) >= DesiredFading Then FlashLevel(nr2) = DesiredFading : FadingLevel(nr2) = 1
  1877.             elseif FlashLevel(nr2) > DesiredFading Then '-
  1878.                 FlashLevel(nr2) = FlashLevel(nr2) - (FlashSpeedDown(nr2) * cgt  )
  1879.                 If FlashLevel(nr2) <= DesiredFading Then FlashLevel(nr2) = DesiredFading : FadingLevel(nr2) = 6
  1880.             End If
  1881.         Case 6
  1882.             FadingLevel(nr2) = 1
  1883.     End Select
  1884. End Sub
  1885.  
  1886. Sub UpdateGIobjects(nr, nr2, a, GIscaleOff)
  1887. '   tbgi.text = "GI: " & SolModValue(nr) & " " & FlashLevel(nr) & " " & FadingLevel(nr) & vbnewline & _
  1888. '               "ModGI: " & SolModValue(nr2) & " " & FlashLevel(nr2) & " " & FadingLevel(nr2) & vbnewline & _
  1889. '               "Solmodvalue, Flashlevel, Fading step"
  1890.     If FadingLevel(nr) > 1 or FadingLevel(nr2) > 1 Then
  1891.         dim OutputF : OutputF = InterpolateV(FlashLevel(nr2) * FlashLevel(nr)   )
  1892.         dim OutputL : OutputL = Interpolate(FlashLevel(nr2) * FlashLevel(nr)    )
  1893.         dim GiscalerF, giscalerL, x
  1894.        
  1895.         'Update GI
  1896.         for each x in a
  1897.             x.IntensityScale = OutputL
  1898.         next
  1899.         GiscalerF = ((Giscaleoff-1) * (ABS(OutputF-1) )  ) + 1  'fade GIscale the opposite direction
  1900.         GiscalerL = ((Giscaleoff-1) * (ABS(OutputL-1) )  ) + 1  'fade GIscale the opposite direction
  1901.         'Handle Compensate Flashers
  1902.  
  1903.         for x = 0 to (aFlashers.Count - 1)
  1904.             On Error Resume Next
  1905.             AFlashers(x).Opacity = FlashersOpacity(x) * GiscalerF
  1906.             AFlashers(x).Intensity = FlashersOpacity(x) * GiscalerF
  1907.         next
  1908.  
  1909.         for x = 0 to (BallReflections.Count - 1)
  1910.             BallReflections(x).IntensityScale = OutputL
  1911.         next
  1912.         for x = 0 to (Lamps.Count - 1)
  1913.             On Error Resume Next
  1914.             Lamps(x).Opacity = InsertFading(x, 0) * GiscalerL
  1915.             Lamps(x).Intensity = InsertFading(x, 0) * GiscalerL
  1916.             Lamps(x).FadeSpeedUp = InsertFading(x, 1) * GiscalerL
  1917.             Lamps(x).FadeSpeedDown = InsertFading(x, 2) * GiscalerL
  1918.         Next
  1919. '       tbbb.text = giscaler & " on:" & FadingLevel(nr) & vbnewline & "flash: " & output & " onmod:" & FadingLevel(nr2) & vbnewline & l37.intensity
  1920. '       tbbb1.text = FadingLevel(nr) & vbnewline & FadingLevel(nr2)
  1921. '   tbgi1.text = Output & " giscale:" & giscaler    'debug
  1922.     End If
  1923. '       tbbb1.text = FLashLevel(nr) & vbnewline & FlashLevel(nr2)
  1924. end Sub
  1925.  
  1926.  
  1927. Sub FadeLUT(nr, nr2, LutName, LutCount) 'fade lookuptable NOTE- this is a bad idea for darkening your table as
  1928.     If FadingLevel(nr) >2 or FadingLevel(nr2) > 2 Then              '-it will strip the whites out of your image
  1929.         dim GoLut
  1930.         GoLut = cInt(LutCount * (FlashLevel(nr)*FlashLevel(nr2) )   )
  1931.         Table1.ColorGradeImage = LutName & GoLut
  1932. '       tbgi2.text = Table1.ColorGradeImage & vbnewline & golut 'debug
  1933.     End If
  1934. End Sub
  1935.  
  1936. Sub nModFlash(nr, object, scaletype, offscale)  'Fading using intensityscale with modulated callbacks   'gametime compensated
  1937.     dim DesiredFading
  1938.     Select Case FadingLevel(nr)
  1939.         case 3  'workaround - wait a frame to let M sub finish fading
  1940.             FadingLevel(nr) = 0
  1941.         Case 4  'off
  1942.             If Offscale = 0 then Offscale = 1
  1943.             FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * cgt ) * offscale
  1944.             If FlashLevel(nr) < 0 then FlashLevel(nr) = 0 : FadingLevel(nr) = 3
  1945.             Object.IntensityScale = ScaleLights(FlashLevel(nr),0 )
  1946.         Case 5 ' Fade (Dynamic)
  1947.             DesiredFading = ScaleByte(SolModValue(nr), scaletype)
  1948.             if FlashLevel(nr) < DesiredFading Then '+
  1949.                 FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * cgt   )
  1950.                 If FlashLevel(nr) >= DesiredFading Then FlashLevel(nr) = DesiredFading : FadingLevel(nr) = 1
  1951.             elseif FlashLevel(nr) > DesiredFading Then '-
  1952.                 FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * cgt )
  1953.                 If FlashLevel(nr) <= DesiredFading Then FlashLevel(nr) = DesiredFading : FadingLevel(nr) = 6
  1954.             End If
  1955.             Object.Intensityscale = ScaleLights(FlashLevel(nr),0 )' * GIscale * Nmult(nr)
  1956.         Case 6
  1957.             FadingLevel(nr) = 1
  1958.     End Select
  1959. End Sub
  1960.  
  1961. Sub nModFlashInterp(nr, object, scaletype, offscale)    'Fading using intensityscale with modulated callbacks   'gametime compensated
  1962.     dim DesiredFading
  1963.     Select Case FadingLevel(nr)
  1964.         case 3  'workaround - wait a frame to let M sub finish fading
  1965.             FadingLevel(nr) = 0
  1966.         Case 4  'off
  1967.             If Offscale = 0 then Offscale = 1
  1968.             FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * cgt ) * offscale
  1969.             If FlashLevel(nr) < 0 then FlashLevel(nr) = 0 : FadingLevel(nr) = 3
  1970.             Object.IntensityScale = ScaleLights(FlashLevel(nr),0 )
  1971.         Case 5 ' Fade (Dynamic)
  1972.             DesiredFading = ScaleByte(SolModValue(nr), scaletype)
  1973.             if FlashLevel(nr) < DesiredFading Then '+
  1974.                 FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * cgt   )
  1975.                 If FlashLevel(nr) >= DesiredFading Then FlashLevel(nr) = DesiredFading : FadingLevel(nr) = 1
  1976.             elseif FlashLevel(nr) > DesiredFading Then '-
  1977.                 FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * cgt )
  1978.                 If FlashLevel(nr) <= DesiredFading Then FlashLevel(nr) = DesiredFading : FadingLevel(nr) = 6
  1979.             End If
  1980.             Object.Intensityscale = InterpolateV(ScaleLights(FlashLevel(nr),0 ) )' * GIscale * Nmult(nr)
  1981.         Case 6
  1982.             FadingLevel(nr) = 1
  1983.     End Select
  1984. '   tb.text = f27n.intensityscale
  1985. End Sub
  1986.  
  1987. Sub nModFlashMInterp(nr, Object)
  1988.     Select Case FadingLevel(nr)
  1989.         Case 3, 4, 5, 6
  1990.             Object.Intensityscale = InterpolateV(ScaleLights(FlashLevel(nr),0 ) )' * GIscale(nr)
  1991.     End Select
  1992. End Sub
  1993.  
  1994. Function Interpolate(x) 'smooth, subtle 0-1 interpolation
  1995. '   Interpolate = -x^3/3 + x^2/2 + (5*x)/6  '0-0-1-1
  1996.     Interpolate = -x^3/3 + x^2/2 + (5*x)/6  '0-0-1-1
  1997. End Function
  1998.  
  1999. Function InterpolateV(x)    'The V stands for 'very much' interpolation
  2000. '   InterpolateV = -0.217469*x^3 + 1.10481*x^2 + 0.112656*x - 2.22045*10^-16    'Very low-end heavy
  2001.     'InterpolateV = -1.94137*x^3 + 2.91206*x^2 + 0.0293147*x + 0    'Balanced but heavy
  2002.     'InterpolateV = 2*x - x^2 'Top heavy
  2003.     'InterpolateV = (4*x)/3 - x^3/3 'Top heavy 2
  2004.     InterpolateV = -(2*x^3)/3 + x^2 + (2*x)/3'balanced
  2005.     if InterpolateV < 0 then InterpolateV = 0
  2006. End Function
  2007.  
  2008.  
  2009. Sub nModFlashM(nr, Object)
  2010.     Select Case FadingLevel(nr)
  2011.         Case 3, 4, 5, 6
  2012.             Object.Intensityscale = ScaleLights(FlashLevel(nr),0 )' * GIscale(nr)
  2013.     End Select
  2014. End Sub
  2015.  
  2016.  
  2017. Sub Flashc(nr, object)
  2018.     Select Case FadingLevel(nr)
  2019.         Case 3
  2020.             FadingLevel(nr) = 0
  2021.         Case 4 'off
  2022.            FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * CGT)
  2023.             If FlashLevel(nr) < FlashMin(nr) Then
  2024.                 FlashLevel(nr) = FlashMin(nr)
  2025.                FadingLevel(nr) = 3 'completely off
  2026.            End if
  2027.             Object.IntensityScale = Interpolate(FlashLevel(nr) )
  2028.         Case 5 ' on
  2029.            FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * CGT)
  2030.             If FlashLevel(nr) > FlashMax(nr) Then
  2031.                 FlashLevel(nr) = FlashMax(nr)
  2032.                 FadingLevel(nr) = 6 'completely on
  2033.            End if
  2034.             Object.IntensityScale = Interpolate(FlashLevel(nr) )
  2035.         Case 6
  2036.             FadingLevel(nr) = 1
  2037.     End Select
  2038. End Sub
  2039.  
  2040. Sub Flashm(nr, object) 'multiple flashers, it just sets the flashlevel
  2041.     select case FadingLevel(nr)
  2042.         case 3, 4, 5, 6
  2043.             Object.IntensityScale = Interpolate(FlashLevel(nr)  )
  2044.     end select
  2045. End Sub
  2046.  
  2047.  
  2048.  
  2049. Function ScaleLights(value, scaletype)  'returns an intensityscale-friendly 0->100% value out of 255
  2050.     dim i
  2051.     Select Case scaletype   'select case because bad at maths   'TODO: Simplify these functions. B/c this is absurdly bad.
  2052.         case 0
  2053.             i = value * (1 / 255)   '0 to 1
  2054.         case 6  '0.0625 to 1
  2055.             i = (value + 17)/272
  2056.         case 9  '0.089 to 1
  2057.             i = (value + 25)/280
  2058.         case 15
  2059.             i = (value / 300) + 0.15
  2060.         case 20
  2061.             i = (4 * value)/1275 + (1/5)
  2062.         case 25
  2063.             i = (value + 85) / 340
  2064.         case 37 '0.375 to 1
  2065.             i = (value+153) / 408
  2066.         case 40
  2067.             i = (value + 170) / 425
  2068.         case 50
  2069.             i = (value + 255) / 510 '0.5 to 1
  2070.         case 75
  2071.             i = (value + 765) / 1020    '0.75 to 1
  2072.         case Else
  2073.             i = 10
  2074.     End Select
  2075.     ScaleLights = i
  2076. End Function
  2077.  
  2078. Function ScaleByte(value, scaletype)    'returns a number between 1 and 255
  2079.     dim i
  2080.     Select Case scaletype
  2081.         case 0
  2082.             i = value * 1   '0 to 1
  2083.         case 9  'ugh
  2084.             i = (5*(200*value + 1887))/1037
  2085.         case 15
  2086.             i = (16*value)/17 + 15
  2087.         case else
  2088.             i = (3*(value + 85))/4  '63.75 to 255
  2089.     End Select
  2090.     ScaleByte = i
  2091. End Function
  2092.  
  2093. Function ScaleGI(value, scaletype)  'returns an intensityscale-friendly 0->100% value out of 1>8 'it does go to 8
  2094.     dim i
  2095.     Select Case scaletype   'select case because bad at maths
  2096.         case 0
  2097.             i = value * (1/8)   '0 to 1
  2098.         case 25
  2099.             i = (1/28)*(3*value + 4)
  2100.         case 50
  2101.             i = (value+5)/12
  2102.         case else
  2103. '           x = (4*value)/3 - 85    '63.75 to 255
  2104.  
  2105.     End Select
  2106.     ScaleGI = i
  2107. End Function
  2108.  
  2109. Function ScaleFalloff(value, nr)
  2110.     select case nr
  2111. '       case 122, 124, 127, 128, 135, 136
  2112. '           ScaleFalloff = (value+170)/425      '0.4 to 1
  2113.         case 123
  2114.             ScaleFalloff = 1
  2115.         case else
  2116.             ScaleFalloff = (value + 765) / 1020 '0.75 to 1
  2117.     end select
  2118. End Function
  2119.  
  2120.  
  2121.  
  2122. '=============================
  2123. 'Animation Subs (Fading Script)
  2124. '=============================
  2125. 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)
  2126.     Select Case FadingLevel(nr)
  2127.         Case 4
  2128.             FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr) * CGT)
  2129.             If FlashLevel(nr) < FlashMin(nr) Then
  2130.                 FlashLevel(nr) = FlashMin(nr)
  2131.                FadingLevel(nr) = 0 'completely off
  2132.            End if
  2133.             Object.ShowFrame InterpolateV(FlashLevel(nr)    )
  2134.         Case 5
  2135.             FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * CGT)
  2136.             If FlashLevel(nr) > FlashMax(nr) Then
  2137.                 FlashLevel(nr) = FlashMax(nr)
  2138.                 FadingLevel(nr) = 1 'completely on
  2139.            End if
  2140.             Object.ShowFrame InterpolateV(FlashLevel(nr)    )
  2141.     End Select
  2142. End Sub
  2143.  
  2144.  
  2145.  
  2146. '
  2147. 'dim ms : ms = 0
  2148. 'Sub tbC_Timer()
  2149. '   dim x
  2150. '   x = "hi"
  2151.  
  2152. '   ms = ms + 1 * CGT
  2153. '
  2154. '   tbc.text = ms & vbnewline & _
  2155. '   "Frametime: " & CGT & vbnewline & _
  2156. '   x
  2157. '
  2158. 'End Sub
  2159.  
  2160.  
  2161. '   '2 frame animation for rubber (0 = resting, 1 = extended) + RotX sling kicker rotation
  2162. '   AnimateSlingshot 101, Sling1, SlingK1, 23, 12   'nr, rubber, kicker, kicker RotX, MS Delay
  2163.  
  2164. Sub AnimateSlingShot(nr, object1, object2, rotation, delay)
  2165.     Select Case FadingLevel(nr)
  2166.         Case 4
  2167.             FadingLevel(nr) = 0
  2168.         Case 5          'Part 1 - Extend immediately
  2169.             FlashLevel(nr) = 1
  2170.             object1.ShowFrame FlashLevel(nr)'1
  2171.             Object2.RotX = FlashLevel(nr) * rotation
  2172.             SolModValue(nr) = 0 + CGT
  2173.             FadingLevel(nr) = 6
  2174.             LampState(nr) = 0 'ignore lampstate
  2175.         Case 6  'Handle Delay (crude)
  2176.             if cgt < (delay/2) Then FadingLevel(nr) = 7 else FadingLevel(nr) = 8
  2177.         case 7' 'Handle Delay (Crude)
  2178.             FadingLevel(nr) = 8
  2179.         case 8  'linear falloff
  2180.             FlashLevel(nr) = FlashLevel(nr) - (FlashSpeedDown(nr)*CGT)
  2181.             If FlashLevel(nr) < FlashMin(nr) Then
  2182.                 FlashLevel(nr) = FlashMin(nr)
  2183.                FadingLevel(nr) = 0 'completely off
  2184.            End if
  2185.             object1.Showframe FlashLevel(nr)
  2186.             object2.RotX = FlashLevel(nr)*rotation 
  2187.     End Select
  2188. End Sub
  2189.  
  2190. dim LeftOvers(450)
  2191. Dim EndPoint(450)
  2192. Sub FadeAnimRotX(Nr, Object1, object2, input) 'primitive animate RotX - Set up start and endpoints in FlashMin and FlashMax
  2193.     dim KeyframeMult
  2194.     Select Case FadingLevel(nr)
  2195.         Case 5  'init
  2196.             'frames = 4
  2197.             LampState(nr) = 0
  2198.             FlashLevel(nr) = 0
  2199.             SolModValue(nr) = 0
  2200.             SolModValue(nr) = SolModValue(nr) + CGT 'Track ms
  2201.  
  2202.             KeyframeMult = 1
  2203.             FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * KeyframeMult * CGT)
  2204.  
  2205.             object1.RotX = FlashLevel(nr)
  2206.             object2.RotX = FlashLevel(nr)
  2207.  
  2208.             FadingLevel(nr) = 6
  2209. '           debug.print FlashLevel(nr) & " " & FadingLevel(nr)
  2210. '           tbL.text = "Step:" & fadinglevel(nr) & vbnewline & _
  2211. '                   "Lvl: " & FlashLevel(nr) & vbnewline & _
  2212. '                   "ms : " & SolModValue(nr) & vbnewline & _
  2213. '                   "endpoint: " & EndPoint(nr) & vbnewline & _
  2214. '                   "delay: " & input & vbnewline & _
  2215. '                   "leftovers: " & LeftOvers(nr) & vbnewline & _
  2216. '                   SolModValue(nr) - EndPoint(nr) + LeftOvers(nr)
  2217.                    
  2218.         Case 6  'dive forward
  2219.             SolModValue(nr) = SolModValue(nr) + CGT 'update MS counter
  2220.  
  2221.             KeyFrameMult = 1
  2222.             FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * KeyframeMult * CGT)
  2223.  
  2224.             If FlashLevel(nr) > FlashMax(nr) then
  2225.                 leftovers(nr) =  FlashLevel(nr) - FlashMax(nr)
  2226.                 FlashLevel(nr) = FlashMax(nr)
  2227.                 if input < 0 then   'if less than 0, end script
  2228.                     FadingLevel(nr) = 1
  2229.                 Else
  2230.                     EndPoint(nr) = SolModValue(nr)
  2231.                     FadingLevel(nr) = 7 'otherwise, reverse direction
  2232.                 End If
  2233.             End If
  2234.  
  2235.             object1.RotX = FlashLevel(nr)
  2236.             object2.RotX = FlashLevel(nr)
  2237. '           debug.print FlashLevel(nr) & " " & FadingLevel(nr)
  2238. '           tbL.text = "Step:" & fadinglevel(nr) & vbnewline & _
  2239. '                   "Lvl: " & FlashLevel(nr) & vbnewline & _
  2240. '                   "ms : " & SolModValue(nr) & vbnewline & _
  2241. '                   "endpoint: " & EndPoint(nr) & vbnewline & _
  2242. '                   "delay: " & input & vbnewline & _
  2243. '                   "leftovers: " & LeftOvers(nr) & vbnewline & _
  2244. '                   SolModValue(nr) - EndPoint(nr) + LeftOvers(nr)
  2245.                    
  2246.         Case 7 'Delay, Swing Back
  2247.             SolModValue(nr) = SolModValue(nr) + CGT 'update MS counter
  2248.  
  2249.             'If new Timer < Delay
  2250.             if SolModValue(nr) - EndPoint(nr) + LeftOvers(nr) <= input Then 'if MS < delay, DELAY
  2251.                 KeyFrameMult = 0
  2252.             elseif SolModValue(nr) - EndPoint(nr) >= input + CGT Then
  2253.                 Leftovers(nr) = 0
  2254.                 KeyFrameMult = 1
  2255.             elseif SolModValue(nr) - EndPoint(nr) >= input - CGT then   'delay over, add leftovers to flashlevel
  2256.                 Leftovers(nr) = (SolModValue(nr) - EndPoint(nr) ) - input '35 - 16 - 16        
  2257.             Else
  2258. '               tb.text = "???"
  2259.             End If
  2260.  
  2261.  
  2262.  
  2263.             FlashLevel(nr) = FlashLevel(nr) - ((FlashSpeedDown(nr) - Leftovers(nr)  ) * KeyframeMult * CGT)
  2264.  
  2265.            
  2266.             If FlashLevel(nr) < FlashMin(nr) then
  2267.                 FlashLevel(nr) = FlashMin(nr)
  2268.                 FadingLevel(nr) = 0
  2269.             End If
  2270.             object1.RotX = FlashLevel(nr)
  2271.             object2.RotX = FlashLevel(nr)
  2272. '           debug.print FlashLevel(nr) & " " & FadingLevel(nr)
  2273. '           tbL.text = "Step:" & fadinglevel(nr) & vbnewline & _
  2274. '                   "Lvl: " & FlashLevel(nr) & vbnewline & _
  2275. '                   "ms : " & SolModValue(nr) & vbnewline & _
  2276. '                   "endpoint: " & EndPoint(nr) & vbnewline & _
  2277. '                   "delay: " & input & vbnewline & _
  2278. '                   "leftovers: " & LeftOvers(nr) & vbnewline & _
  2279. '                   SolModValue(nr) - EndPoint(nr) + LeftOvers(nr)
  2280.                    
  2281.     End Select
  2282.  
  2283.  
  2284. End Sub
  2285.  
  2286.  
  2287.  
  2288. Sub FadeAnimShowFrame(nr, object1, object2, rotation, input) 'primitive animate RotX - Set up start and endpoints in FlashMin and FlashMax
  2289.     dim KeyframeMult
  2290.     Select Case FadingLevel(nr)
  2291.         Case 5  'init
  2292.             'frames = 4
  2293.             LampState(nr) = 0
  2294.             FlashLevel(nr) = 0
  2295.             SolModValue(nr) = 0
  2296.             SolModValue(nr) = SolModValue(nr) + CGT 'Track ms
  2297.  
  2298.             KeyframeMult = 1
  2299.             FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * KeyframeMult * CGT)
  2300.  
  2301.             object1.ShowFrame FlashLevel(nr)
  2302.             object2.RotX = FlashLevel(nr) * Rotation
  2303.  
  2304.             FadingLevel(nr) = 6
  2305. '           debug.print FlashLevel(nr) & " " & FadingLevel(nr)
  2306. '           tbL.text = "Step:" & fadinglevel(nr) & vbnewline & _
  2307. '                   "Lvl: " & FlashLevel(nr) & vbnewline & _
  2308. '                   "ms : " & SolModValue(nr) & vbnewline & _
  2309. '                   "endpoint: " & EndPoint(nr) & vbnewline & _
  2310. '                   "delay: " & input & vbnewline & _
  2311. '                   "leftovers: " & LeftOvers(nr) & vbnewline & _
  2312. '                   SolModValue(nr) - EndPoint(nr) + LeftOvers(nr)
  2313.                    
  2314.         Case 6  'dive forward
  2315.             SolModValue(nr) = SolModValue(nr) + CGT 'update MS counter
  2316.  
  2317.             KeyFrameMult = 1
  2318.             FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * KeyframeMult * CGT)
  2319.  
  2320.             If FlashLevel(nr) > FlashMax(nr) then
  2321.                 leftovers(nr) =  FlashLevel(nr) - FlashMax(nr)
  2322.                 FlashLevel(nr) = FlashMax(nr)
  2323.                 if input < 0 then   'if less than 0, end script
  2324.                     FadingLevel(nr) = 1
  2325.                 Else
  2326.                     EndPoint(nr) = SolModValue(nr)
  2327.                     FadingLevel(nr) = 7 'otherwise, reverse direction
  2328.                 End If
  2329.             End If
  2330.  
  2331.             object1.ShowFrame FlashLevel(nr)
  2332.             object2.RotX = FlashLevel(nr) * Rotation
  2333. '           debug.print FlashLevel(nr) & " " & FadingLevel(nr)
  2334. '           tbL.text = "Step:" & fadinglevel(nr) & vbnewline & _
  2335. '                   "Lvl: " & FlashLevel(nr) & vbnewline & _
  2336. '                   "ms : " & SolModValue(nr) & vbnewline & _
  2337. '                   "endpoint: " & EndPoint(nr) & vbnewline & _
  2338. '                   "delay: " & input & vbnewline & _
  2339. '                   "leftovers: " & LeftOvers(nr) & vbnewline & _
  2340. '                   SolModValue(nr) - EndPoint(nr) + LeftOvers(nr)
  2341.                    
  2342.         Case 7 'Delay, Swing Back
  2343.             SolModValue(nr) = SolModValue(nr) + CGT 'update MS counter
  2344.  
  2345.             'If new Timer < Delay
  2346.             if SolModValue(nr) - EndPoint(nr) + LeftOvers(nr) <= input Then 'if MS < delay, DELAY
  2347.                 KeyFrameMult = 0
  2348.             elseif SolModValue(nr) - EndPoint(nr) >= input + CGT Then
  2349.                 Leftovers(nr) = 0
  2350.                 KeyFrameMult = 1
  2351.             elseif SolModValue(nr) - EndPoint(nr) >= input - CGT then   'delay over, add leftovers to flashlevel
  2352.                 Leftovers(nr) = (SolModValue(nr) - EndPoint(nr) ) - input '35 - 16 - 16        
  2353.             Else
  2354. '               tb.text = "???"
  2355.             End If
  2356.  
  2357.  
  2358.  
  2359.             FlashLevel(nr) = FlashLevel(nr) - ((FlashSpeedDown(nr) - Leftovers(nr)  ) * KeyframeMult * CGT)
  2360.  
  2361.            
  2362.             If FlashLevel(nr) < FlashMin(nr) then
  2363.                 FlashLevel(nr) = FlashMin(nr)
  2364.                 FadingLevel(nr) = 0
  2365.             End If
  2366.             object1.ShowFrame FlashLevel(nr)
  2367.             object2.RotX = FlashLevel(nr) * Rotation
  2368. '           debug.print FlashLevel(nr) & " " & FadingLevel(nr)
  2369. '           tbL.text = "Step:" & fadinglevel(nr) & vbnewline & _
  2370. '                   "Lvl: " & FlashLevel(nr) & vbnewline & _
  2371. '                   "ms : " & SolModValue(nr) & vbnewline & _
  2372. '                   "endpoint: " & EndPoint(nr) & vbnewline & _
  2373. '                   "delay: " & input & vbnewline & _
  2374. '                   "leftovers: " & LeftOvers(nr) & vbnewline & _
  2375. '                   SolModValue(nr) - EndPoint(nr) + LeftOvers(nr)
  2376.                    
  2377.     End Select
  2378.  
  2379.  
  2380. End Sub
  2381.  
  2382.  
  2383.  
  2384. dim BoogieDuration' : BoogieDuration = 100
  2385. Sub BoogiemanAnim(nr, Object, Frames) ' 'More complicated keyframe animation
  2386.     dim KeyframeMult
  2387.     Select Case FadingLevel(nr)
  2388.         Case 5
  2389. '           Dim KeyframeMult
  2390.             'frames = 4
  2391. '           Duration = FlashSpeedUp(106)
  2392.             LampState(nr) = 0
  2393.             FlashLevel(nr) = 0
  2394.             SolModValue(nr) = 0
  2395.             SolModValue(nr) = SolModValue(nr) + CGT 'Track ms
  2396.  
  2397.             FlashSpeedUp(nr) = Frames / (BoogieDuration / CGT)  '0.32 at 8 frame time
  2398.  
  2399.  
  2400.             KeyframeMult = 2.29167'Always 0 to Start
  2401.             FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * KeyframeMult)
  2402.  
  2403.             object.ShowFrame FlashLevel(nr)
  2404.  
  2405.             FadingLevel(nr) = 6
  2406. '           debug.print FlashLevel(nr)
  2407.  
  2408.         Case 6
  2409.             if SolModValue(nr) > (0.45*BoogieDuration) Then
  2410.                 KeyFrameMult = 0.605
  2411.             Elseif SolModValue(nr) > (0.14*BoogieDuration) then
  2412.                 KeyFrameMult = 1.06765
  2413.             Else
  2414.                 KeyFrameMult = 2.2917
  2415.             End If
  2416.             SolModValue(nr) = SolModValue(nr) + CGT
  2417.             FlashSpeedUp(nr) = Frames / (BoogieDuration / CGT)  '0.32 at 8 frame time
  2418.             FlashLevel(nr) = FlashLevel(nr) + (FlashSpeedUp(nr) * KeyframeMult)
  2419.  
  2420.             If FlashLevel(nr) > Frames then
  2421.                 FlashLevel(nr) = Frames
  2422.                 FadingLevel(nr) = 1
  2423.             End If
  2424.  
  2425.             object.ShowFrame FlashLevel(nr)
  2426. '           debug.print FlashLevel(nr)
  2427.  
  2428.             'Keyframes (in %)
  2429.  
  2430.             'frame 0 -> 1
  2431.             '....14.54545454545454% 'arching back
  2432.             'i 42.72727272727273
  2433.  
  2434.             'frame 1 -> 2
  2435.             '...30.909091%          'stretching forward
  2436.  
  2437.             'i 34.5454545
  2438.  
  2439.  
  2440.             'frame 2 -> 3
  2441.             '...54.54545454545455%  'Resetting back to 0
  2442.  
  2443.             'i 22.72727272727273
  2444.  
  2445.             '14.545
  2446.             '45.45454545454545
  2447.             '100
  2448.            
  2449.     End Select
  2450. End Sub
  2451.  
  2452.  
  2453. '=============================
  2454.  
  2455. '=============================
  2456.  
  2457.  
  2458. 'flasher locations:
  2459. 'f27    f22
  2460. 'f24    f28
  2461. 'f35    f36
  2462.  
  2463. ''***********
  2464. '' Update GI
  2465. ''***********
  2466. 'Sub UpdateGIOn(no, Enabled) : Setlamp no, cInt(enabled) : tb.text = no & vbnewline & cInt(enabled) : End Sub  
  2467. 'Sub UpdateGI(no, step)
  2468. '    Dim ii, x', i
  2469. '    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...
  2470. '   SetModLamp no+100, ScaleGI(step, 0)
  2471. '   if no = 2 then tb.text = step & vbnewline & ScaleGI(step,0)
  2472. 'End Sub
  2473.  
  2474.  
  2475.        
  2476. 'cutting down the intensity a bit
  2477. 'min 50% intensityscale
  2478.  
  2479. 'x = intensityscale y = gistep
  2480. 'x1= 0.5 y1= 1
  2481. 'x2= 1   y2= 7
  2482.  
  2483. 'solve for slope
  2484. ''m = (y2 - y1) / (x2 - x1)
  2485. '   (7 - 1) / (1 - 0.5)
  2486. '   6 / 0.5
  2487. 'm = 12
  2488.  
  2489. 'point slope formula
  2490. 'y - y1 = m(x-x1)
  2491. '   y - 1 = 12(x-0.5)
  2492.  
  2493. 'y = 12x -5
  2494. 'x = (y+5)/12
  2495.  
  2496. Sub DebugLampsOn(i)
  2497.     dim x
  2498.     for each x in Lamps
  2499.         x.state = i
  2500.     next
  2501. End Sub
  2502.  
  2503. Sub DebugFlashers(x)
  2504. '   setlamp 122, x
  2505. '   Setlamp 127, x
  2506. '   setlamp 124, x
  2507. '   setlamp 128, x
  2508. '   setlamp 135, x
  2509. '   setlamp 136, x
  2510. '
  2511. '   setlamp 172, x
  2512. '   Setlamp 177, x
  2513. '   setlamp 174, x
  2514. '   setlamp 178, x
  2515. '   setlamp 185, x
  2516. '   setlamp 186, x
  2517. '   f22.state = x
  2518. '   f22b.state = x
  2519. '   f27.state = x
  2520. '   f27b.state = x
  2521. '   F24.state = x
  2522. '   f24b.state = x
  2523. '   F28.state = x
  2524. '   f28b.state = x
  2525. '   F35.state = x
  2526. '   f35b.state = x
  2527. '   f36.state = x
  2528. '   f36b.state = x
  2529. End Sub
  2530.  
  2531.  
  2532.  
  2533. 'Turn up inserts and flashers when GI is off Init
  2534. dim FlashersA, FlashersB
  2535. 'FlashersA = array(f22, f24, f27, f28, f35, F36)
  2536. 'FlashersB = array(f22b, f24b, f27b, f28b, f35b, F36b)
  2537.  
  2538.  
  2539. sub tweakflashers(input)
  2540.     dim x
  2541.     for each x in FlashersB
  2542.         x.intensity = input
  2543.     Next
  2544.     tb.text = "intensity: " & input
  2545. End Sub
  2546.  
  2547.  
  2548. '***************** Debug Stuff *************
  2549.  
  2550. 'Sub Textboxnf_timer()
  2551. 'dim i
  2552. 'i = ((f35f.opacity / f35fI)) * 100
  2553. 'i = cInt(i)
  2554. 'textboxnf.text = "opacity:" & i & vbnewline & "Scale:" & f35f.intensityscale * 100 & _
  2555. '   vbnewline & vbnewline & "FadeUp:" & f35.fadespeedup & vbnewline & "FadeDown" & f35.fadespeeddown
  2556. 'end Sub
  2557.  
  2558. 'flasher locations:
  2559. 'f27    f22
  2560. 'f24    f28
  2561. 'f35    f36
  2562.  
  2563. '======================
  2564. 'Solenoid Callbacks
  2565.  
  2566.  
  2567. '======================
  2568.  
  2569. Dim LockPower, LockHold
  2570. 'Solenoid routines
  2571. Sub LDiverterPower(enabled)
  2572.     LockPower = enabled
  2573.     If enabled Then
  2574.         Lock.RotateToEnd
  2575.         If Lock.CurrentAngle < 207 then PlaySound SoundFX("DiverterLeft_Open",DOFContactors), 0, LVL(0.17), -0.06, 0.1
  2576.     End If
  2577.     If Not enabled AND Not LockHold Then
  2578.         Lock.RotateToStart
  2579.         PlaySound SoundFX("DiverterLeft_Close",DOFContactors), 0, LVL(0.05), -0.06, 0.1
  2580.     End If
  2581. End Sub
  2582.  
  2583. Sub LDiverterHold(enabled)
  2584.     LockHold = enabled
  2585.     If Not enabled AND Not LockPower Then Lock.RotateToStart
  2586. End Sub
  2587.  
  2588. 'Sub SolUpperSling(enabled)
  2589. '   If Enabled Then
  2590. '       PlaySound SoundFX("LeftSlingShotTrimmed",DOFContactors), 0, LVL(0.68), -0.005, 0.2
  2591. '       Setlamp 310, 1
  2592. '   End If
  2593. 'End Sub
  2594.  
  2595. Sub SolLeftSling(enabled)
  2596.     If Enabled Then
  2597.         PlaySound SoundFX("LeftSlingShotTrimmed",DOFContactors), 0, LVL(0.2), -0.015, 0.2
  2598.         setlampmm cBoogieL, cBoogieLarms, cLeftSling, 1 'Rubber/Kicker, Boogie Rot, Boogie Showframe Anim
  2599.     End If
  2600. End sub
  2601.  
  2602. Sub SolRightSling(enabled)
  2603.     If Enabled Then
  2604.         PlaySound SoundFX("RightSlingShot",DOFContactors), 0, LVL(0.2), 0.01, 0.2
  2605.         setlampmm cBoogieR, cBoogieRarms, cRightSling, 1    'Rubber/Kicker, Boogie Rot, Boogie Showframe Anim
  2606.     End If
  2607. End Sub
  2608.  
  2609. Sub SolCoffinPopper(Enabled)
  2610.     dim x
  2611.     If Enabled Then
  2612.         If bsCoffin.Balls Then
  2613.             bsCoffin.ExitSol_On
  2614.             BIP = BIP + 1
  2615.             FadingLevel(cCadaver) = 5
  2616. '           TiCadaver.enabled = 1
  2617.             CoffinKicker.TimerEnabled = 1
  2618.             CoffinKicker.TimerInterval = 1500
  2619.             Playsound SoundFX("Kicker_Release",DOFContactors), 0, LVL(0.2), -0.015
  2620.         End If
  2621.     End If
  2622. End Sub
  2623.  
  2624. Sub SolLoopGate(Enabled)
  2625.     LoopGate.Open = Enabled
  2626. End Sub
  2627.  
  2628. Sub AutoPlunge(enabled)
  2629.     If Enabled Then
  2630.         IMAutoPlunger.Autofire
  2631.         playsound SoundFX("Kicker_Release",DOFcontactors), 0, LVL(0.3), 0.06,0.05
  2632.         if BallInPlunger then
  2633.             PlaySound SoundFX("Plunger3",0),0, LVL(0.3),0.06,0.05
  2634.         Else
  2635.             PlaySound SoundFX("plunger",0),0, LVL(0.3),0.06,0.05
  2636.         end if
  2637.     End if
  2638. End Sub
  2639.  
  2640. 'Sub CratePostPower(Enabled)
  2641. '   If(Enabled) Then
  2642. '       debugpower = 1
  2643. ''      sw57.IsDropped = 1
  2644. ''      Gate4.timerenabled = 1
  2645. '   Else
  2646. '       debugpower = 0
  2647. ''      CrateOpen = 0
  2648. '   End If
  2649. 'End Sub
  2650. dim debughold, debugpower
  2651. Sub CratePostHold(Enabled)
  2652. '   sw57.IsDropped = Enabled
  2653.     sw57.Collidable = Not Enabled
  2654. '   sw57.Visible = Enabled
  2655. '   tb.text = "crateposthold: " & enabled & "sw57: " & sw57.collidable
  2656.     If enabled then
  2657.         debughold = 1
  2658.         CrateTrigger.Timerinterval = 1200
  2659.         CrateTrigger.timerenabled = 1
  2660. '       crateopen = 1
  2661.     else
  2662.         debughold = 0
  2663.         CrateTrigger.Timerinterval = 1200
  2664.         CrateTrigger.timerenabled = 1
  2665.     end if
  2666. '   if CratePostHold(enabled) Then
  2667. '       sw57.IsDropped = Enabled
  2668. '   Else
  2669. '       sw57.IsDropped = Enabled
  2670. '       Gate4.timerenabled = 1
  2671. '   sw57.IsDropped = Enabled
  2672. '   CrateOpen = Enabled
  2673. End Sub
  2674.  
  2675. sub CrateTrigger_Timer()        'helps transition animation
  2676.     if sw57.Collidable = False then
  2677.         crateopen = 1
  2678.     Else
  2679.         crateopen = 0
  2680.     end if
  2681. '   textbox2.text = "crate updated"
  2682.     me.timerenabled = 0
  2683. end sub
  2684.  
  2685.  
  2686. Sub SolBallRelease(Enabled) 'trough release. Ballrelease
  2687.     If Enabled Then
  2688.         If bsTrough.Balls Then
  2689.             PlaySound SoundFX("BallReleaseRS",DOFcontactors), 0, LVL(0.4), 0.03
  2690.             vpmTimer.PulseSw 31
  2691.             bsTrough.ExitSol_On
  2692.             BIP = BIP + 1
  2693.         End If
  2694.     End If
  2695. End Sub
  2696.  
  2697. Dim CoffinDir
  2698. Sub SolCoffinDoor(Enabled)
  2699.     If Enabled Then
  2700.         CoffinDir = -1
  2701.     Else
  2702.         CoffinDir = 1
  2703.     End If
  2704.     FadingLevel(cCoffin) = 5
  2705. End Sub
  2706.  
  2707.  
  2708. Sub UpdateCoffin(nr)    'gametimer
  2709.     Select Case FadingLevel(nr)
  2710.         case 5
  2711.             PrCoffinLid.RotY = PrCoffinLid.RotY + ((1.5*cgt )*CoffinDir)    'adjust speed here
  2712.             If PrCoffinLid.RotY <= -110 Then
  2713.                 FadingLevel(nr) = 0
  2714.                 PrCoffinLid.RotY = -110
  2715.             End If
  2716.             If PrCoffinLid.RotY >= 0 Then
  2717.                 FadingLevel(nr) = 0
  2718.                 PrCoffinLid.RotY = 0
  2719.             End If
  2720.     End Select
  2721. End Sub
  2722.  
  2723.  
  2724.  
  2725. '***************
  2726. '* Lights
  2727. '***************
  2728.  
  2729. Sub UpdateLamps()
  2730.     FlashC 11, l11n
  2731.     FlashC 12, l12n
  2732.     FlashC 13, l13n
  2733.     FlashC 14, l14n
  2734.     FlashC 15, l15n
  2735.     FlashC 16, l16n
  2736.     FlashC 17, l17n
  2737.  
  2738.     If Not Proto then NFadeL 18, l18    'a beast eye
  2739.  
  2740.     FlashC 21, l21n
  2741.     FlashC 22, L22n
  2742.     FlashC 23, L23n
  2743.     FlashC 24, L24n
  2744.     FlashC 25, L25n'(l25, l26, l27, l51, l52, l53, l57, l58, l61, l62, l63)
  2745.     FlashC 26, L26n
  2746.     FlashC 27, L27n
  2747.     FlashC 28, L28n
  2748.  
  2749.  
  2750.     If Not Proto then NFadeLm 31, l31   'crate eyes
  2751.     If Not Proto then NFadeLm 32, l32
  2752.     If Not Proto then NFadeLm 33, l33
  2753.     If Not Proto then NFadeLm 34, l34
  2754.     If Not Proto then NFadeLm 31, l31a
  2755.     If Not Proto then NFadeLm 32, l32a
  2756.     If Not Proto then NFadeLm 33, l33a
  2757.     If Not Proto then NFadeLm 34, l34a
  2758.  
  2759.     FlashC 35, L35r 'prototype only kickback reflection
  2760.     Flashm 35, L35n
  2761.  
  2762.     FlashC 36, l36n
  2763.     FlashC 37, l37n
  2764.     FlashC 38, l38n
  2765.  
  2766.     FlashC 41, l41n
  2767.     FlashC 42, l42n
  2768.     FlashC 43, l43n
  2769.     If Not Proto then NFadeL 44, l44    'Ramp Right Eye (ss05)
  2770.  
  2771.     FlashC 45, l45r 'Telepathetic Power reflection
  2772.     Flashm 45, L45n
  2773.  
  2774.  
  2775.     FlashC 46, L46n
  2776.     FlashC 47, L47n
  2777.     FlashC 48, L48n
  2778.  
  2779.     If Not Proto then NFadeLmM 51, FlSkull6_1
  2780.     If Not Proto then NFadeLmM 51, FlSkull6_2
  2781.     FlashC 51, l51n
  2782.  
  2783.     If Not Proto then NFadeLmM 52, FlSkull5_1
  2784.     If Not Proto then NFadeLmM 52, FlSkull5_2
  2785.     FlashC 52, l52n
  2786.  
  2787.     If Not Proto then NFadeLmM 53, FlSkull4_1
  2788.     If Not Proto then NFadeLmM 53, FlSkull4_2
  2789.     FlashC 53, L53n
  2790.  
  2791. '   FlashC 54, l54  'coffin light - special
  2792.     nFadeL 54, L54
  2793.     FlashC 55, L55n
  2794.     FlashC 56, l56n ' lock light - special
  2795.     Flashm 56, l56a ' lock light - special
  2796.     FlashC 57, L57n
  2797.     FlashC 58, L58n
  2798.  
  2799.     If Not Proto then NFadeLmM 61, FlSkull2_3
  2800.     If Not Proto then NFadeLmM 61, FlSkull2_4
  2801.     FlashC 61, L61n
  2802.  
  2803.     If Not Proto then NFadeLmM 62, FlSkull2_5
  2804.     If Not Proto then NFadeLmM 62, FlSkull2_6
  2805.     FlashC 62, L62n 'Top skull
  2806.  
  2807.     If Not Proto then NFadeLmM 63, FlSkull2_1
  2808.     If Not Proto then NFadeLmM 63, FlSkull2_2
  2809.     FlashC 63, L63n
  2810.  
  2811.     nFlashW 64, l64
  2812.     nFlashW 65, l65
  2813.     nFlashW 66, l66
  2814.     nFlashW 67, l67
  2815.     nFlashW 68, l68
  2816.  
  2817.     nFlashW 71, l71
  2818.     nFlashW 72, l72
  2819.     nFlashW 73, l73
  2820.     nFlashW 74, l74
  2821.     nFlashW 75, l75
  2822.     nFlashW 76, l76
  2823.     nFlashW 77, l77
  2824.     nFlashW 78, l78
  2825.  
  2826.     nFlashW 81, l81
  2827.     nFlashW 82, l82
  2828.     nFlashW 83, l83
  2829. ' Skull Lanes
  2830.  
  2831.     FlashC 84, L84_1
  2832.     FLashm 84, L84_2
  2833.     FLashm 84, L84_0
  2834.     Flashm 84, l84n
  2835.     FlashC 85, L85r
  2836.     Flashm 85, l85n
  2837.     FlashC 86, L86r
  2838.     Flashm 86, l86n
  2839.  
  2840.     '87 - Buy In Button (Pre-production rom only)
  2841.  
  2842.     if Proto then
  2843.         nFadeL 18, Lbolt1 'Left Bolt
  2844.         nFadeL 31, L18 'ramp Left eye
  2845.         nFadeL 32, L44 'ramp Right eye 
  2846.         nFadeL 33, Lbolt2 'Right Bolt
  2847.         nFadeL 34, LCandle1'Left Candle (backglass?)
  2848.         nFadeL 44, LCandle2'Right Candle (backglass?)
  2849.  
  2850.  
  2851.  
  2852.         'These lamps don't work right now
  2853.         '---------------------------------
  2854.         nFadeL 91, l34  'crate eyes, right to left
  2855.         nFadeLm 91, L34a
  2856.         nFadeL 92, l33
  2857.         nFadeLm 92, L33a
  2858.         nFadeL 93, l32
  2859.         nFadeLm 93, L32a
  2860.         nFadeL 94, l31
  2861.         nFadeLm 94, L31a
  2862.  
  2863.  
  2864.         'Skull LEDs
  2865.         'bottom to top / left to right... (not sure the correct order)
  2866. '       nFadeL 95, FlSkull2_5'#11
  2867. '       nFadeL 96, FlSkull2_6'#12      
  2868. '       nFadeL 97, FlSkull2_4'#10
  2869. '       nFadeL 98, FlSkull2_3'#9
  2870. '       nFadeL 101, FlSkull6_2'#6
  2871. '       nFadeL 102, FlSkull6_1'#5
  2872. '       nFadeL 103, FlSkull5_2  '#4
  2873. '       nFadeL 104, FlSkull5_1  '#3
  2874. '       nFadeL 105, FlSkull4_2  '#2
  2875. '       nFadeL 106, FlSkull4_1  '#1
  2876. '       nFadeL 107, FlSkull2_1'#7
  2877. '       nFadeL 108, FlSkull2_2'#8
  2878.         'Top to bottom, left to right...
  2879.         nFadeL 95,  FlSkull6_1'#11
  2880.         nFadeL 96,  FlSkull6_2'#12     
  2881.         nFadeL 97,  FlSkull5_2'#10
  2882.         nFadeL 98,  FlSkull5_1'#9
  2883.         nFadeL 1, FlSkull2_4'#6
  2884.         nFadeL 2, FlSkull2_3'#5
  2885.         nFadeL 3, FlSkull2_2'#4
  2886.         nFadeL 4,   FlSkull2_1'#3
  2887.         nFadeL 5,   FlSkull2_6'#2
  2888.         nFadeL 6, FlSkull2_5'#1
  2889.         nFadeL 7, FlSkull4_1'#7
  2890.         nFadeL 8, FlSkull4_2'#8
  2891.         '--------------------------------
  2892.     End If
  2893.  
  2894. End sub
  2895.  
  2896. Sub TBF_timer():me.text = "GiStep:" & gistep & vbnewline & "Desired LUT:" & DesiredGI & vbnewline & " GiFadeStep:" & GiFadeStep _
  2897.                          & vbnewline & "fadinglevel" & FadingLevel(199) & vbnewline & "lampstate" & lampstate(199) & vbnewline & LUTtimer.enabled & vbnewline & Table1.ColorGradeImage: End Sub
  2898.  
  2899.  
  2900. Sub AllLampsOff 'debug
  2901.    Dim x
  2902.     For x = 0 to 340
  2903.         SetLamp x, 0
  2904.     Next
  2905. End Sub
  2906.  
  2907. Sub SetLamp(nr, value)
  2908.     If value <> LampState(nr) Then
  2909.         LampState(nr) = abs(value)
  2910.         FadingLevel(nr) = abs(value) + 4
  2911.     End If
  2912. End Sub
  2913.  
  2914. Sub SetLampm(nr, nr2, value)    'set 2 lamps
  2915.    If value <> LampState(nr) Then
  2916.         LampState(nr) = abs(value)
  2917.         FadingLevel(nr) = abs(value) + 4
  2918.     End If
  2919.     If value <> LampState(nr2) Then
  2920.         LampState(nr2) = abs(value)
  2921.         FadingLevel(nr2) = abs(value) + 4
  2922.     End If
  2923. End Sub
  2924.  
  2925. Sub SetLampmm(nr, nr2, nr3, value)  'set 3 lamps
  2926.    If value <> LampState(nr) Then
  2927.         LampState(nr) = abs(value)
  2928.         FadingLevel(nr) = abs(value) + 4
  2929.     End If
  2930.     If value <> LampState(nr2) Then
  2931.         LampState(nr2) = abs(value)
  2932.         FadingLevel(nr2) = abs(value) + 4
  2933.     End If
  2934.     If value <> LampState(nr3) Then
  2935.         LampState(nr3) = abs(value)
  2936.         FadingLevel(nr3) = abs(value) + 4
  2937.     End If
  2938. End Sub
  2939.  
  2940. Sub NFadeL(nr, object)
  2941.     Select Case FadingLevel(nr)
  2942.         Case 3:object.state = 0:FadingLevel(nr) = 0
  2943.         Case 4:object.state = 0:FadingLevel(nr) = 3
  2944.         Case 5:object.state = 1:FadingLevel(nr) = 6
  2945.         Case 6:object.state = 1:FadingLevel(nr) = 1
  2946.     End Select
  2947. End Sub
  2948.  
  2949.  
  2950. Sub NFadeLm(nr, object) ' used for multiple lights
  2951.    Select Case FadingLevel(nr)
  2952.         Case 3:object.state = 0
  2953.         Case 4:object.state = 0
  2954.         Case 5:object.state = 1
  2955.         Case 6:object.state = 1
  2956.     End Select
  2957. End Sub
  2958.  
  2959. Sub NFadeLmM(nr, object) ' used for multiple lights, Mod
  2960.     if SkullLEDMod = 0 then Exit Sub
  2961.     Select Case FadingLevel(nr)
  2962.         Case 4:object.state = 0
  2963.         Case 5:object.state = 1
  2964.     End Select
  2965. End Sub
  2966.  
  2967. Sub nFlashW(nr, object) 'simple flashing light for wheel
  2968.    Select Case FadingLevel(nr)
  2969.         Case 4 'off
  2970.              object.intensityscale = 0.5
  2971.              FadingLevel(nr) = 0
  2972.         Case 5 ' on
  2973.              object.intensityscale = 3
  2974.              FadingLevel(nr) = 1
  2975.     End Select
  2976. End Sub
  2977.  
  2978.  
  2979.  
  2980. '***************
  2981.  
  2982. '***************
  2983. '* Triggers and Switches
  2984. '***************
  2985. 'vpmCreateEvents Triggers
  2986.  
  2987. sub sw16_hit():controller.Switch(16) = 1:end sub        'Kickback
  2988. sub sw16_unhit():controller.Switch(16) = 0:end sub
  2989. sub sw17_hit():controller.Switch(17) = 1:end sub        'Right Flipper Lane
  2990. sub sw17_unhit():controller.Switch(17) = 0:end sub
  2991.  
  2992. dim BallInPlunger :BallInPlunger = False
  2993. sub PlungerLane_hit():ballinplunger = True: End Sub
  2994. Sub PlungerLane_unhit():BallInPlunger = False : End Sub
  2995.  
  2996. sub sw18_hit():controller.Switch(18) = 1:end sub        'Shooter Lane
  2997. sub sw18_unhit():controller.Switch(18) = 0:end sub
  2998.  
  2999. sub sw25_hit():controller.Switch(25) = 1:end sub        'Extra Ball Lane
  3000. sub sw25_unhit():controller.Switch(25) = 0:end sub
  3001. sub sw26_hit():controller.Switch(26) = 1:end sub        'Left Flipper Lane
  3002. sub sw26_unhit():controller.Switch(26) = 0:end sub
  3003. sub sw27_hit():controller.Switch(27) = 1:end sub        'Right Outlane
  3004. sub sw27_unhit():controller.Switch(27) = 0:end sub
  3005. sub sw28_hit():vpmTimer.PulseSw 28:end sub      'Right Standup
  3006. 'sub sw28_unhit():controller.Switch(28) = 0:end sub
  3007.  
  3008. sub sw38_hit():controller.Switch(38) = 1:end sub        'Crate Enter
  3009. sub sw38_unhit():controller.Switch(38) = 0:end sub
  3010.  
  3011. sub sw41_hit():controller.Switch(41) = 1:end sub        'Coffin left
  3012. sub sw41_unhit():controller.Switch(41) = 0:end sub
  3013. sub sw42_hit():controller.Switch(42) = 1:end sub        'Coffin middle
  3014. sub sw42_unhit():controller.Switch(42) = 0:end sub
  3015. sub sw43_hit():controller.Switch(43) = 1:end sub        'Coffin right
  3016. sub sw43_unhit():controller.Switch(43) = 0:end sub
  3017. sub sw44_hit():controller.Switch(44) = 1: end sub       'Left Ramp Entry
  3018. sub sw44_unhit():controller.Switch(44) = 0:end sub
  3019. sub sw46_hit() :controller.Switch(46) = 1:end sub       'Left Ramp Made
  3020. sub sw46_unhit():controller.Switch(46) = 0:end sub
  3021. 'Sub LeftRampEnd_Hit():playsound "drop_mono", 0, LVL(0.5), 0.05:end sub
  3022.  
  3023. sub sw45_hit():controller.Switch(45) = 1:end sub        'Right Ramp Enter
  3024. sub sw45_unhit():controller.Switch(45) = 0:end sub
  3025. sub sw47_hit():controller.Switch(47) = 1:end sub        'Right Ramp Made
  3026. sub sw47_unhit():controller.Switch(47) = 0:end sub
  3027. 'Sub RightRampEnd_Hit():playsound "drop_mono", 0, LVL(0.5), -0.05   :end sub'name,loopcount,volume,pan,randompitch
  3028.  
  3029. 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
  3030. Sub RHelp1_Timer():me.timerenabled = 0:end sub
  3031.  
  3032. 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
  3033. Sub RHelp2_Timer():me.timerenabled = 0:end sub
  3034.  
  3035. '- moved these to light sequence area
  3036.  
  3037. Sub LeftSlingShot_Slingshot():me.timerenabled = True : controller.Switch(51) = 1    :   End Sub
  3038. Sub LeftSlingShot_Timer()   :   me.timerenabled = False : controller.Switch(51) = 0 :   End Sub
  3039. Sub RightSlingShot_Slingshot():me.timerenabled = True : controller.Switch(52) = 1   :   End Sub
  3040. Sub RightSlingShot_Timer()  :   me.timerenabled = False : controller.Switch(52) = 0 :   End Sub
  3041.  
  3042.  
  3043. Sub SolBumper1(enabled)
  3044.     If enabled Then
  3045.         if BumperArea.BallCntOver > 0 then Exit Sub 'bumper hack
  3046.         Bumper1.PlayHit()
  3047.         PlaySound SoundFX("TopBumper_Hit",DOFContactors), 0, LVL(0.3), 0.053, 0.1
  3048.     End If
  3049. End Sub
  3050.  
  3051. Sub SolBumper2(enabled)
  3052.     If enabled Then
  3053.         if BumperArea.BallCntOver > 0 then Exit Sub 'bumper hack
  3054.         Bumper2.PlayHit()
  3055.         PlaySound SoundFX("LeftBumper_Hit",DOFContactors), 0, LVL(0.3), 0.043, 0.1
  3056.     End If
  3057. End Sub
  3058.  
  3059. Sub SolBumper3(enabled)
  3060.     If enabled Then
  3061.         if BumperArea.BallCntOver > 0 then Exit Sub 'bumper hack
  3062.         Bumper3.PlayHit()
  3063.         PlaySound SoundFX("RightBumper_Hit",DOFContactors), 0, LVL(0.3), 0.053, 0.1
  3064.     End If
  3065. End Sub
  3066.  
  3067. sub Bumper1_hit()   'Upper Jet
  3068.     vpmtimer.PulseSw 53
  3069.     Bumper1.PlayHit()
  3070.     PlaySound SoundFX("TopBumper_Hit",DOFContactors), 0, LVL(0.3), 0.053, 0.1
  3071. end sub
  3072.  
  3073. sub Bumper2_hit()       'Center Jet
  3074.     vpmtimer.PulseSw 54
  3075.     Bumper2.PlayHit()
  3076.     PlaySound SoundFX("LeftBumper_Hit",DOFContactors), 0, LVL(0.3), 0.043, 0.1
  3077. end sub
  3078.  
  3079. sub Bumper3_hit()       'Lower Jet
  3080.     vpmtimer.PulseSw 55
  3081.     Bumper3.PlayHit()
  3082.     PlaySound SoundFX("RightBumper_Hit",DOFContactors), 0, LVL(0.3), 0.053, 0.1
  3083. end sub
  3084. '*****************************
  3085.  
  3086. 'Sub SW56_SlingShot():vpmTimer.PulseSw 56:End Sub   'Upper slingshot
  3087. Sub SW56_SlingShot()
  3088.     vpmTimer.PulseSw 56
  3089.     PlaySound SoundFX("LeftSlingShotTrimmed",DOFContactors), 0, LVL(0.3), -0.005, 0.2
  3090.     Setlamp cTopSling, 1
  3091. End Sub
  3092.  
  3093. sub sw57_hit()  'Crate Sensor. Crate spinner also trips this switch
  3094.     controller.Switch(57) = 1
  3095.     TiCratesw.Timerinterval=1200    'may help
  3096.  
  3097.     dim finalspeed : finalspeed=BallVel(activeball)'SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  3098.     If finalspeed > 12 then
  3099.         playsound "woodhitaluminium", 0, LVL(Vol(ActiveBall)*5), Pan(ActiveBall), 0, SlopeIt(finalspeed, 12,12500, 23,19000), 1, 0
  3100.     Elseif finalspeed > 1 then
  3101.         playsound "metalhit2", 0, LVL(Vol(ActiveBall)*5), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  3102.     End If
  3103.     'tb.text = finalspeed
  3104. end sub
  3105.  
  3106.  
  3107.  
  3108.  
  3109. sub sw57_unhit():controller.Switch(57) = 0:end sub
  3110. sub sw58_hit():controller.Switch(58) = 1:end sub    'Left Loop
  3111. sub sw58_unhit():controller.Switch(58) = 0:end sub
  3112.  
  3113. sub sw61_hit():vpmTimer.PulseSw 61:end sub  'Three bank upper
  3114. sub sw62_hit():vpmTimer.PulseSw 62:end sub  'Three bank middle
  3115. sub sw63_hit():vpmTimer.PulseSw 63:end sub  'Three bank lower
  3116.  
  3117. sub Col_Rubber_Band_sw67_hit():controller.Switch(67) = 1:end sub    'Left Ramp 10 point
  3118. sub Col_Rubber_Band_sw67_unhit():controller.Switch(67) = 0:end sub
  3119. sub sw68_hit():controller.Switch(68) = 1:end sub    'Right Loop
  3120. sub sw68_unhit():controller.Switch(68) = 0:end sub
  3121.  
  3122. sub sw71_hit():controller.Switch(71) = 1:end sub    'Left Skull Lane
  3123. sub sw71_unhit():controller.Switch(71) = 0:end sub
  3124. sub sw72_hit():controller.Switch(72) = 1:end sub    'Center Skull Lane
  3125. sub sw72_unhit():controller.Switch(72) = 0:end sub
  3126. sub sw73_hit():controller.Switch(73) = 1:end sub    'Right Skull Lane
  3127. sub sw73_unhit():controller.Switch(73) = 0:end sub
  3128. sub sw74_hit():controller.Switch(74) = 1:end sub    'Secret Passage
  3129. sub sw74_unhit():controller.Switch(74) = 0:end sub
  3130.  
  3131. Sub Drain_Hit()
  3132.     PLaySound "ball_trough", 0, LVL(0.06)
  3133.     bsTrough.AddBall Me
  3134.     BIP = BIP - 1
  3135. End Sub
  3136.  
  3137.  
  3138. Sub CoffinEntrance_Hit()    'important for lock / multiball start routines
  3139.     vpmTimer.PulseSw 48
  3140.     PlaySound "Scoop_Enter2", 0, LVL(0.5), -0.03, 0.1
  3141.     bsCoffin.Addball Me
  3142.     BIP = BIP - 1
  3143. End Sub
  3144.  
  3145.  
  3146. '****************
  3147. '* Hole Handling by nFozzy
  3148. '****************
  3149.  
  3150. 'Method:
  3151. 'Replicates square holes in the playfield by using square triggers to enable kickers
  3152. 'Some use two triggers to better emulate the square shape of the holes
  3153.  
  3154. '-------------
  3155. 'Crate
  3156. '-------------
  3157. 'Uses fallthrough holes and a submarine switch
  3158. 'The crate switch, sw38, is handled by automatic switch handling
  3159.  
  3160. 'sub CrateTrigger_hit() 'star-shaped
  3161. '   CrateHole1.Enabled = 1
  3162. '   CrateHole2.Enabled = 1
  3163. '   CrateHole3.Enabled = 1
  3164. '   CrateHole4.Enabled = 1
  3165. 'end sub
  3166. '
  3167. 'Sub CrateHole1_Hit()
  3168. '   me.enabled = 0
  3169. 'end sub
  3170. 'sub CrateTrigger_Unhit()   'square
  3171. '   CrateHole1.Enabled = 0
  3172. '   CrateHole2.Enabled = 0
  3173. '   CrateHole3.Enabled = 0
  3174. '   CrateHole4.Enabled = 0
  3175. 'end sub
  3176.  
  3177. Sub cratetrigger_hit()
  3178.     activeball.z = -30
  3179.     activeball.vely = activeball.vely * 0.5
  3180.     activeball.velz = 0
  3181.     playsound "Trough3", 0, LVL(Vol(ActiveBall) ), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  3182. end Sub
  3183.  
  3184. Sub cratetrigger2_hit() 'catches stuck balls. hopefully temporary
  3185.     activeball.z = -35
  3186. end Sub
  3187.  
  3188. sub sw37_dropwall_hit()
  3189.     if bsLeftKick.balls > 0 then playsound "fx_collide", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall)
  3190. end sub
  3191.  
  3192.  
  3193. sub cratetriggerexit_unhit()
  3194.  
  3195. end sub
  3196.  
  3197. '-------------
  3198. 'Crate Kickout / Skillshot
  3199. '-------------
  3200.  
  3201. sub sw37Trigger_hit():sw37a.enabled = 1:end sub
  3202. sub sw37Trigger_unhit():sw37a.enabled = 0:end sub
  3203.  
  3204. Dim aBalla, aBallb, aBallc
  3205. Dim aZpos
  3206. Sub sw37a_Hit()
  3207.     Set aBalla = ActiveBall
  3208.     aZpos = 50
  3209.     Me.TimerInterval = 2
  3210.     Me.TimerEnabled = 1
  3211.     me.enabled = 0
  3212.     sw37_dropwall.isdropped = 0
  3213. end sub
  3214.  
  3215. Sub sw37a_Timer
  3216.     aBalla.Z = aZpos
  3217.     aZpos = aZpos-2
  3218.     If aZpos <0 Then    '40
  3219.         Me.TimerEnabled = 0
  3220.         Me.DestroyBall
  3221.         if bsLeftKick.balls > 0 then playsound "fx_collide", 0, LVL(0.3), -0.01
  3222.         bsLeftKick.AddBall Me
  3223.         PlaySound "Scoop_Enter", 0, LVL(0.3), -0.005, 0.1
  3224.     End If
  3225. end sub
  3226.  
  3227.  
  3228. Sub sw37_Hit()                                          'left kickout from crate
  3229. '   PlaySound "Scoop_Enter", 0, LVL(1), -0.2, 0.2
  3230.     sw37_dropwall.isdropped = 0
  3231.     Me.DestroyBall
  3232.     bsLeftKick.AddBall Me
  3233. End Sub
  3234.  
  3235. Sub SolCrateKickout(Enabled)    'Solenoid Callback
  3236. '   If Enabled Then
  3237. '       If bsLeftKick.Balls Then
  3238. '           bsLeftKick.ExitSol_On
  3239. '       End If
  3240. '   End If
  3241.  
  3242. '   sw37a.enabled = 0       'turns off the entry kicker for kickout
  3243. '   sw37Trigger.timerinterval = 150
  3244. '   sw37Trigger.timerenabled = 1
  3245. '       .InitExitSnd SoundFX("Kicker_Release",DOFContactors), SoundFX("FlipperUpLeft",DOFContactors)
  3246.     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
  3247.     bsLeftKick.ExitSol_On
  3248.     sw37_dropwall.isdropped = 1
  3249. End Sub
  3250.  
  3251. 'Sub sw37Trigger_Timer()    'actually don't think this is necessary. The default state of the fallthrough kicker should be 0!
  3252. '   sw37a.enabled = 1
  3253. '   me.timerenabled = 0
  3254. 'end sub
  3255.  
  3256. '-------------
  3257. 'Spider hole
  3258. '-------------
  3259.  
  3260. 'The players:
  3261. 'Prim_RampDiverter2 --- animated primitive
  3262. 'RampGateFlipper ---    for animation, goes from 0 to -40
  3263. 'sw36           ---     the kicker (not enabled!)
  3264. 'sw36a and sw36b ---    top kicker and bottom kicker, respectively
  3265. 'sw36trigger     ---    rectangular Trigger
  3266. 'sw36triggerexit ---    big star-shaped trigger
  3267. 'RaLeft_Closed  ---     ramp gate when open
  3268. 'RaLeft_Open    ---     ramp gate when closed
  3269.  
  3270.  
  3271.                         'Square triggers enabling the hole
  3272. sub sw36trigger_hit():sw36a.enabled=1:sw36b.enabled=1:end sub
  3273. sub sw36triggerexit_unhit():sw36a.enabled=0:sw36b.enabled=0:end sub
  3274.  
  3275. Sub sw36a_Hit()         'Holes themselves
  3276.     Set aBallb = ActiveBall
  3277.     aZpos = 60          'lil deeper
  3278.     Me.TimerInterval = 2
  3279.     Me.TimerEnabled = 1
  3280.     me.enabled = 0
  3281. end sub
  3282.  
  3283. Sub sw36a_Timer
  3284.     aBallb.Z = aZpos
  3285.     aZpos = aZpos-2
  3286.     If aZpos <0 Then    '40
  3287.         Me.TimerEnabled = 0
  3288.         Me.DestroyBall
  3289.         bsSpider.AddBall Me
  3290. '       CheckMultiballTimer.enabled = 1     'for multiball start award (might not work)
  3291. '       CheckMultiballTimer.enabled = 600
  3292. '       CrateSeqHelp = 1
  3293. '       SpiderLockSequenceChecker.enabled = 1
  3294.         PlaySound "Trough1", 0, LVL(0.2), 0.03, 0.1
  3295.     End If
  3296. end sub
  3297.  
  3298. Sub sw36b_Hit()         'Holes themselves
  3299.     Set aBallc = ActiveBall
  3300.     aZpos = 50
  3301.     Me.TimerInterval = 2
  3302.     Me.TimerEnabled = 1
  3303.     me.enabled = 0
  3304. end sub
  3305.  
  3306. Sub sw36b_Timer
  3307.     aBallc.Z = aZpos
  3308.     aZpos = aZpos-2
  3309.     If aZpos <0 Then    '40
  3310.         Me.TimerEnabled = 0
  3311.         Me.DestroyBall
  3312.         bsSpider.AddBall Me
  3313. '       CrateSeqHelp = 1
  3314. '       SpiderLockSequenceChecker.enabled = 1
  3315.         PlaySound "Trough2", 0, LVL(0.2), 0.03, 0.1
  3316.     End If
  3317. end sub
  3318.  
  3319.  
  3320.  
  3321. 'Solenoid Callback
  3322. Sub SolSpiderPopper(Enabled)
  3323.     If Enabled Then
  3324.         If bsSpider.Balls Then
  3325.             if FSSpiderenabled then setlamp cSpiderFade, 0
  3326.             bsSpider.ExitSol_On
  3327.             Playsound SoundFX("Kicker_Release",DOFContactors), 0, LVL(0.2), 0.03, 0.1
  3328.             RaLeft_Closed.collidable = 0
  3329.             RaLeft_Open.collidable = 1
  3330.             sw36a.enabled = 0
  3331.             sw36b.enabled = 0
  3332. '           sw36trigger.enabled = 0 'necessary?
  3333.             sw36.timerinterval = 75     'Closes the gate again after a timer
  3334.             sw36.timerenabled = 1       'Closes the gate again after a timer
  3335.             RampGateFlipper.timerinterval = -1
  3336.             RampGateFlipper.timerenabled = 1
  3337. '           RampGateFlipper.CurrentAngle = RampGateFlipper.CurrentAngle -0.01
  3338.             RampGateFlipper.rotatetoend
  3339.  
  3340. '           SpiderLockSequenceChecker.enabled = 0
  3341.  
  3342. '           sw36.Enabled = 0 'disable the kicker to do not accept more balls during the animation
  3343. '           Set spiderBall = sw36a.Createball
  3344. '           spiderZpos = 0
  3345. '           sw36a.TimerInterval = 1
  3346. '           sw36a.TimerEnabled = 1
  3347.         End If
  3348.     End If
  3349. End Sub
  3350.  
  3351. sub RampGateFlipper_Timer() 'Animates ramp popper gate
  3352. '   if rampgateflipper.timerinterval = 50 then  RampGateFlipper.rotatetoend:RampGateFlipper.timerinterval = 16      'timer is both a delay and a 16ms update
  3353. '   if RampGateFlipper.Timerinterval = 16 and RampGateFlipper.CurrentAngle < -39 then rampgateflipper.timerinterval = 35:
  3354. '   if RampGateFlipper.Timerinterval = 35 and RampGateFlipper.CurrentAngle < -39 then rampgateflipper.timerinterval = 50
  3355.     'todo optimize
  3356.     Prim_RampDiverter2.RotX = RampGateFlipper.currentangle
  3357.     if RampGateFlipper.CurrentAngle = RampGateFlipper.StartAngle then me.Enabled = 0    'todo this might not work
  3358. '   if RampGateFlipper.CurrentAngle < -39 then rampgateflipper.rotatetostart end if
  3359. '   if RampGateFlipper.currentangle > -1 then
  3360. end sub
  3361.  
  3362.  
  3363.  
  3364.  
  3365. sub sw36_Timer()        'Closes the gate again after a timer
  3366. '   sw36trigger.enabled = 1
  3367.     RampGateFlipper.rotatetostart
  3368.     RaLeft_Closed.collidable = 1
  3369.     RaLeft_Open.collidable = 0
  3370.     if sw36.timerinterval = 750 then me.timerenabled = 0:RampGateFlipper.timerenabled = 0   'disables both timers
  3371.     if sw36.timerinterval = 75 then sw36.timerinterval = 750    'reuses the timer for disabling updates after 3/4s of a second
  3372. end sub
  3373.  
  3374.  
  3375.  
  3376. '****************
  3377. '* Animations
  3378. '* Rstep and Lstep  are the variables that increment the animation
  3379. '****************
  3380. dim FrogDir1, frogdir2, frogdir3
  3381. frogdir1 = 1
  3382. frogdir2 = 1
  3383. frogdir3 = 1
  3384.  
  3385.  
  3386. Sub sw64_Hit                'Left leaper
  3387.     Frog1Vel = SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  3388.     vpmTimer.PulseSw 64
  3389. '   tb.text = frog1vel
  3390.     sw64t.Enabled = 1
  3391.     Playsound SoundFX("LockupPin",DOFTargets), 0, LVL(0.1), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0
  3392. End Sub
  3393. Sub sw65_Hit                'Center Leaper
  3394.     vpmTimer.PulseSw 65
  3395.     Frog2Vel = SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  3396.     sw65t.Enabled = 1
  3397.     Playsound SoundFX("LockupPin",DOFTargets), 0, LVL(0.1), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0
  3398. End Sub
  3399. Sub sw66_Hit                'Right Leaper
  3400.     vpmTimer.PulseSw 66
  3401.     Frog3Vel = SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  3402.     sw66t.Enabled = 1
  3403.     Playsound SoundFX("LockupPin",DOFTargets), 0, LVL(0.1), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0
  3404. End Sub
  3405.  
  3406.  
  3407. 'ideal rotations?
  3408. 'prfrog 1:
  3409. '-40  to 20
  3410. 'prfrog2:
  3411. '-60 to 20
  3412. 'prfrog3:
  3413. '-20 to 60
  3414.  
  3415.  
  3416. Dim Dir1, chdir1, updown1, slowmo
  3417. slowmo = 1'.98                                              'Make this number lower for slow-mo frogs
  3418. Dir1 = 1
  3419. updown1 = 1
  3420. ChDir1 = 0
  3421. Sub Sw64t_Timer()
  3422. dim rotdir
  3423.     If updown1 = -1 AND ChDir1 = 0 Then ChDir1 = 1
  3424.     If ChDir1 = 1 Then
  3425.         If PrLeaper1.Z >= 160 Then PlaySound "metalhit2", 0, LVL(0.1), -0.5, 0:ChDir1 = 2
  3426.         If PrLeaper1.Z >= 155 AND PrLeaper1.Z < 160 Then PlaySound "metalhit2", 0, LVL(0.1), -0.01, 0:ChDir1 = 2
  3427.         If PrLeaper1.Z >= 150 AND PrLeaper1.Z < 155 Then PlaySound "metalhit2", 0, LVL(0.05), -0.01, 0:ChDir1 = 2
  3428.     End If
  3429.     PrLeaper1.Z = dSin(dir1) * Frog1Vel * 2 + 55
  3430.  
  3431.     if PrLeaper1.Rotz > 20 then
  3432. '       frogdir1 = -1
  3433.         frogdir1 = 1
  3434.     elseif prleaper1.rotz < -40 Then
  3435.         frogdir1 = 1
  3436.     end if
  3437.  
  3438. '   PrLeaper1.RotZ = PrLeaper1.RotZ + (Frog1Vel * 0.005 * frogdir1) 'simple rotation
  3439.     PrLeaper1.RotZ = PrLeaper1.RotZ + (Frog1Vel * 0.05 * frogdir1)  'simple rotation
  3440.     If dir1 >= 80 Then updown1 = -1
  3441. '   debug.Print dir1
  3442.     dir1 = dir1 + dCos(dir1) * updown1 * slowmo
  3443.     If PrLeaper1.Z <= 55 Then
  3444.         PrLeaper1.Z = 55
  3445.         Me.Enabled = 0
  3446.         Dir1 = 1
  3447.         ChDir1 = 0
  3448.         updown1 = 1
  3449.     End If
  3450. End Sub
  3451.  
  3452. Dim Dir2, chdir2, updown2
  3453. Dir2 = 1
  3454. updown2 = 1
  3455. ChDir2 = 0
  3456. Sub Sw65t_Timer()
  3457.     If updown2 = -1 AND ChDir2 = 0 Then ChDir2 = 1
  3458.     If ChDir2 = 1 Then
  3459.         If PrLeaper2.Z >= 160 Then PlaySound "metalhit2", 0, LVL(0.1), -0.2, 0:ChDir2 = 2
  3460.         If PrLeaper2.Z >= 155 AND PrLeaper2.Z < 160 Then PlaySound "metalhit2", 0, LVL(0.1), 0, 0:ChDir2 = 2
  3461.         If PrLeaper2.Z >= 150 AND PrLeaper2.Z < 155 Then PlaySound "metalhit2", 0, LVL(0.05), 0, 0:ChDir2 = 2
  3462.     End If
  3463.     PrLeaper2.Z = dSin(dir2) * Frog2Vel * 2 + 55
  3464.  
  3465.     if PrLeaper2.Rotz > 40 then
  3466. '       frogdir2 = -1
  3467.         frogdir2 = 1
  3468.     elseif prleaper2.rotz < -60 Then
  3469.         frogdir2 = 1
  3470.     end if
  3471.  
  3472.     PrLeaper2.RotZ = PrLeaper2.RotZ + (Frog2Vel * 0.05 * frogdir2)
  3473.     If dir2 >= 80 Then updown2 = -1
  3474.     dir2 = dir2 + dCos(dir2) * updown2 * slowmo
  3475.     If PrLeaper2.Z <= 55 Then
  3476.         PrLeaper2.Z = 55
  3477.         Me.Enabled = 0
  3478.         Dir2 = 1
  3479.         ChDir2 = 0
  3480.         updown2 = 1
  3481.     End If
  3482. End Sub
  3483.  
  3484. Dim Dir3, chdir3, updown3
  3485. Dir3 = 1
  3486. updown3 = 1
  3487. ChDir3 = 0
  3488. Sub Sw66t_Timer()
  3489.     If updown3 = -1 AND ChDir3 = 0 Then ChDir3 = 1
  3490.     If ChDir3 = 1 Then
  3491.         If PrLeaper3.Z >= 160 Then PlaySound "metalhit2", 0, LVL(0.1), 0.4, 0:ChDir3 = 2
  3492.         If PrLeaper3.Z >= 155 AND PrLeaper3.Z < 160 Then PlaySound "metalhit2", 0, LVL(0.08), 0.01, 0:ChDir3 = 2
  3493.         If PrLeaper3.Z >= 150 AND PrLeaper3.Z < 155 Then PlaySound "metalhit2", 0, LVL(0.05), 0.01, 0:ChDir3 = 2
  3494.     End If
  3495.     PrLeaper3.Z = dSin(dir3) * Frog3Vel * 2 + 55
  3496.     if PrLeaper3.Rotz > 60 then
  3497. '       frogdir3 = -1
  3498.         frogdir3 = 1
  3499.     elseif prleaper3.rotz < -20 Then
  3500.         frogdir3 = 1
  3501.     end if
  3502.     PrLeaper3.RotZ = PrLeaper3.RotZ + (Frog3Vel * 0.05 * frogdir3)
  3503.     If dir3 >= 80 Then updown3 = -1
  3504.     dir3 = dir3 + dCos(dir3) * updown3 * slowmo
  3505.     If PrLeaper3.Z <= 55 Then
  3506.         PrLeaper3.Z = 55
  3507.         Me.Enabled = 0
  3508.         Dir3 = 1
  3509.         ChDir3 = 0
  3510.         updown3 = 1
  3511.     End If
  3512. End Sub
  3513.  
  3514.  
  3515. '*****************
  3516. '* Maths Functions
  3517. '*****************
  3518. Dim Pi
  3519. Pi = Round(4 * Atn(1), 6)
  3520. Function dSin(degrees)
  3521.     dsin = sin(degrees * Pi/180)
  3522.     if ABS(dSin) < 0.000001 Then dSin = 0
  3523.     if ABS(dSin) > 0.999999 Then dSin = 1' * sgn(dSin)
  3524. End Function
  3525.  
  3526. Function dCos(degrees)
  3527.     dcos = cos(degrees * Pi/180)
  3528.     if ABS(dCos) < 0.000001 Then dCos = 0
  3529.     if ABS(dCos) > 0.999999 Then dCos = 1' * sgn(dCos)
  3530. End Function
  3531.  
  3532. Function dTan(degrees)
  3533.     dTan = tan(degrees*Pi/180)
  3534.     If ABS(dTan) < 0.000001 AND ABS(dTan) > -0.000001 Then dTan = 0
  3535. '   If ABS(dTan) > 0.999999 Then dTan = 1'*sgn(dTan)
  3536. End Function
  3537. '*****************
  3538.  
  3539. '*****************
  3540. '* Timers
  3541. '*****************
  3542.  
  3543. 'Redesigned Crate Door -nf
  3544. '
  3545. 'Trigger in front of the crate turns on/off the prim update timer
  3546. 'sub TiCratesw_Hit():TiCrate.enabled = 1:Me.Timerinterval=1200:Me.timerenabled = 1:end sub
  3547. 'Sub TiCratesw_Timer():TiCrate.Enabled = 0:Me.timerenabled = 0:end sub  'disables update after an interval
  3548. sub TiCratesw_Hit():FadingLevel(cCrate) = 5:Me.Timerinterval=2000:Me.timerenabled = 1:end sub
  3549. Sub TiCratesw_Timer():FadingLevel(cCrate) = 0:Me.timerenabled = 0:end sub   'disables update after an interval
  3550. 'sw57a
  3551.  
  3552. crateopen = False
  3553.  
  3554.  
  3555. 'Sub TiCrate_Timer()    'updates door
  3556. '   if CrateOpen = False Then
  3557. ''  if sw57.isdropped = True Then
  3558. '       PrCrateDoor.RotX = -CrateSpinner_Closed.CurrentAngle
  3559. '   Else
  3560. '       PrCrateDoor.RotX = -CrateSpinner_Open.CurrentAngle
  3561. '   end if
  3562. '   if PrCrateDoor.RotX < -5 then controller.switch(57) = 1 else controller.Switch(57) = 0
  3563. 'End SUb
  3564.  
  3565. Sub UpdateCrate(nr)
  3566.     Select Case FadingLevel(nr)
  3567.         case 5
  3568.             if CrateOpen = False Then
  3569.                 PrCrateDoor.RotX = -CrateSpinner_Closed.CurrentAngle
  3570.             Else
  3571.                 PrCrateDoor.RotX = -CrateSpinner_Open.CurrentAngle
  3572.             end if
  3573.             if PrCrateDoor.RotX < -5 then controller.switch(57) = 1 else controller.Switch(57) = 0
  3574.     End Select
  3575. End Sub
  3576.  
  3577.  
  3578.  
  3579. sub UpdateCadaver(nr)
  3580.     Select Case FadingLevel(nr)
  3581.         case 5 :    PrCadaver.RotX = CadaverSpinner.CurrentAngle - 30
  3582.     end Select
  3583. End Sub
  3584.  
  3585. sub CoffinKicker_Timer()    'starts with bscoffin.exitsol. 1500ms shut off Prcadaver tracking
  3586.     me.enabled = 0
  3587. '   TiCadaver.enabled = 0
  3588.     FadingLevel(cCadaver) = 0
  3589. end sub
  3590.  
  3591.  
  3592.  
  3593.  
  3594. Sub UpdateFlippers()
  3595.     PrLeftFlipper.RotZ = LeftFlipper.CurrentAngle
  3596.     PrRightFlipper.RotZ = RightFlipper.CurrentAngle
  3597.     FlSpider.RotZ = WheelMech.position * 7.5 + 18   '+20
  3598.     UpdateBallShadow
  3599. End Sub
  3600.  
  3601.  
  3602.  
  3603. 'Ballshadow routine by Ninuzzu
  3604.  
  3605. Dim BallShadow
  3606. BallShadow = Array (BallShadow1, BallShadow2, BallShadow3, BallShadow4, BallShadow5, BallShadow6)
  3607.  
  3608. Sub UpdateBallShadow()  'called by -1 lamptimer
  3609.     On Error Resume Next
  3610.     Dim BOT, b
  3611.     BOT = GetBalls
  3612.     dim CenterPoint : CenterPoint = 425'Table1.Width/2
  3613.  
  3614.     ' render the shadow for each ball
  3615.    For b = 0 to UBound(BOT)
  3616.         If BOT(b).X < CenterPoint Then
  3617.             BallShadow(b).X = ((BOT(b).X) - (50/6) + ((BOT(b).X - (CenterPoint))/7)) + 10
  3618.         Else
  3619.             BallShadow(b).X = ((BOT(b).X) + (50/6) + ((BOT(b).X - (CenterPoint))/7)) - 10
  3620.         End If
  3621.  
  3622.             BallShadow(b).Y = BOT(b).Y + 20
  3623.             BallShadow(b).Z = 1
  3624.         If BOT(b).Z > 20 Then
  3625.             BallShadow(b).visible = 1
  3626.         Else
  3627.             BallShadow(b).visible = 0
  3628.         End If
  3629.     Next
  3630. End Sub
  3631.  
  3632.  
  3633. sub k033(x,y,z) : k033k.CreateSizedBallwithMass ballsize/2, z : k033k.kick x, y : End Sub
  3634. sub k148(x,y,z) : k148k.CreateSizedBallwithMass ballsize/2, z : k148k.kick x, y : End Sub
  3635. sub k236(x,y,z) : k148k.CreateSizedBallwithMass ballsize/2, z : k148k.kick x, y : End Sub
  3636. sub k1037(x,y,z): k1037k.CreateSizedBallwithMass ballsize/2, z : k1037k.kick x, y : End Sub
  3637. sub k1044(x,y,z): k1044k.CreateSizedBallwithMass ballsize/2, z : k1044k.kick x, y : End Sub
  3638. 'sub k1141(x,y,z): k1141k.CreateSizedBallwithMass ballsize/2, z : k1141k.kick x, y : End Sub
  3639. sub k1610(x,y,z): k1037k.CreateSizedBallwithMass ballsize/2, z : k1037k.kick x, y : End Sub
  3640. sub k1614(x,y,z): k1037k.CreateSizedBallwithMass ballsize/2, z : k1037k.kick x, y : End Sub
  3641. sub k1821(x,y,z): k1821k.CreateSizedBallwithMass ballsize/2, z : k1821k.kick x, y : End Sub
  3642. sub k1846(x,y,z): k1846k.CreateSizedBallwithMass ballsize/2, z : k1846k.kick x, y : End Sub
  3643. sub k1953(x,y,z): k1953k.CreateSizedBallwithMass ballsize/2, z : k1953k.kick x, y : End Sub
  3644. sub k2023(x,y,z): k1044k.CreateSizedBallwithMass ballsize/2, z : k1044k.kick x, y : End Sub
  3645. sub k2144(x,y,z): k2144k.CreateSizedBallwithMass ballsize/2, z : k2144k.kick x, y : End Sub
  3646. sub k2226(x,y,z): k2226k.CreateSizedBallwithMass ballsize/2, z : k2226k.kick x, y : End Sub
  3647. sub k2341(x,y,z): k2341k.CreateSizedBallwithMass ballsize/2, z : k2341k.kick x, y : End Sub
  3648. sub k2415(x,y,z): k2341k.CreateSizedBallwithMass ballsize/2, z : k2341k.kick x, y : End Sub
  3649. 'sub k2544(x,y,z): k2544k.CreateSizedBallwithMass ballsize/2, z : k2544k.kick x, y : End Sub
  3650. sub k2549(x,y,z): k2549k.CreateSizedBallwithMass ballsize/2, z : k2549k.kick x, y : End Sub
  3651. sub k2555(x,y,z): k2549k.CreateSizedBallwithMass ballsize/2, z : k2549k.kick x, y : End Sub
  3652. sub k2620(x,y,z): k2620k.CreateSizedBallwithMass ballsize/2, z : k2620k.kick x, y : End Sub
  3653. sub k2627(x,y,z): k2627k.CreateSizedBallwithMass ballsize/2, z : k2627k.kick x, y : End Sub
  3654. sub k2812(x,y,z): k2341k.CreateSizedBallwithMass ballsize/2, z : k2341k.kick x, y : End Sub
  3655. sub k2903(x,y,z): k2903k.CreateSizedBallwithMass ballsize/2, z : k2903k.kick x, y : End Sub
  3656. sub k3007(x,y,z): k2627k.CreateSizedBallwithMass ballsize/2, z : k2627k.kick x, y : End Sub
  3657. sub k3130(x,y,z): k2226k.CreateSizedBallwithMass ballsize/2, z : k2226k.kick x, y : End Sub
  3658.  
  3659.  
  3660.  
  3661.  
  3662.  
  3663.  
  3664.  
  3665.  
  3666. dim EndPointL : EndPointL = 379.34  'X position of the very end of the flipper
  3667. dim EndPointR : EndPointR = 498.5795'489.7015'-25'X position of the very end of the flipper
  3668. '==,ggggggggggg,=========================================================================
  3669. 'dP"""88""""""Y8,              ,dPYb,                                I8              
  3670. 'Yb,  88      `8b              IP'`Yb                                I8              
  3671. ' `"  88      ,8P              I8  8I                         gg  88888888          
  3672. '     88aaaad8P"               I8  8'                         ""     I8              
  3673. '     88"""""       ,ggggg,    I8 dP    ,gggg,gg   ,gggggg,   gg     I8    gg     gg
  3674. '     88           dP"  "Y8ggg I8dP    dP"  "Y8I   dP""""8I   88     I8    I8     8I
  3675. '     88          i8'    ,8I   I8P    i8'    ,8I  ,8'    8I   88    ,I8,   I8,   ,8I
  3676. '     88         ,d8,   ,d8'  ,d8b,_ ,d8,   ,d8b,,dP     Y8,_,88,_ ,d88b, ,d8b, ,d8I
  3677. '     88         P"Y8888P"    8P'"Y88P"Y8888P"`Y88P      `Y88P""Y888P""Y88P""Y88P"888
  3678. '===============================================================================,d8I'====
  3679. '                                                                             ,dP'8I
  3680. 'Tracks balls, Adjusts ball velocity and adjusts shot angle                  ,8"  8I
  3681. 'Part 1 - Ball velocity Hack                                                 I8   8I
  3682. 'Part 2 - Polarity and Velocity Adjustments on 3 or 5-point envelopes        `8, ,8I
  3683. '                                                                             `Y8P"  
  3684. 'Setup -                                                            
  3685. 'Triggers tight to the flippers TriggerLF and TriggerRF. Timers as low as possible, but > 80ms
  3686. 'Debug box TBpl
  3687. 'On Flipper Call:
  3688. '   ProcessballsL
  3689. '   ...
  3690. '   ProcessballsR
  3691. 'set up flipper end X coords in variables EndpointL / EndpointR (or in FTS flipper test script)
  3692.  
  3693.  
  3694. '-----------Configuration---------------
  3695. dim PolarityMod(5, 1), VelMod(5, 1), Ydiminish(3, 1), VelXmod(5, 1)
  3696.  
  3697. 'Coord PolarityMod, 1, x, y
  3698. Sub Coord(N,A,X,Y):a(n, 0) = x :a(n,1) = y : End Sub 'Point #, Array name, XCoord, YCoord
  3699.  
  3700. PolarityMod(0,0) = "PolarityMod"
  3701. VelMod(0,0) = "VelMod"
  3702. Ydiminish(0,0) = "Ydiminish"
  3703. VelXmod(0,0) = "VelXmod"
  3704.  
  3705. 'x = % Position of Flipper
  3706. 'Y = Output Coefficient for calculation
  3707.  
  3708. polarityenabled = True'False
  3709.  
  3710. 'Stern
  3711.  
  3712. 'm1 = 1 : m2 = 1 : m3 = 50 : m4 = 0.93 'Setup Vel Falloff Line
  3713. 'Coord 1, PolarityMod, 0.38, -4.5       'Early1
  3714. 'Coord 2, PolarityMod, 0.65, -4     'Early2
  3715. 'Coord 3, PolarityMod, 0.84, 0      'Middle
  3716. 'Coord 4, PolarityMod, 0.97, 3.2    'Late3
  3717. 'Coord 5, PolarityMod, 1.05,  7 'Late4
  3718. '
  3719. 'Coord 1, VelMod, 0.30, 0.9     'Early1
  3720. 'Coord 2, VelMod, 0.596, 1'0.97     'Early2
  3721. 'Coord 3, VelMod, 0.782, 1          'Middle
  3722. 'Coord 4, VelMod, 0.941,  0.95'0.9      'Late3
  3723. 'Coord 5, VelMod, 1.1,  0.825'0.85      'Late4
  3724.  
  3725. 'WPC Steep (71.1/120)
  3726. m1 = 1 : m2 = 1 : m3 = 10 : m4 = 0.935
  3727. Coord 1, PolarityMod, 0.38, -3.5        'Early1
  3728. Coord 2, PolarityMod, 0.596, -5     'Early2
  3729. Coord 3, PolarityMod, 0.8, -2       'Middle
  3730. Coord 4, PolarityMod, 0.97, -1.5    'Late3
  3731. Coord 5, PolarityMod, 1.05,  0  'Late4
  3732. 'kinda improper. Adjust speed so that these cap out at 1!
  3733. Coord 1, VelMod, 0.300.9     'Early1
  3734. Coord 2, VelMod, 0.596, 0.95'0.97       'Early2
  3735. Coord 3, VelMod, 0.745, 0.965           'Middle
  3736. Coord 4, VelMod, 0.941,  0.95'0.9       'Late3
  3737. Coord 5, VelMod, 1.1,   0.95'0.85       'Late4
  3738.  
  3739. 'all
  3740. Coord 1, Ydiminish, RightFlipper.Y-65,   0      ' Earliest Flipper (keep at 1)
  3741. Coord 2, Ydiminish, RightFlipper.Y-11,  1       ' Mid Point
  3742. Coord 3, Ydiminish, RightFlipper.Y,  1  ' Latest Flipper
  3743.  
  3744. 'Part 1 - Overall Velocity Hack
  3745. '***************************
  3746. Dim LFon, RFon, RF1on, SpeedLimit, M1, M2, M3, M4
  3747.  
  3748. Sub TriggerLF_Timer(): LFon = False : me.TimerEnabled = 0 : End Sub
  3749. Sub TriggerRF_Timer(): RFon = False : me.TimerEnabled = 0 : End Sub
  3750. Sub TriggerRF1_Timer(): RF1on = False : me.TimerEnabled = 0 : End Sub
  3751. Sub TriggerRF1_UnHit(): if RF1on then FlipSpeedHack m1, m2, m3, m4, False End If : End Sub
  3752.  
  3753. Sub FlipSpeedHack(X1, Y1, X2, Y2, CutoffBool)   'Two points
  3754.     if CutoffBool then if activeball.vely > 0 then exit sub 'if ball is going Down, exit sub (inappropriate for upper flippers)
  3755.     Dim FinalSpeed : FinalSpeed = BallSpeed(ActiveBall) : if FinalSpeed < x1 then Exit Sub
  3756.     Dim VelCoef : VelCoef = SlopeIt(FinalSpeed,X1,Y1,X2,Y2)
  3757.         if VelCoef < Y1 then VelCoef = Y1   'Clamp Low
  3758.         if VelCoef > Y2 then VelCoef = Y2   'Clamp High
  3759.         activeball.velx = activeball.velx * VelCoef
  3760.         activeball.vely = activeball.vely * VelCoef
  3761.        
  3762.         Dim DebugString : DebugString = "Flip" & vbnewline
  3763.         FalloffDebugBox TBflipper, Finalspeed, BallSpeed(ActiveBall), VelCoef, DebugString
  3764. End Sub
  3765. Sub TBflipper_Timer():me.timerenabled = False : me.text = Empty : End Sub
  3766.  
  3767.  
  3768. '=====================================
  3769. 'Part 2
  3770. 'Ball Tracking Polarity Correction
  3771. '=====================================
  3772.  
  3773. '0.09a
  3774. '   -   Improved Envelope Functions
  3775. '   -   fixed greater than / less than errors
  3776. '0.09b - script cleanup, removed unused stuff
  3777.  
  3778. Dim Lballstack(9, 5)
  3779. Dim Rballstack(9, 5)
  3780. '0 = Object reference
  3781. '1 = ballID kept in integer (trigger unhit compares this to activeball.ID for wiping ball from stack)
  3782. '2 = Ball X pos (set by flip for Polarity correction, wiped on trigger unhit)
  3783. '3 = Ball Y pos (TODO)
  3784. '4 = Ball X vel
  3785. '5 = Partial Flip Coefficient  (kept in 0, 5 only)
  3786.  
  3787. Initballstacks
  3788. Sub Initballstacks() : dim x: for x = 0 to 9 : Set Lballstack(x,0) = Nothing : Set Rballstack(x,0) = Nothing : next : End Sub
  3789.  
  3790. 'Left Flipper ====================================
  3791.  
  3792. Sub TriggerLF_Hit() 'add a ball to the stack
  3793. '   tb.text = activeball.mass
  3794.     dim x : for x = 0 to 9
  3795.         if Typename(Lballstack(x, 0)) = "Nothing" then
  3796.             Set Lballstack(x, 0) = activeball
  3797.             Lballstack(x, 1) = activeball.id
  3798.             exit For
  3799.         End If
  3800.     Next
  3801. End Sub
  3802.  
  3803. Sub TriggerLF_UnHit() 'proc Polarity Correction, then wipe X coords from column 2
  3804.     if LFon then    'FalloffNF
  3805.         dim x : for x = 0 to 9  'If X position is set, call Polarity Correction for that object
  3806.             if Lballstack(x, 2) > 0 then
  3807.                 PolarityCorrect Lballstack(x, 0), Lballstack(x, 2), Lballstack(x, 3), Lballstack(x, 4), Lballstack(0, 5), 0
  3808.             End If
  3809.         Next
  3810.         for x = 0 to 9  'wipe X Positions
  3811.             Lballstack(x, 2) = Empty
  3812.         Next
  3813.         FlipSpeedHack m1, m2, m3, m4, True
  3814.     End If
  3815.     for x = 0 to 9  'Remove ball from stack...
  3816.         if activeball.id = Lballstack(x, 1) then Set Lballstack(x, 0) = Nothing
  3817.     Next
  3818. End Sub
  3819.  
  3820. Sub ProcessballsL() 'note X position of balls in flipper area
  3821.     TriggerLF.TimerEnabled = 1
  3822.     LFon = True
  3823.     dim x : for x = 0 to 9 'Count X positions of balls in array
  3824.         if TypeName(Lballstack(x, 0)) = "IBall" then
  3825.             Lballstack(x, 2) = Lballstack(x, 0).X
  3826.             Lballstack(x, 3) = Lballstack(x, 0).Y
  3827.             Lballstack(x, 4) = Lballstack(x, 0).VelX
  3828.         End If
  3829.     Next
  3830.     'dim totalrotation, currentangler, b
  3831.     'CurrentAngler = (LeftFlipper.StartAngle - LeftFlipper.CurrentAngle)
  3832.     'TotalRotation = (LeftFlipper.StartAngle - LeftFlipper.EndAngle)
  3833.     dim b
  3834.     b = ((LeftFlipper.StartAngle - LeftFlipper.CurrentAngle) / (LeftFlipper.StartAngle - LeftFlipper.EndAngle))
  3835.     b = abs(b-1)    'invert
  3836.     Lballstack(0, 5) = b    'Partial Flip Coefficient
  3837.     'tb.text = LeftFlipper.StartAngle - LeftFlipper.EndAngle & vbnewline & leftflipper.CurrentAngle & vbnewline & b
  3838. end Sub
  3839.  
  3840. 'Right Flipper ====================================
  3841.  
  3842. Sub TriggerRF_Hit() 'add a ball to the stack
  3843.     dim x : for x = 0 to 9
  3844.         if Typename(Rballstack(x, 0)) = "Nothing" then
  3845.             Set Rballstack(x, 0) = activeball
  3846.             Rballstack(x, 1) = activeball.id
  3847.             exit For
  3848.         End If
  3849.     Next
  3850. End Sub
  3851.  
  3852. Sub TriggerRF_UnHit() 'proc Polarity Correction, then wipe X coords from column 2
  3853.     if RFon then    'FalloffNF
  3854.         dim x : for x = 0 to 9  'If X position is set, call Polarity Correction for that object
  3855.             if Rballstack(x, 2) > 0 then
  3856.                 PolarityCorrect Rballstack(x, 0), Rballstack(x, 2), Rballstack(x, 3) , Rballstack(x, 4), Rballstack(0, 5), 1
  3857.             End If
  3858.         Next
  3859.         for x = 0 to 9  'wipe X Positions
  3860.             Rballstack(x, 2) = Empty
  3861.         Next
  3862.         FlipSpeedHack m1, m2, m3, m4, True
  3863.     End If
  3864.     for x = 0 to 9  'Remove ball from stack...
  3865.         if activeball.id = Rballstack(x, 1) then Set Rballstack(x, 0) = Nothing
  3866.     Next
  3867. End Sub
  3868.  
  3869. Sub tbBS_Timer()    'debug textbox
  3870. '   on error resume next
  3871.     dim y(9), x : for x = 0 to 9
  3872.         y(x) = Typename(Rballstack(x, 0))
  3873.         if TypeName(Rballstack(x, 0)) = "IBall" then y(x) = y(x) & " " & Rballstack(x, 0).ID
  3874.         y(x) = y(x) & " " & Rballstack(x, 2)
  3875.     Next
  3876.     me.text = "Ball 1: " & y(0) & " " & Rballstack(0,1) & vbnewline & _
  3877.               "Ball 2: " & y(1) & " " & Rballstack(1,1) & vbnewline & _
  3878.               "Ball 3: " & y(2) & " " & Rballstack(2,1) & vbnewline & _
  3879.               "Ball 4: " & y(3) & " " & Rballstack(3,1) & vbnewline & _
  3880.               "Ball 5: " & y(4) & " " & Rballstack(4,1) & vbnewline & _
  3881.               "Ball 6: " & y(5) & " " & Rballstack(5,1) & vbnewline & _
  3882.               "Ball 7: " & y(6) & " " & Rballstack(6,1) & vbnewline & _
  3883.               "Ball 8: " & y(7) & " " & Rballstack(7,1) & vbnewline & _
  3884.               "Ball 9: " & y(8) & " " & Rballstack(8,1) & vbnewline & _
  3885.               "Ball10: " & y(9) & " " & Rballstack(9,1) & vbnewline & _
  3886.               "..."
  3887. End Sub
  3888.  
  3889. Sub ProcessballsR() 'note X position of balls in flipper area
  3890.     TriggerRF.TimerEnabled = 1
  3891.     RFon = True
  3892.     dim x : for x = 0 to 9 'Count X positions of balls in array
  3893.         if TypeName(Rballstack(x, 0)) = "IBall" then
  3894.             Rballstack(x, 2) = Rballstack(x, 0).X
  3895.             Rballstack(x, 3) = Rballstack(x, 0).Y
  3896.             Rballstack(x, 4) = Rballstack(x, 0).VelX
  3897.         End If
  3898.     Next
  3899.     dim b
  3900.     b = ((RightFlipper.StartAngle - RightFlipper.CurrentAngle) / (RightFlipper.StartAngle - RightFlipper.EndAngle))
  3901.     b = abs(b-1)    'invert
  3902.     Rballstack(0, 5) = b    'Partial Flip Coefficient
  3903.     'tb.text = RightFlipper.StartAngle - RightFlipper.EndAngle & vbnewline & RightFlipper.CurrentAngle & vbnewline & b
  3904. end Sub
  3905.  
  3906.  
  3907. 'Puts an input X through a five-point, four line envelope with flat clamping at the ends
  3908. 'Function Procedures: Input X, 2D array, special (if True, inverts first two lines for polarity script)
  3909. 'This 2d Array should start at 1 and end at 5.
  3910. '0,0 is used to hold an identifying string for debug purposes
  3911. 'This 2d Array should hold X data in (x, 0) & Y data in (x, 1)
  3912. 'Input X, Output Y  
  3913. Function FivePointEnvelope(xInput, yArray)', special)
  3914.     dim y, testF
  3915.     If xInput < yArray(2,0) Then    'Setup X Points     'please keep array X coords sequential!
  3916.         y = SlopeIt(xInput, yArray(1,0), yArray(1,1), yArray(2,0), yArray(2, 1) )
  3917.         If yArray(1,1) > yArray(2,1) then
  3918.             if y > yArray(1,1) then y = yArray(1,1) 'Clamp Low End 
  3919.         elseif yArray(1,1) <= yArray(2,1) then
  3920.             if y <= yArray(1,1) then y = yArray(1,1) 'Clamp Low End            
  3921.         End If
  3922.         testF = yArray(0,0) & " L1 (early1) " & "x= " & xInput & " y= " & y
  3923.     elseif xInput < yArray(3,0) Then    'l2
  3924.         y = SlopeIt(xInput, yArray(2,0), yArray(2,1), yArray(3,0), yArray(3,1)  )
  3925.         testF =  yArray(0,0) & " L2 (early2)" & "x= " & xInput & " y= " & y
  3926.     Elseif xInput < yArray(4,0) Then    'l3
  3927.         y = SlopeIt(xInput, yArray(3,0), yArray(3,1), yArray(4,0), yArray(4,1)  )
  3928.         testF = yArray(0,0) & " L3 (late3)" & "x= " & xInput & " y= " & y
  3929.     Elseif xInput >= yArray(4,0) Then   'l4
  3930.         y = SlopeIt(xInput, yArray(4,0), yArray(4,1), yArray(5,0), yArray(5,1)  )      
  3931.         If yArray(5,1) > yArray(4,1) then    'Clamp High End   
  3932.             if y > yArray(5,1) then y = yArray(5,1)
  3933.         elseif yArray(5,1) <= yArray(4,1) then
  3934.             if y <= yArray(5,1) then y = yArray(5,1)       
  3935.         End If     
  3936.         testF = yArray(0,0) & " L4 (late4) " & " x= " & xInput & " y= " & y
  3937.     Else
  3938.     debug.print "5error: " & yArray(0,0) & ", xinput = " & xInput : y = 1
  3939.     End If
  3940.     FivePointEnvelope = y
  3941. End Function
  3942.  
  3943. dim TestSpecial
  3944.  
  3945. Function ThreePointEnvelope(xInput, yArray)
  3946.     dim y, test
  3947.     If xInput < yArray(2,0) Then
  3948.         y = SlopeIt(xInput, yArray(1,0), yArray(1,1), yArray(2,0), yArray(2,1)  )
  3949.         If yArray(1,1) > yArray(2,1) then  'Clamp Low End  
  3950.             if y > yArray(1,1) then y = yArray(1,1)
  3951.         elseif yArray(1,1) <= yArray(2,1) then
  3952.             if y < yArray(1,1) then y = yArray(1,1)    
  3953.         End If
  3954.         test = "L1 (earliest) " & yArray(0,0) & " x= " & xInput & " y= " & y
  3955.     Elseif xInput >= yArray(2,0) Then   'l2
  3956.         y = SlopeIt(xInput, yArray(2,0), yArray(2,1), yArray(3,0), yArray(3,1)  )
  3957.         If yArray(3,1) > yArray(2,1) then    'Clamp High End   
  3958.             if y > yArray(3,1) then y = yArray(3,1)
  3959.         elseif yArray(3,1) <= yArray(2,1) then
  3960.             if y < yArray(3,1) then y = yArray(3,1)    
  3961.         End If 
  3962.         test = "L3 (latest) " & yArray(0,0) & " x= " & xInput & " y= " & y
  3963.     Else
  3964.     'debug.print "3error: " & yArray(0,0) & ", xinput = " & xInput
  3965.     y = 1
  3966.     End If
  3967.     'debug.print test
  3968.     ThreePointEnvelope = y
  3969. End Function
  3970.  
  3971. dim PolarityEnabled : PolarityEnabled = True    'debug
  3972. Sub PolarityCorrect(object, xpos, ypos, xvel, PartialFLipCoef, LR)  'Corrects angle/velocity using ball data captured at flip
  3973.     if TypeName(object) = "Nothing" then Exit Sub 'Bug - This happens when the ball wavers in and out of trigger maybe
  3974.     if object.vely > 0 then TBpl.text = "exit sub" : exit sub
  3975.     dim TestVar :   TestVar = "Cutoff"  'debug string
  3976.     dim lrcoef : if lr = 1 then lrcoef = -1 else lrcoef = 1 end if  'Direction Coef- could be used to compress the script. readability tho
  3977.  
  3978.     dim Y    'output (% ball-on-flipper position, 0=base 1=tip)
  3979.     if xpos <0.15 then TBpl.text = "xpos<0.15, exit sub " & vbnewline & " y =" & round(y,3) : exit sub 'Cutoff super early
  3980.     Select Case LR  'return position of ball on flipper as a % (0=base, 1=tip)
  3981.         case 0 : y = SlopeIt(xpos, LeftFlipper.X, 0, EndpointL, 1)  'base flipper -> 0
  3982.         case 1 : y = SlopeIt(xpos, RightFlipper.X, 0, EndpointR, 1) 'End flipper -> 1
  3983.     End Select
  3984.     if y > 1.05 then y = 1.05   'Clamp high End
  3985.    
  3986.  
  3987.     ''''''''''''''declare Polarity Correction + safeties'''''''''''''''
  3988.     dim AddX    'Polarity correction
  3989.     dim Ycoef:Ycoef = 1 'Safety coef #1 - Cut down Correction if the ball is sufficiently above the flipper base
  3990.     if Y > 0.65 then ycoef = ThreePointEnvelope(ypos, Ydiminish)    'Calculate Safety coef #1- if ball is above the flipper
  3991.     'PartialFLipCoef -  'Safety coef #2 - handled by processballs, another safety coefficient
  3992.  
  3993.    
  3994.     if not PolarityEnabled then 'If Disabled, Exit Sub Here
  3995.         TBpl.text = "%" & round(y,5) & vbnewline & "PolarityEnabled = " & PolarityEnabled
  3996.         Exit Sub   
  3997.     End If
  3998.    
  3999.     ''''''''''''''''''''Apply Velocity Correction''''''''''''''
  4000.     dim velcoef 'Overall Velocity coefficient
  4001.     Velcoef = FivePointEnvelope(y, VelMod)  'five point velocity envelope based on Y (% on flipper)
  4002.     Object.Velx = Object.VelX * velcoef
  4003.     Object.Vely = Object.VelY * velcoef
  4004.  
  4005.     ''''''''''''''''''''Apply Polarity Correction''''''''''''''
  4006.     AddX = FivePointEnvelope(y, PolarityMod)*lrcoef 'AddX - Find polarity correction   
  4007.     object.VelX = object.VelX + 1*(AddX*ycoef*PartialFlipcoef)  'gogo          
  4008.  
  4009.     '''''''''''''''''''''''Debug Strings''''''''''''''''''''''
  4010.     Select Case LR
  4011.         case 0 : TestVar =  "Left:" & round(1*(AddX*ycoef*PartialFlipcoef),3) 'debug string  'left flipper
  4012.         case 1 : TestVar =  "Right:" & round(1*(AddX*ycoef*PartialFlipcoef),3) 'debug string  'Right Flipper
  4013.     End Select
  4014.     'debug stuff
  4015.     dim d1, d2, d3
  4016.     if ycoef < 1 then d1 = "ycoef: " & round(ycoef,5) & vbnewline
  4017.     if y = 1.05 then d2 = "(MAX)"
  4018.     if PartialFlipcoef < 1 then d3 = "PartialFlipcoef: " & round(PartialFlipcoef,4) & vbnewline
  4019.     TBpl.text =  "%" & round(y,3) & d2 & vbnewline & _
  4020.                  TestVar & vbnewline & _
  4021.                  d1 & d3 & vbnewline & _
  4022.                  " "
  4023. End Sub
  4024.  
  4025. Function BallSpeed(ball) 'Calculates the ball speed
  4026.    BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
  4027. End Function
  4028.  
  4029. '======================================
  4030. Function SlopeIt(Input, X1, Y1, X2, Y2) 'Set up line via two points, no clamping. Input X, output Y
  4031.     dim x, y, b, m
  4032.     x = input
  4033.     m = (Y2 - Y1) / (X2 - X1)
  4034.     b = Y2 - m*X2
  4035.  
  4036.     Y = M*x+b
  4037.     SlopeIt = Y
  4038. End Function
  4039. '======================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement