forked from LegendsUnchained/vpx-standalone-alp4k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Black Knight (Williams 1980).vbs
3419 lines (2837 loc) · 120 KB
/
Black Knight (Williams 1980).vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
' Black Knight / IPD No. 310 / Williams, November, 1980 / 4 Players
' Original table done by Bord
' VR Room Mods for Version 3.0 by Uncle Paulie
' - NOTE: IF YOU GET TOO MANY CREDITS: If you get 3 credits when you press your keycode 5 or addcreditkey; you need to change your ROM
' Here is the procedure to set credits on Williams System 6A tables on the ROM using service keys (or your keyboard):
' 1. Press 9 to enter diagnostic mode.
' 2. Press 8 to enter test mode.
' 3. Press 7 then press 8 to see 01 in the credit display.
' 4. Continue to press 8 until you see 19 in the credit display
' 5. Press and hold the 1 key select for the setting you want 00-08. The value will increment by 1 while holding in the 1 key.
' When you reach the number you want to set it to, release the 1 key. (NOTE: If you want to lower the value or you went past
' the value you wanted to set it to, release the 1 key, press and release the 7 key, then press and hold the 1 key. Value should
' then decrement by 1). (NOTE: From a fresh NVRAM, incrementing the 1 key one time is all that's necessary.)
' 6. Press F3 to save your changes and reset the table.
' The manual is here: https://www.ipdb.org/files/310/Williams_1980_Black_Knight_Operators_Handbook.pdf
Option Explicit
Randomize
On Error Resume Next
ExecuteGlobal GetTextFile("controller.vbs")
If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
On Error Goto 0
Const cSingleLFlip = 0
Const cSingleRFlip = 0
Dim CustomWalls
Dim VR_Room
' ****************************************************
' OPTIONS
' ****************************************************
'----- Shadow Options -----
Const DynamicBallShadowsOn = 1 '0 = no dynamic ball shadow, 1 = enable dynamic ball shadow
Const AmbientShadowOn = 1 '0 = no moving shadow primitive (ninuzzu's)
'///////////////////////-----General Sound Options-----///////////////////////
'// VolumeDial:
'// VolumeDial is the actual global volume multiplier for the mechanical sounds.
'// Values smaller than 1 will decrease mechanical sounds volume.
'// Recommended values should be no greater than 1.
Const VolumeDial = 1
VR_Room = 0 ' 0 is desktop or cab mode, 1 is VR Room
' *** If using VR Room, set to 0 for Modern Minimal Walls, floor, and roof, 1 for Sixtoe's original walls and floor
CustomWalls = 0
Const WallClock = 1 '1 Shows the clock in the VR minimal rooms only
Dim VRThings
if VR_Room = 0 Then
for each VRThings in VRStuff:VRThings.visible = 0:Next
for each VRThings in VRClock:VRThings.visible = 0:Next
Else
for each VRThings in VRStuff:VRThings.visible = 1:Next
for each VRThings in VRClock:VRThings.visible = WallClock:Next
'Custom Walls, Floor, and Roof
if CustomWalls = 1 Then
VR_Wall_Left.image = "VR_Wall_Left"
VR_Wall_Right.image = "VR_Wall_Right"
VR_Floor.image = "VR_Floor"
VR_Roof.image = "VR_Roof"
end if
End If
'***************************************************************************************
' CODE BELOW IS FOR THE VR CLOCK. This was originally taken from Rascal VP9 clock table
'***************************************************************************************
Dim CurrentMinute ' for VR clock
Sub ClockTimer_Timer()
'ClockHands Below *********************************************************
Pminutes.RotAndTra2 = (Minute(Now())+(Second(Now())/100))*6
Phours.RotAndTra2 = Hour(Now())*30+(Minute(Now())/2)
Pseconds.RotAndTra2 = (Second(Now()))*6
CurrentMinute=Minute(Now())
End Sub
PinCab_Backglass.blenddisablelighting = 1
Dim UseVPMDMD:UseVPMDMD = True
LoadVPM "01560000", "S7.VBS", 3.26
'********************
'Standard definitions
'********************
Dim VarHidden
IF VR_Room = 0 Then
If Table1.ShowDT = true then
VarHidden = 1
For each x in aReels
x.Visible = 1
Next
Primary_SideRailMapLeft.visible=1
Primary_SideRailMapRight.visible=1
UV1_lockdown.visible=1
else
VarHidden = 0
For each x in aReels
x.Visible = 0
Next
Primary_SideRailMapLeft.visible=0
Primary_SideRailMapRight.visible=0
UV1_lockdown.visible=0
end if
Else
For each x in aReels
x.Visible = 0
Next
UV1_lockdown.visible=0
End If
if B2SOn = true then VarHidden = 1
' using table width and height in script slows down the performance
dim tablewidth: tablewidth = Table1.width
dim tableheight: tableheight = Table1.height
Dim bsTrough, bsLock, bsSaucer, dtLL, dtLR, dtUL, dtUR, LMAG, RMAG
Dim x, k
Dim EnableBallControl
EnableBallControl = false 'Change to true to enable manual ball control (or press C in-game) via the arrow keys and B (boost movement) keys
' *** VR Plunger Animation ***
Sub TimerPlunger_Timer
If PinCab_Shooter.Y < -270 then
PinCab_Shooter.Y = PinCab_Shooter.Y + 5
End If
End Sub
Sub TimerPlunger2_Timer
PinCab_Shooter.Y = -397 + (5* Plunger.Position) -20
End Sub
'************
' Table init.
'************
Const cGameName = "bk_l4",UseSolenoids=2,UseLamps=0,UseGI=0,SSolenoidOn="Solenoid",SSolenoidOff="SolOff"
Const SCoin=""
Sub Table1_Init
vpmInit Me
With Controller
.GameName = cGameName
If Err Then MsgBox "Can't start Game " & cGameName & vbNewLine & Err.Description:Exit Sub
.SplashInfoLine = "Black Knight (Williams 1980)"
.HandleKeyboard = 0
.ShowTitle = 0
.ShowDMDOnly = 1
.ShowFrame = 0
.HandleMechanics = 0
.Hidden = VarHidden
On Error Resume Next
.SolMask(0) = 0
vpmTimer.AddTimer 2000, "Controller.SolMask(0)=&Hffffffff'" 'ignore all solenoids - then add the timer to renable all the solenoids after 2 seconds
.Run GetPlayerHWnd
If Err Then MsgBox Err.Description
On Error Goto 0
End With
' *** necessary for initializing the primitive inserts and lights ***
InitLights InsertOn, InsertLights
' Nudging
vpmNudge.TiltSwitch = 46
vpmNudge.Sensitivity = 1
vpmNudge.TiltObj = Array(Bumper1, LeftSlingshot, RightSlingshot)
' Trough
Set bsTrough = New cvpmBallStack
With bsTrough
.InitSw 20, 17, 18, 19, 0, 0, 0, 0
.InitKick BallRelease, 80, 12
.InitExitSnd "Saucer_kick", "Saucer_kick"
.Balls = 3
.IsTrough = 1
End With
' Lock
Set bsLock = New cvpmBallStack
With bsLock
.InitSw 0, 41, 42, 43, 0, 0, 0, 0
.InitKick LockOut, 194, 1
.InitExitSnd "Saucer_kick", "Saucer_kick"
End With
' Lower Eject Hole
Set bsSaucer = New cvpmBallStack
With bsSaucer
.InitSaucer sw24, 24, 90, 28
.InitExitSnd "Saucer_kick", "Saucer_kick"
End With
' Left Magnet
Set LMAG = New cvpmMagnet
With LMAG
.InitMagnet MagnetL, 6
.Solenoid = 10
.CreateEvents "LMAG"
End With
' Right Magnet
Set RMAG = New cvpmMagnet
With RMAG
.InitMagnet MagnetR, 6
.Solenoid = 9
.CreateEvents "RMAG"
End With
' Main Timer init
PinMAMETimer.Interval = PinMAMEInterval
PinMAMETimer.Enabled = 1
SolGi 0
if VR_Room = 1 Then
setup_backglass()
End If
End Sub
Dim ballsize, ballmass
Ballsize = 50
BallMass = 1
Dim GIisOff
Sub table1_Paused:Controller.Pause = 1:End Sub
Sub table1_unPaused:Controller.Pause = 0:End Sub
Sub table1_Exit:Controller.Stop:End Sub
''************** Constant update timer
Sub FlipperTimer_timer()
lflip.rotz = leftflipper.currentangle
rflip.rotz = rightflipper.currentangle
rflip1.rotz = rightflipper1.currentangle
lflip1.rotz = leftflipper1.currentangle
rampgate_prim.RotX = Gate2.CurrentAngle
If VR_Room = 1 Then
DisplayTimer
End If
End Sub
Dim Angle
'***********Rotate Spinner
Sub SpinnerTimer_Timer
Angle = (sin (Spinner.CurrentAngle))
TextBox1.text = Spinner.currentangle
TextBox2.text = Angle
' Spinner_Mesh.RotX = Spinner.CurrentAngle
SpinnerRod.TransZ = -sin( (Spinner.CurrentAngle) * (2*3.14/360)) * 5
SpinnerRod.TransX = (sin( (Spinner.CurrentAngle- 90) * (2*3.14/360)) * -5)
' SpinnerRod.TransZ = cos ((Spinner.CurrentAngle)) * -2
' SpinnerRod.TransY = Angle * -2
End Sub
'**********
' Keys
'**********
Sub Table1_KeyDown(ByVal KeyCode)
If keycode = LeftFlipperKey Then
FlipperActivate LeftFlipper, LFPress
' Move VR Left flipper
VRFlipperButtonLeft.X = VRFlipperButtonLeft.X +10
End If
If keycode = RightFlipperKey Then
FlipperActivate RightFlipper, RFPress
' Move VR Right flipper
VRFlipperButtonRight.X = VRFlipperButtonRight.X - 10
End If
If KeyCode = LeftMagnaSave Then
Controller.Switch(10) = 1
' Move VR Left Magna
VRFlipperButtonLeftMagna.X = VRFlipperButtonLeftMagna.X +10
End If
If KeyCode = RightMagnaSave Then
Controller.Switch(9) = 1
' Move VR Left Magna
VRFlipperButtonRightMagna.X = VRFlipperButtonRightMagna.X -10
End If
If keycode = StartGameKey Then
StartButton.y = StartButton.y -7
end if
If keycode = LeftTiltKey Then Nudge 90, 5:SoundNudgeLeft()
If keycode = RightTiltKey Then Nudge 270, 5:SoundNudgeRight()
If keycode = CenterTiltKey Then Nudge 0, 3:SoundNudgeCenter()
If keycode = keyInsertCoin1 or keycode = keyInsertCoin2 or keycode = keyInsertCoin3 or keycode = keyInsertCoin4 Then
Select Case Int(rnd*3)
Case 0: PlaySound ("Coin_In_1"), 0, CoinSoundLevel, 0, 0.25
Case 1: PlaySound ("Coin_In_2"), 0, CoinSoundLevel, 0, 0.25
Case 2: PlaySound ("Coin_In_3"), 0, CoinSoundLevel, 0, 0.25
End Select
End If
If KeyCode = PlungerKey Then Plunger.Pullback:SoundPlungerPull()
' Animate Plunger
If keycode = PlungerKey Then
TimerPlunger.Enabled = True
TimerPlunger2.Enabled = False
End If
If KeyDownHandler(keycode) Then Exit Sub
' Manual Ball Control
If keycode = 46 Then ' C Key
If EnableBallControl = 1 Then
EnableBallControl = 0
Else
EnableBallControl = 1
End If
End If
If EnableBallControl = 1 Then
If keycode = 48 Then ' B Key
If BCboost = 1 Then
BCboost = BCboostmulti
Else
BCboost = 1
End If
End If
If keycode = 203 Then BCleft = 1 ' Left Arrow
If keycode = 200 Then BCup = 1 ' Up Arrow
If keycode = 208 Then BCdown = 1 ' Down Arrow
If keycode = 205 Then BCright = 1 ' Right Arrow
End If
End Sub
Sub Table1_KeyUp(ByVal KeyCode)
If keycode = LeftFlipperKey Then
FlipperDeActivate LeftFlipper, LFPress
' Move VR Left flipper
VRFlipperButtonLeft.X = VRFlipperButtonLeft.X -10
End If
If keycode = RightFlipperKey Then
FlipperDeActivate RightFlipper, RFPress
' Move VR Right flipper
VRFlipperButtonRight.X = VRFlipperButtonRight.X +10
End If
If KeyCode = LeftMagnaSave Then
Controller.Switch(10) = 0
' Move VR Left Magna
VRFlipperButtonLeftMagna.X = VRFlipperButtonLeftMagna.X -10
End If
If KeyCode = RightMagnaSave Then
Controller.Switch(9) = 0
' Move VR Left Magna
VRFlipperButtonRightMagna.X = VRFlipperButtonRightMagna.X +10
End If
If keycode = StartGameKey Then
StartButton.y = StartButton.y +7
end if
If KeyCode = PlungerKey Then
Plunger.Fire
If plungelane=1 Then
SoundPlungerReleaseBall() 'Plunger release sound when there is a ball in shooter lane
Else
SoundPlungerReleaseNoBall() 'Plunger release sound when there is no ball in shooter lane
End If
TimerPlunger.Enabled = False
TimerPlunger2.Enabled = True
PinCab_Shooter.Y = -397
End If
If KeyUpHandler(keycode) Then Exit Sub
'Manual Ball Control
If EnableBallControl = 1 Then
If keycode = 203 Then BCleft = 0 ' Left Arrow
If keycode = 200 Then BCup = 0 ' Up Arrow
If keycode = 208 Then BCdown = 0 ' Down Arrow
If keycode = 205 Then BCright = 0 ' Right Arrow
End If
End Sub
dim plungelane
'******************************************************
' FLIPPERS
'******************************************************
SolCallback(sLRFlipper) = "SolRFlipper"
SolCallback(sLLFlipper) = "SolLFlipper"
Const ReflipAngle = 20
Sub SolLFlipper(Enabled)
If Enabled Then
LF.Fire
LeftFlipper1.rotatetoend
If leftflipper.currentangle < leftflipper.endangle + ReflipAngle Then
RandomSoundReflipUpLeft LeftFlipper
Else
SoundFlipperUpAttackLeft LeftFlipper
RandomSoundFlipperUpLeft LeftFlipper
End If
Else
LeftFlipper.RotateToStart
LeftFlipper1.RotateToStart
If LeftFlipper.currentangle < LeftFlipper.startAngle - 5 Then
RandomSoundFlipperDownLeft LeftFlipper
End If
FlipperLeftHitParm = FlipperUpSoundLevel
End If
End Sub
Sub SolRFlipper(Enabled)
If Enabled Then
RF.Fire
RightFlipper1.rotatetoend
If rightflipper.currentangle > rightflipper.endangle - ReflipAngle Then
RandomSoundReflipUpRight RightFlipper
Else
SoundFlipperUpAttackRight RightFlipper
RandomSoundFlipperUpRight RightFlipper
End If
Else
RightFlipper.RotateToStart
rightflipper1.rotatetostart
If RightFlipper.currentangle > RightFlipper.startAngle + 5 Then
RandomSoundFlipperDownRight RightFlipper
End If
FlipperRightHitParm = FlipperUpSoundLevel
End If
End Sub
'******************************************************
' KNOCKER
'******************************************************
Sub SolKnocker(Enabled)
If enabled Then
KnockerSolenoid 'Add knocker position object
End If
End Sub
'******************************************************
' FLIPPER TRICKS
'******************************************************
RightFlipper.timerinterval=1
Rightflipper.timerenabled=True
sub RightFlipper_timer()
FlipperTricks LeftFlipper, LFPress, LFCount, LFEndAngle, LFState
FlipperTricks RightFlipper, RFPress, RFCount, RFEndAngle, RFState
end sub
dim LFPress, RFPress, LFCount, RFCount
dim LFState, RFState
dim EOST, EOSA,Frampup, FElasticity,FReturn
dim RFEndAngle, LFEndAngle
EOST = leftflipper.eostorque
EOSA = leftflipper.eostorqueangle
Frampup = LeftFlipper.rampup
FElasticity = LeftFlipper.elasticity
FReturn = LeftFlipper.return
Const EOSTnew = 1
Const EOSAnew = 1
Const EOSRampup = 0
Dim SOSRampup
SOSRampup = 2.5
Const LiveCatch = 16
Const LiveElasticity = 0.45
Const SOSEM = 0.815
Const EOSReturn = 0.045
LFEndAngle = Leftflipper.endangle
RFEndAngle = RightFlipper.endangle
Sub FlipperActivate(Flipper, FlipperPress)
FlipperPress = 1
Flipper.Elasticity = FElasticity
Flipper.eostorque = EOST
Flipper.eostorqueangle = EOSA
End Sub
Sub FlipperDeactivate(Flipper, FlipperPress)
FlipperPress = 0
Flipper.eostorqueangle = EOSA
Flipper.eostorque = EOST*EOSReturn/FReturn
If Abs(Flipper.currentangle) <= Abs(Flipper.endangle) + 0.1 Then
Dim BOT, b
BOT = GetBalls
For b = 0 to UBound(BOT)
If Distance(BOT(b).x, BOT(b).y, Flipper.x, Flipper.y) < 55 Then 'check for cradle
If BOT(b).vely >= -0.4 Then BOT(b).vely = -0.4
End If
Next
End If
End Sub
Sub FlipperTricks (Flipper, FlipperPress, FCount, FEndAngle, FState)
Dim Dir
Dir = Flipper.startangle/Abs(Flipper.startangle) '-1 for Right Flipper
If Abs(Flipper.currentangle) > Abs(Flipper.startangle) - 0.05 Then
If FState <> 1 Then
Flipper.rampup = SOSRampup
Flipper.endangle = FEndAngle - 3*Dir
Flipper.Elasticity = FElasticity * SOSEM
FCount = 0
FState = 1
End If
ElseIf Abs(Flipper.currentangle) <= Abs(Flipper.endangle) and FlipperPress = 1 then
if FCount = 0 Then FCount = GameTime
If FState <> 2 Then
Flipper.eostorqueangle = EOSAnew
Flipper.eostorque = EOSTnew
Flipper.rampup = EOSRampup
Flipper.endangle = FEndAngle
FState = 2
End If
Elseif Abs(Flipper.currentangle) > Abs(Flipper.endangle) + 0.01 and FlipperPress = 1 Then
If FState <> 3 Then
Flipper.eostorque = EOST
Flipper.eostorqueangle = EOSA
Flipper.rampup = Frampup
Flipper.Elasticity = FElasticity
FState = 3
End If
End If
End Sub
Const LiveDistanceMin = 30 'minimum distance in vp units from flipper base live catch dampening will occur
Const LiveDistanceMax = 114 'maximum distance in vp units from flipper base live catch dampening will occur (tip protection)
Sub CheckLiveCatch(ball, Flipper, FCount, parm) 'Experimental new live catch
Dim Dir
Dir = Flipper.startangle/Abs(Flipper.startangle) '-1 for Right Flipper
Dim LiveCatchBounce 'If live catch is not perfect, it won't freeze ball totally
Dim CatchTime : CatchTime = GameTime - FCount
if CatchTime <= LiveCatch and parm > 6 and ABS(Flipper.x - ball.x) > LiveDistanceMin and ABS(Flipper.x - ball.x) < LiveDistanceMax Then
if CatchTime <= LiveCatch*0.5 Then 'Perfect catch only when catch time happens in the beginning of the window
LiveCatchBounce = 0
else
LiveCatchBounce = Abs((LiveCatch/2) - CatchTime) 'Partial catch when catch happens a bit late
end If
If LiveCatchBounce = 0 and ball.velx * Dir > 0 Then ball.velx = 0
ball.vely = LiveCatchBounce * (32 / LiveCatch) ' Multiplier for inaccuracy bounce
ball.angmomx= 0
ball.angmomy= 0
ball.angmomz= 0
End If
End Sub
Sub LeftFlipper_Collide(parm)
CheckLiveCatch Activeball, LeftFlipper, LFCount, parm
LeftFlipperCollide parm
Rubberizer2(parm)
End Sub
Sub RightFlipper_Collide(parm)
CheckLiveCatch Activeball, RightFlipper, RFCount, parm
RightFlipperCollide parm
Rubberizer2(parm)
End Sub
'*******************************************
' VPW Rubberizer by Iaakki
'*******************************************
' iaakki Rubberizer
sub Rubberizer(parm)
if parm < 10 And parm > 2 And Abs(activeball.angmomz) < 10 then
'debug.print "parm: " & parm & " momz: " & activeball.angmomz &" vely: "& activeball.vely
activeball.angmomz = activeball.angmomz * 1.2
activeball.vely = activeball.vely * 1.2
'debug.print ">> newmomz: " & activeball.angmomz&" newvely: "& activeball.vely
Elseif parm <= 2 and parm > 0.2 Then
'debug.print "* parm: " & parm & " momz: " & activeball.angmomz &" vely: "& activeball.vely
activeball.angmomz = activeball.angmomz * -1.1
activeball.vely = activeball.vely * 1.4
'debug.print "**** >> newmomz: " & activeball.angmomz&" newvely: "& activeball.vely
end if
end sub
' apophis Rubberizer
sub Rubberizer2(parm)
if parm < 10 And parm > 2 And Abs(activeball.angmomz) < 10 then
'debug.print "parm: " & parm & " momz: " & activeball.angmomz &" vely: "& activeball.vely
activeball.angmomz = -activeball.angmomz * 2
activeball.vely = activeball.vely * 1.2
'debug.print ">> newmomz: " & activeball.angmomz&" newvely: "& activeball.vely
Elseif parm <= 2 and parm > 0.2 Then
'debug.print "* parm: " & parm & " momz: " & activeball.angmomz &" vely: "& activeball.vely
activeball.angmomz = -activeball.angmomz * 0.5
activeball.vely = activeball.vely * (1.2 + rnd(1)/3 )
'debug.print "**** >> newmomz: " & activeball.angmomz&" newvely: "& activeball.vely
end if
end sub
'*********
' Switches
'*********
' Slings & div switches
Dim LStep, RStep
Sub LeftSlingShot_Slingshot
RandomSoundSlingshotLeft lemk
LeftSling2.Visible = 1
Lemk.RotX = 26
LStep = 0
vpmTimer.PulseSw 21
LeftSlingShot.TimerEnabled = 1
End Sub
Sub LeftSlingShot_Timer
Select Case LStep
Case 1:LeftSLing2.Visible = 0:LeftSLing3.Visible = 1:Lemk.RotX = 14
Case 2:LeftSLing3.Visible = 0:LeftSLing4.Visible = 1:Lemk.RotX = 2
Case 3:LeftSLing4.Visible = 0:LeftSling1.visible = 1:Lemk.RotX = -20:LeftSlingShot.TimerEnabled = 0
End Select
LStep = LStep + 1
End Sub
Sub RightSlingShot_Slingshot
RandomSoundSlingshotRight remk
RightSling2.Visible = 1
Remk.RotX = 26
RStep = 0
vpmTimer.PulseSw 22
RightSlingShot.TimerEnabled = 1
End Sub
Sub RightSlingShot_Timer
Select Case RStep
Case 1:RightSLing2.Visible = 0:RightSLing3.Visible = 1:Remk.RotX = 14
Case 2:RightSLing3.Visible = 0:RightSLing4.Visible = 1:Remk.RotX = 2
Case 3:RightSLing4.Visible = 0:RightSling1.visible = 1:Remk.RotX = -20:RightSlingShot.TimerEnabled = 0
End Select
RStep = RStep + 1
End Sub
' Bumpers
Sub Bumper1_Hit
vpmTimer.PulseSw 36
RandomSoundBumperMiddle Bumper1
bumperskirt.roty=skirtAY(me,Activeball)
bumperskirt.rotx=skirtAX(me,Activeball)
me.timerinterval = 150
me.timerenabled=1
End Sub
sub bumper1_timer
bumperskirt.rotx=0
bumperskirt.roty=0
me.timerenabled=0
end sub
'******************************************************
' SKIRT ANIMATION FUNCTIONS
'******************************************************
' NOTE: set bumper object timer to around 150-175 in order to be able
' to actually see the animation, adjust to your liking
Const PI = 3.1415926
Const SkirtTilt=3 'angle of skirt tilting in degrees
Function SkirtAX(bumper, bumperball)
skirtAX=cos(skirtA(bumper,bumperball))*(SkirtTilt) 'x component of angle
if (bumper.y<bumperball.y) then skirtAX=skirtAX*-1 'adjust for ball hit bottom half
End Function
Function SkirtAY(bumper, bumperball)
skirtAY=sin(skirtA(bumper,bumperball))*(SkirtTilt) 'y component of angle
if (bumper.x>bumperball.x) then skirtAY=skirtAY*-1 'adjust for ball hit left half
End Function
Function SkirtA(bumper, bumperball)
dim hitx, hity, dx, dy
hitx=bumperball.x
hity=bumperball.y
dy=Abs(hity-bumper.y) 'y offset ball at hit to center of bumper
if dy=0 then dy=0.0000001
dx=Abs(hitx-bumper.x) 'x offset ball at hit to center of bumper
skirtA=(atn(dx/dy)) '/(PI/180) 'angle in radians to ball from center of Bumper1
End Function
' Drain holes, vuks & saucers
Sub Drain_Hit:RandomSoundDrain drain:bsTrough.AddBall Me:End Sub
Sub LockMech_Hit:PlaySound "fx_kicker_enter":bsLock.AddBall Me:End Sub
Sub sw24_Hit:PlaySound "fx_kicker_enter":bsSaucer.AddBall 0:End Sub
' Rollovers & Ramp Switches
Sub sw11_Hit:Controller.Switch(11) = 1:wire1.transz=-6:End Sub
Sub sw11_UnHit:Controller.Switch(11) = 0:wire1.transz=0:End Sub
Sub sw16_Hit:Controller.Switch(16) = 1:wire2.transz=-6:End Sub
Sub sw16_UnHit:Controller.Switch(16) = 0:wire2.transz=0:End Sub
Sub sw15_Hit:Controller.Switch(15) = 1:wire3.transz=-6:End Sub
Sub sw15_UnHit:Controller.Switch(15) = 0:wire3.transz=0:End Sub
Sub sw12_Hit:Controller.Switch(12) = 1:wire4.transz=-6:End Sub
Sub sw12_UnHit:Controller.Switch(12) = 0:wire4.transz=0:End Sub
Sub sw23_Hit:Controller.Switch(23) = 1:End Sub
Sub sw23_UnHit:Controller.Switch(23) = 0:End Sub
Sub sw14_Hit:Controller.Switch(14) = 1:End Sub
Sub sw14_UnHit:Controller.Switch(14) = 0:End Sub
Sub sw44_Hit:Controller.Switch(44) = 1:wire6.transz=-6:End Sub
Sub sw44_UnHit:Controller.Switch(44) = 0:wire6.transz=0:End Sub
Sub sw45_Hit:Controller.Switch(45) = 1
plungelane=1
' Set ControlBall = ActiveBall
' contballinplay = True
wire5.transz=-6
End Sub
Sub sw45_UnHit:Controller.Switch(45) = 0:plungelane=0:wire5.transz=0:End Sub
Sub spinner_Spin:vpmTimer.PulseSw 13:PlaySoundAtLevelStatic ("fx_spinner"), gatesoundlevel, spinnerrod:End Sub
'Drop Targets
Sub Sw25_Hit:DTHit 25:End Sub
Sub Sw26_Hit:DTHit 26:End Sub
Sub Sw27_Hit:DTHit 27:End Sub
Sub Sw29_Hit:DTHit 29:End Sub
Sub Sw30_Hit:DTHit 30:End Sub
Sub Sw31_Hit:DTHit 31:End Sub
Sub Sw33_Hit:DTHit 33:End Sub
Sub Sw34_Hit:DTHit 34:End Sub
Sub Sw35_Hit:DTHit 35:End Sub
Sub Sw37_Hit:DTHit 37:End Sub
Sub Sw38_Hit:DTHit 38:End Sub
Sub Sw39_Hit:DTHit 39:End Sub
Sub SolDropUpLL(enabled)
If enabled Then
DTRaise 25
DTRaise 26
DTRaise 27
PlaySoundAtLevelStatic ("solenoid"), DrainSoundLevel, psw26
dropplate7.visible=1:dropplate8.visible=1:dropplate9.visible=1
End If
End Sub
Sub SolDropUpLR(enabled)
If enabled Then
DTRaise 29
DTRaise 30
DTRaise 31
PlaySoundAtLevelStatic ("solenoid"), DrainSoundLevel, psw30
dropplate4.visible=1:dropplate5.visible=1:dropplate6.visible=1
End If
End Sub
Sub SolDropUpUL(enabled)
If enabled Then
DTRaise 33
DTRaise 34
DTRaise 35
PlaySoundAtLevelStatic ("solenoid"), DrainSoundLevel, psw34
End If
End Sub
Sub SolDropUpUR(enabled)
If enabled Then
DTRaise 37
DTRaise 38
DTRaise 39
PlaySoundAtLevelStatic ("solenoid"), DrainSoundLevel, psw38
dropplate2.visible=1
End If
End Sub
'*********
'Solenoids
'*********
SolCallback(1) = "bsTrough.SolIn"
SolCallback(2) = "SolDropUpLL"
SolCallback(3) = "SolDropUpLR"
SolCallback(4) = "SolDropUpUL"
SolCallback(5) = "SolDropUpUR"
SolCallback(6) = "bsTrough.SolOut"
SolCallback(7) = "bsLock.SolOut"
SolCallback(8) = "bsSaucer.SolOut"
SolCallback(11) = "SolGi"
solcallback(15) = "vpmSolSound SoundFX(""ringing_bell"",DOFBell),"
SolCallback(23) = "vpmNudge.SolGameOn"
Sub SolGi(Enabled)
If Enabled Then
GiOFF
Else
GiON
end if
end sub
'***************************************************
' JP's VP10 Fading Lamps & Flashers
' Based on PD's Fading Light System
' SetLamp 0 is Off
' SetLamp 1 is On
' fading for non opacity objects is 4 steps
'***************************************************
Dim LampState(200), FadingLevel(200)
Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200), FlashRepeat(200)
'InitLamps() ' turn off the lights and flashers and reset them to the default parameters
'LampTimer.Interval = 10 ' lamp fading speed
'LampTimer.Enabled = 1
'
' *****************************************
' *** insert lights *****
' *****************************************
Dim PFLights(100,5), PFLightsCount(100), PFInsertOnPrim(100), PFInsertOnPrimMult(100), PFInsertMax
Dim PFInsertState(100), PFInsertStateNew(100), PFInsertChange(100)
'Dim LampState(200), FadingLevel(200)
'Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200), FlashRepeat(200)
PFInsertMax= 0
Sub InitLights(aColl, aColl2)
Dim obj, idx, mult, nr
For idx = 0 to 100 : PfInsertChange(idx) = False : Next
For Each obj In aColl
idx = CInt(left(obj.name, 2)) : mult = mid(obj.name, 4, 3)
obj.BlendDisableLightingFromBelow = 1
Set PFInsertOnPrim(idx) = obj : PfInsertOnPrimMult(idx) = mult
If idx > PfInsertMax then PfInsertMax = idx
PfInsertState(idx) = 0
Next
For Each obj In aColl2
idx = obj.TimerInterval
Set PFLights(idx, PFLightsCount(idx)) = obj
PFLightsCount(idx) = PFLightsCount(idx) + 1
Next
End Sub
Sub LampTimer_Timer()
Dim chgLamp, ii, nr, num, chg
chgLamp = Controller.ChangedLamps
If Not IsEmpty(chgLamp) Then
For ii = 0 To UBound(chgLamp)
For nr = 1 to PFLightsCount(chglamp(ii,0)) : PFLights(chglamp(ii,0),nr - 1).state = chglamp(ii,1) : Next
PfInsertStateNew(chglamp(ii,0)) = chglamp(ii,1)
If Not IsEmpty(PFInsertOnPrim(chglamp(ii,0))) Then PfInsertChange(chglamp(ii,0)) = True
LampState(chgLamp(ii, 0)) = chgLamp(ii, 1) 'keep the real state in an array
FadingLevel(chgLamp(ii, 0)) = chgLamp(ii, 1) + 4 'actual fading step
Next
End If
For ii = 0 To PfInsertMax
If PfInsertChange(ii) Then
If PFInsertState(ii) < PFInsertStateNew(ii) Then
PFInsertState(ii) = PFInsertState(ii) + 2 * ((PFInsertStateNew(ii) - PFInsertState(ii)) / 3)^2
Else
PFInsertState(ii) = PFInsertState(ii) + (PFInsertStateNew(ii) - PFInsertState(ii)) / 1.5
End If
If abs(PFInsertState(ii) - PFInsertStateNew(ii)) < 0.01 Then PFInsertState(ii) = PFInsertStatenew(ii) : PfInsertChange(ii) = False
PFInsertOnPrim(ii).BlendDisableLighting = 5 * PFInsertOnPrimMult(ii) * PFInsertState(ii)
End If
Next
If VR_Room = 0 Then
If VarHidden Then
UpdateLeds
End If
End If
UpdateLamps
End Sub
' ****************************************************************************
'******************** VR Backglass Flasher Light code **********************
' ****************************************************************************
' **********************************
' ***** Text Backglass Lights *****
' **********************************
Set LampCallback = GetRef("UpdateMultipleLamps")
Sub UpdateMultipleLamps()
If VR_Room = 1 Then
If Controller.Lamp(1) = 0 Then: f1.visible=0: else: f1.visible=1 ' Same Player Shoots Again
If Controller.Lamp(2) = 0 Then: f2.visible=0: else: f2.visible=1 ' Ball In Play
If Controller.Lamp(3) = 0 Then: f3.visible=0: else: f3.visible=1 ' Tilt
If Controller.Lamp(4) = 0 Then: f4.visible=0: else: f4.visible=1 ' Game Over
If Controller.Lamp(5) = 0 Then: f5.visible=0: else: f5.visible=1 ' Match
If Controller.Lamp(6) = 0 Then: f6.visible=0: else: f6.visible=1 ' High Score
If Controller.Lamp(8) = 0 Then: f8.visible=0: else: f8.visible=1 ' Bonus Ball Time
Else
f1.visible=0
f2.visible=0
f3.visible=0
f4.visible=0
f5.visible=0
f6.visible=0
f8.visible=0
End If
End Sub
dim GILvl : GILvl = 0
Sub UpdateLamps()
'backdrop lights
If VarHidden Then
NFadeT 1, l1, "same player shoots again"
NFadeT 2, l2, "ball in play"
NFadeT 3, l3, "tilt"
NFadeT 4, l4, "game over"
NFadeT 5, l5, "match"
NFadeT 6, l6, "highscore"
NFadeTm 7, l7a, "credits"
NFadeT 8, l8, "bonus ball time"
End If
'GI Primitive and bumper fading
If GIIsOff=false Then
if GILvl < 1 then 'GI ON --> raise GILvl "fast". Modify the equation to adjust primitive fading speed.