forked from LegendsUnchained/vpx-standalone-alp4k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Barracora (Williams 1981) w VR Room v2.1.3.vbs
4534 lines (3756 loc) · 155 KB
/
Barracora (Williams 1981) w VR Room v2.1.3.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
' Barracora / IPD No. 177 / September, 1981 / 4 Players
' Version 2.0 by UnclePaulie 2022
' Table nearly completely done from scratch. Only reuse was from Dids 1.2 VPX version was plastic images, apron image, and upper gate prims.
' Table includes Hybrid VR/desktop/cabinet modes, new upscaled playfield, VPW physics, Fleep sounds, Lampz, 3D inserts, new GI, sling corrections, targets, saucers, playfield mesh, etc.
' Significant time was spent on researching online videos, to ensure accuracy of shots, ball drops, kickouts, playability.
' 2.1 version has updated playfield and plastics done by redbone.
' Complete implementation details found at the bottom of the script.
Option Explicit
Randomize
'*******************************************
' Desktop, Cab, and VR OPTIONS
'*******************************************
' Desktop, Cab, and VR Room are automatically selected. However if in VR Room mode, you can change the environment with the magna save buttons.
const BallLightness = 2 '0 = dark, 1 = not as dark, 2 = bright, 3 = brightest
const cabsideblades = 1 '0 = off, 1 = on; some users want sideblades in the cabinet, some don't.
const usebell = 1 '0 = off, 1 = on. Very short bell sound for match, and ROM also calls it out on all coin entries.
Dim LUTset, DisableLUTSelector, LutToggleSound, LutToggleSoundLevel
LutToggleSound = True
LutToggleSoundLevel = .1
DisableLUTSelector = 0 ' Disables the ability to change LUT option with magna saves in game when set to 1
' *** If using VR Room:
const CustomWalls = 0 'set to 0 for Modern Minimal Walls, floor, and roof, 1 for Sixtoe's original walls and floor
const WallClock = 1 '1 Shows the clock in the VR minimal rooms only
const topper = 1 '0 = Off 1= On - Topper visible in VR Room only
const poster = 1 '1 Shows the flyer posters in the VR room only
const poster2 = 1 '1 Shows the flyer posters in the VR room only
' ****************************************************
'----- Shadow Options -----
Const DynamicBallShadowsOn = 1 '0 = no dynamic ball shadow ("triangles" near slings and such), 1 = enable dynamic ball shadow
Const AmbientBallShadowOn = 1 '0 = Static shadow under ball ("flasher" image, like JP's)
'1 = Moving ball shadow ("primitive" object, like ninuzzu's) - This is the only one that shows up on the pf when in ramps and fades when close to lights!
'2 = flasher image shadow, but it moves like ninuzzu's
'Ambient (Room light source)
Const AmbientBSFactor = 1 '0 to 1, higher is darker
Const AmbientMovement = 2 '1 to 4, higher means more movement as the ball moves left and right
Const offsetX = 0 'Offset x position under ball (These are if you want to change where the "room" light is for calculating the shadow position,)
Const offsetY = 0 'Offset y position under ball (for example 5,5 if the light is in the back left corner)
'Dynamic (Table light sources)
Const DynamicBSFactor = 1 '0 to 1, higher is darker
Const Wideness = 20 'Sets how wide the dynamic ball shadows can get (20 +5 thinness should be most realistic for a 50 unit ball)
Const Thinness = 5 'Sets minimum as ball moves away from source
'----- General Sound Options -----
Const VolumeDial = 0.8 ' Recommended values should be no greater than 1.
Const BallRollVolume = 0.5 'Level of ball rolling volume. Value between 0 and 1
Const RampRollVolume = 0.5 'Level of ramp rolling volume. Value between 0 and 1
'----- Phsyics Mods -----
Const TargetBouncerEnabled = 1 '0 = normal standup targets, 1 = bouncy targets, 2 = orig TargetBouncer
Const TargetBouncerFactor = 0.7 'Level of bounces. Recommmended value of 0.7 when TargetBouncerEnabled
'//////////////---- LUT (Colour Look Up Table) ----//////////////
'0 = Fleep Natural Dark 1
'1 = Fleep Natural Dark 2
'2 = Fleep Warm Dark
'3 = Fleep Warm Bright
'4 = Fleep Warm Vivid Soft
'5 = Fleep Warm Vivid Hard
'6 = Skitso Natural and Balanced
'7 = Skitso Natural High Contrast
'8 = 3rdaxis Referenced THX Standard
'9 = CalleV Punchy Brightness and Contrast
'10 = HauntFreaks Desaturated
'11 = Tomate Washed Out
'12 = VPW Original 1 to 1
'13 = Bassgeige
'14 = Blacklight
'15 = B&W Comic Book
'16 = Skitso New Warmer LUT
'17 = Original LUT
LoadLUT
'LUTset = 16 ' Override saved LUT for debug
SetLUT
ShowLUT_Init
' ****************************************************
' standard definitions
' ****************************************************
Dim VR_Room, cab_mode, DesktopMode: DesktopMode = Table1.ShowDT
If RenderingMode = 2 Then VR_Room=1 Else VR_Room=0 'VRRoom set based on RenderingMode in version 10.72
If Not DesktopMode and VR_Room=0 Then cab_mode=1 Else cab_mode=0
Const UseSolenoids = 2
Const UseLamps = 0
Const UseSync = 0
Const HandleMech = 0
Const UseGI = 0
Const cGameName = "barra_l1" 'ROM name
Const ballsize = 50
Const ballmass = 1
Const UsingROM = True 'The UsingROM flag is to indicate code that requires ROM usage.
'***********************
Const tnob = 3 'Total number of balls
Const lob = 0 'Locked balls
Dim tablewidth: tablewidth = Table1.width
Dim tableheight: tableheight = Table1.height
Dim i, BBall1, BBall2, BBall3, gBOT
Dim BIPL : BIPL = False 'Ball in plunger lane
dim gilvl
gilvl = 1
On Error Resume Next
ExecuteGlobal GetTextFile("controller.vbs")
If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
On Error Goto 0
LoadVPM "00990300", "S7.VBS", 3.36
'**********************************************************************************************************
'Solenoids
'**********************************************************************************************************
'SolCallbacks
SolCallback(1) = "SolDTLeftB" 'Drop Target Left B
SolCallback(2) = "SolDTLeftA" 'Drop Target Left A
SolCallback(3) = "SolDTLeftRR" 'Drop Target Left RR
SolCallback(4) = "SolDTRightA" 'Drop Target Right A
SolCallback(5) = "SolDTRightC" 'Drop Target Right C
SolCallback(6) = "SolDTRightO" 'Drop Target Right O
SolCallback(7) = "SolDTRightR" 'Drop Target Right R
SolCallback(8) = "SolDTRightAA" 'Drop Target Right A - 2nd one
SolCallback(9) = "SolDTLeftReset" 'Drop Target Left - B-A-RR Release
SolCallback(10) = "SolDTRightReset" 'Drop Target Right - A-C-O-R-A Release
SolCallback(11) = "SolOuthole" 'Outhole
SolCallback(12) = "SolBallRelease" 'Ball Release
SolCallback(13) = "SolTopEjectHole" 'Top Eject Hole
SolCallback(14) = "SolLoweEjectHole" 'Lower Eject Hole
SolCallback(15) = "Bell" 'Bell
SolCallback(17) = "UpperKickerGate" 'Opens the Upper Kicker Gate
SolCallback(sllflipper)="SolLFlipper"
SolCallback(slrflipper)="SolRFlipper"
'*******************************************
' Timers
'*******************************************
' The game timer interval is 10 ms
Sub GameTimer_Timer()
Cor.Update 'update ball tracking
RollingUpdate 'update rolling sounds
DoDTAnim 'handle drop target animations
DoSTAnim 'handle stand up target animations
SpinnerTimer
End Sub
' The frame timer interval is -1, so executes at the display frame rate
Sub FrameTimer_Timer()
FlipperVisualUpdate 'update flipper shadows and primitives
If DynamicBallShadowsOn Or AmbientBallShadowOn Then DynamicBSUpdate 'update ball shadows
If VR_Room=0 Then
DisplayTimer
End If
If VR_Room=1 Then
VRDisplayTimer
End If
End Sub
' This subroutine updates the flipper shadows and visual primitives
Sub FlipperVisualUpdate
FlipperLSh.RotZ = LeftFlipper.currentangle
FlipperRSh.RotZ = RightFlipper.currentangle
LFLogo.RotZ = LeftFlipper.CurrentAngle
RFlogo.RotZ = RightFlipper.CurrentAngle
End Sub
'**********************************************************************************************************
'Initiate Table
'**********************************************************************************************************
Sub table1_Init
vpmInit me
With Controller
.GameName = cGameName
If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description:Exit Sub
.SplashInfoLine = "Barracora (Williams 1981)"&chr(13)&"by UnclePaulie"
.HandleMechanics=0
.HandleKeyboard=0
.ShowDMDOnly=1
.ShowFrame=0
.ShowTitle=0
.Hidden = 1
.Games(cGameName).Settings.Value("sound") = 1 ' Set sound (0=OFF, 1=ON)
On Error Resume Next
.Run GetPlayerHWnd
If Err Then MsgBox Err.Description
On Error Goto 0
End With
' Nudging
vpmNudge.TiltSwitch = 1
vpmNudge.Sensitivity = 5
vpmNudge.TiltObj = Array(Bumper1, Bumper2, Bumper3, LeftFlipper, RightFlipper, LeftSlingshot, RightSlingshot)
'Ball initializations need for physical trough
Set BBall1 = BallRelease.CreateSizedballWithMass(Ballsize/2,Ballmass)
Set BBall2 = SlotCenter.CreateSizedballWithMass(Ballsize/2,Ballmass)
Set BBall3 = SlotLeft.CreateSizedballWithMass(Ballsize/2,Ballmass)
'Ball initializations
gBOT = Array(BBall1, BBall2, BBall3)
Controller.Switch(12) = 0
Controller.Switch(13) = 1
Controller.Switch(14) = 1
Controller.Switch(15) = 1
' Make drop target shadows visible
Dim xx
for each xx in ShadowDT
xx.visible=True
Next
' Make the off inserts easier to see when not lit
for each xx in inserts_off
xx.blenddisablelighting = 4
Next
' Make sure gate in plunger lane is in closed state at start
PlungerLaneGate.open = false
' Turn on the Flupper bumper lights at game launch
FlBumperFadeTarget(1) = .95
FlBumperFadeTarget(2) = .95
FlBumperFadeTarget(3) = .95
if VR_Room = 1 Then
setup_backglass()
SetBackglass
End If
PinCab_Backglass.blenddisablelighting = 3
End Sub
Sub table1_Paused:Controller.Pause = 1:End Sub
Sub table1_unPaused:Controller.Pause = 0:End Sub
Sub table1_exit
SaveLUT
Controller.stop
End Sub
'********************************************
' Keys and Plunger code
'********************************************
Sub table1_KeyDown(ByVal Keycode)
If keycode = LeftMagnaSave Then
bLutActive = True
End If
If keycode = RightMagnaSave Then
If bLutActive Then
if DisableLUTSelector = 0 then
If LutToggleSound Then
Playsound "click", 0, LutToggleSoundLevel * VolumeDial, 0, 0.2, 0, 0, 0, 1
End If
LUTSet = LUTSet + 1
if LutSet > 17 then LUTSet = 0
SetLUT
ShowLUT
end if
End If
End If
If keycode = LeftTiltKey Then Nudge 90, 1 ': SoundNudgeLeft
If keycode = RightTiltKey Then Nudge 270, 1 ': SoundNudgeRight
If keycode = CenterTiltKey Then Nudge 0, 1 ': SoundNudgeCenter
If KeyCode = PlungerKey Then
Plunger.PullBack
SoundPlungerPull()
TimerVRPlunger.Enabled = True
TimerVRPlunger1.Enabled = False
PinCab_Shooter.Y = -351
End If
If keycode = LeftFlipperKey Then
controller.switch(34) = 1
VRFlipperButtonLeft.X = VRFlipperButtonLeft.X + 8
FlipperActivate LeftFlipper, LFPress
End If
If keycode = RightFlipperKey Then
controller.switch(35) = 1
VRFlipperButtonRight.X = VRFlipperButtonRight.X - 8
FlipperActivate RightFlipper, RFPress
End If
If keycode = StartGameKey Then
StartButton.y = 811.9485 - 5
SoundStartButton
End If
If keycode = keyInsertCoin1 or keycode = keyInsertCoin2 or keycode = keyInsertCoin3 or keycode = keyInsertCoin4 Then 'Use this for ROM based games
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 vpmKeyDown(keycode) Then Exit Sub
End Sub
Sub table1_KeyUp(ByVal Keycode)
If keycode = LeftMagnaSave Then
bLutActive = False
End If
If keycode = PlungerKey Then
Plunger.Fire
If BIPL = 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
TimerVRPlunger.Enabled = False
TimerVRPlunger1.Enabled = True
PinCab_Shooter.Y = -351
End If
If keycode = LeftFlipperKey Then
controller.switch(34) = 0
VRFlipperButtonLeft.X = VRFlipperButtonLeft.X - 8
FlipperDeActivate LeftFlipper, LFPress
End If
If keycode = RightFlipperKey Then
controller.switch(35) = 0
VRFlipperButtonRight.X = VRFlipperButtonRight.X + 8
FlipperDeActivate RightFlipper, RFPress
End If
If keycode = StartGameKey Then
StartButton.y = 811.9485
End If
if vpmKeyUp(keycode) Then Exit Sub
End Sub
'*******************************************
' Flippers
'*******************************************
Const ReflipAngle = 20
' Flipper Solenoid Callbacks (these subs mimics how you would handle flippers in ROM based tables)
Sub SolLFlipper(Enabled)
If Enabled Then
LF.Fire 'leftflipper.rotatetoend
If leftflipper.currentangle < leftflipper.endangle + ReflipAngle Then
RandomSoundReflipUpLeft LeftFlipper
Else
SoundFlipperUpAttackLeft LeftFlipper
RandomSoundFlipperUpLeft LeftFlipper
End If
Else
LeftFlipper.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 'rightflipper.rotatetoend
If rightflipper.currentangle > rightflipper.endangle - ReflipAngle Then
RandomSoundReflipUpRight RightFlipper
Else
SoundFlipperUpAttackRight RightFlipper
RandomSoundFlipperUpRight RightFlipper
End If
Else
RightFlipper.RotateToStart
If RightFlipper.currentangle > RightFlipper.startAngle + 5 Then
RandomSoundFlipperDownRight RightFlipper
End If
FlipperRightHitParm = FlipperUpSoundLevel
End If
End Sub
' Flipper collide subs
Sub LeftFlipper_Collide(parm)
CheckLiveCatch Activeball, LeftFlipper, LFCount, parm
LeftFlipperCollide parm
End Sub
Sub RightFlipper_Collide(parm)
CheckLiveCatch Activeball, RightFlipper, RFCount, parm
RightFlipperCollide parm
End Sub
'*******************************************
' Rollovers
'*******************************************
Sub sw9_Hit:Controller.Switch(9) = 1:End Sub
Sub sw9_UnHit:Controller.Switch(9) = 0:End Sub
Sub sw16_Hit:Controller.Switch(16) = 1:End Sub
Sub sw16_UnHit:Controller.Switch(16) = 0:End Sub
Sub sw17_Hit:Controller.Switch(17) = 1:End Sub
Sub sw17_UnHit:Controller.Switch(17) = 0:End Sub
Sub sw18_Hit:Controller.Switch(18) = 1:End Sub
Sub sw18_UnHit:Controller.Switch(18) = 0:End Sub
Sub sw19_Hit:Controller.Switch(19) = 1:End Sub
Sub sw19_UnHit:Controller.Switch(19) = 0:End Sub
Sub sw23_Hit:Controller.Switch(23) = 1:End Sub
Sub sw23_UnHit:Controller.Switch(23) = 0:End Sub
Sub sw24_Hit:Controller.Switch(24) = 1:End Sub
Sub sw24_UnHit:Controller.Switch(24) = 0:End Sub
Sub sw26_Hit:Controller.Switch(26) = 1:End Sub
Sub sw26_UnHit:Controller.Switch(26) = 0:End Sub
Sub sw31_Hit
Controller.Switch(31) = 1
'emulate slowing down ball slightly in the inlane triggers
activeball.angmomz= 0
activeball.vely = activeball.vely * 0.8
End Sub
Sub sw31_UnHit:Controller.Switch(31) = 0:End Sub
Sub sw32_Hit
Controller.Switch(32) = 1
'emulate slowing down ball slightly in the inlane triggers
activeball.angmomz= 0
activeball.vely = activeball.vely * 0.8
End Sub
Sub sw32_UnHit:Controller.Switch(32) = 0:End Sub
'*******************************************
' Spinners
'*******************************************
Sub sw25_Spin()
vpmtimer.PulseSw 25
SoundSpinner sw25
End Sub
'***********Rotate Spinner
Dim Angle
Sub SpinnerTimer
SpinnerPrim.Rotx = sw25.CurrentAngle
Angle = (sin (sw25.CurrentAngle-180))
SpinnerRod.TransX = sin( (sw25.CurrentAngle+180) * (2*PI/360)) * 12
SpinnerRod.TransZ = sin( (sw25.CurrentAngle- 90) * (2*PI/360)) * 3.5
End Sub
'*******************************************
' Bumpers
'*******************************************
Sub Bumper1_Hit
RandomSoundBumperTop Bumper1
vpmTimer.PulseSw 20
End Sub
Sub Bumper2_Hit
RandomSoundBumperMiddle Bumper2
vpmTimer.PulseSw 21
End Sub
Sub Bumper3_Hit
RandomSoundBumperBottom Bumper3
vpmTimer.PulseSw 22
End Sub
'********************************************
' Targets
'********************************************
'*******************************************
' Round Targets
'*******************************************
Sub sw27_Hit
STHit 27
End Sub
Sub sw27o_Hit
TargetBouncer Activeball, 1
End Sub
Sub sw28_Hit
STHit 28
End Sub
Sub sw28o_Hit
TargetBouncer Activeball, 1
End Sub
Sub sw33_Hit
STHit 33
End Sub
Sub sw33o_Hit
TargetBouncer Activeball, 1
End Sub
'********************************************
' Drop Target Hits
'********************************************
Sub sw41_Hit
DTHit 41
End Sub
Sub sw42_Hit
DTHit 42
End Sub
Sub sw43_Hit
DTHit 43
End Sub
Sub sw44_Hit
DTHit 44
End Sub
Sub sw45_Hit
DTHit 45
End Sub
Sub sw46_Hit
DTHit 46
End Sub
Sub sw47_Hit
DTHit 47
End Sub
Sub sw48_Hit
DTHit 48
End Sub
'********************************************
' Drop Target Solenoid Controls
'********************************************
Sub SolDTLeftB(enabled)
if enabled then
RandomSoundDropTargetReset sw41p
DTRaise 41
dtsh41.visible=True
end if
End Sub
Sub SolDTLeftA(enabled)
if enabled then
RandomSoundDropTargetReset sw42p
DTRaise 42
dtsh42.visible=True
end if
End Sub
Sub SolDTLeftRR(enabled)
if enabled then
RandomSoundDropTargetReset sw43p
DTRaise 43
dtsh43.visible=True
end if
End Sub
Sub SolDTRightA(enabled)
if enabled then
RandomSoundDropTargetReset sw44p
DTRaise 44
dtsh44.visible=True
end if
End Sub
Sub SolDTRightC(enabled)
if enabled then
RandomSoundDropTargetReset sw45p
DTRaise 45
dtsh45.visible=True
end if
End Sub
Sub SolDTRightO(enabled)
if enabled then
RandomSoundDropTargetReset sw46p
DTRaise 46
dtsh46.visible=True
end if
End Sub
Sub SolDTRightR(enabled)
if enabled then
RandomSoundDropTargetReset sw47p
DTRaise 47
dtsh47.visible=True
end if
End Sub
Sub SolDTRightAA(enabled)
if enabled then
RandomSoundDropTargetReset sw48p
DTRaise 48
dtsh48.visible=True
end if
End Sub
Sub SolDTLeftReset(enabled)
dim xx
if enabled then
RandomSoundDropTargetReset sw42p
DTDrop 41
DTDrop 42
DTDrop 43
for each xx in ShadowDTLeft
xx.visible=False
Next
end if
End Sub
Sub SolDTRightReset(enabled)
dim xx
if enabled then
RandomSoundDropTargetReset sw46p
DTDrop 44
DTDrop 45
DTDrop 46
DTDrop 47
DTDrop 48
for each xx in ShadowDTRight
xx.visible=False
Next
end if
End Sub
'*******************************************
' Leaf Standups
'*******************************************
Sub RubberBand014_Hit():vpmtimer.pulsesw 37:End Sub
Sub RubberBand012_Hit():vpmtimer.pulsesw 38:End Sub
Sub RubberBand010_Hit():vpmtimer.pulsesw 39:End Sub
Sub RubberBand006_Hit():vpmtimer.pulsesw 40:End Sub
'*******************************************
' Sling Shot Animations
' Rstep and Lstep are the variables that increment the animation
'*******************************************
Dim RStep, Lstep, R2Step
Sub RightSlingShot_Slingshot
RS.VelocityCorrect(ActiveBall)
RandomSoundSlingshotRight Sling1
vpmTimer.PulseSw 30
RSling.Visible = 0
RSling1.Visible = 1
sling1.rotx = 12
RStep = 0
RightSlingShot.TimerEnabled = 1
End Sub
Sub RightSlingShot_Timer
Select Case RStep
Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.rotx = 6
Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.rotx = 0:RightSlingShot.TimerEnabled = 0:
End Select
RStep = RStep + 1
End Sub
Sub LeftSlingShot_Slingshot
LS.VelocityCorrect(ActiveBall)
RandomSoundSlingshotLeft Sling2
vpmTimer.PulseSw 29
LSling.Visible = 0
LSling1.Visible = 1
sling2.rotx = 12
LStep = 0
LeftSlingShot.TimerEnabled = 1
End Sub
Sub LeftSlingShot_Timer
Select Case LStep
Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.rotx = 6
Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.rotx = 0:LeftSlingShot.TimerEnabled = 0:
End Select
LStep = LStep + 1
End Sub
'******************************************************
' TROUGH BASED ON FOZZY and Rothbauerw
'******************************************************
Sub BallRelease_Hit : Controller.Switch(15) = 1 : UpdateTrough : End Sub
Sub BallRelease_UnHit : Controller.Switch(15) = 0 : UpdateTrough : End Sub
Sub SlotCenter_Hit : Controller.Switch(14) = 1 : UpdateTrough : End Sub
Sub SlotCenter_UnHit : Controller.Switch(14) = 0 : UpdateTrough : End Sub
Sub SlotLeft_Hit : Controller.Switch(13) = 1 : UpdateTrough : End Sub
Sub SlotLeft_UnHit : Controller.Switch(13) = 0 : UpdateTrough : End Sub
Sub UpdateTrough
UpdateTroughTimer.Interval = 100 '300 increased speed to ensure balls update before drain kicks
UpdateTroughTimer.Enabled = 1
End Sub
Sub UpdateTroughTimer_Timer
If BallRelease.BallCntOver = 0 Then SlotCenter.kick 60, 8
If SlotCenter.BallCntOver = 0 Then SlotLeft.kick 60, 8
Me.Enabled = 0
End Sub
'********************************************
' Drain hole and saucer kickers
'********************************************
Dim RNDKickValue1, RNDKickAngle1, RNDKickValue2, RNDKickAngle2 'Random Values for saucer kick and angles
Sub SolOuthole(Enabled)
If Enabled Then
Drain.kick 60, 15
End If
End Sub
Sub SolBallRelease(enabled)
If enabled Then
BallRelease.kick 60, 12
RandomSoundBallRelease BallRelease
End If
End Sub
Sub Drain_Hit()
UpdateTrough
vpmTimer.AddTimer 200, "Controller.Switch(12) = 1'" ' Delaying the drain switch to give trough time to update.
RandomSoundDrain Drain
End Sub
Sub Drain_UnHit()
Controller.Switch(12) = 0
End Sub
Sub sw10_Hit()
SoundSaucerLock
vpmTimer.AddTimer 300, "Controller.Switch(10) = 1'" ' Delaying the top eject switch just a little.
End Sub
Sub SolTopEjectHole (Enabled)
if enabled Then
RNDKickAngle1 = RndInt(63.5, 67.5) ' Generate random value between 63.5 and 67.5. (Variance of 4)
RNDKickValue1 = RndInt(10, 16) ' Generate random value between 10 and 16. (Variance of 6)
SoundSaucerKick 1, sw10
sw10.kick RNDKickAngle1, RNDKickValue1
controller.switch(10) = 0
end if
End sub
Sub sw11_Hit()
SoundSaucerLock
controller.Switch(11) = 1
End Sub
Sub SolLoweEjectHole (Enabled)
if enabled Then
RNDKickAngle2 = RndInt(148, 150) ' Generate random value between 148 and 150. (Variance of 2)
RNDKickValue2 = RndInt(9, 12) ' Generate random value between 9 and 12. (Variance of 3)
SoundSaucerKick 1, sw11
sw11.kick RNDKickAngle2, RNDKickValue2
controller.switch(11) = 0
end if
End sub
Sub UpperKickerGate(enabled)
If enabled Then
Gate1.open = True
Else
Gate1.open = False
End If
End Sub
'*******************************************
' Bell Solenoid
'*******************************************
Sub Bell(Enabled)
If enabled Then
If usebell = 1 Then
PlaySoundAtLevelStaticLoop("ringing_bell"), KnockerSoundLevel, KnockerPosition
End If
Else
stopsound "ringing_bell"
End If
End Sub
'***************************************************************
'**** VPW DYNAMIC BALL SHADOWS by Iakki, Apophis, and Wylte
'***************************************************************
' *** Required Functions, enable these if they are not already present elswhere in your table
Function max(a,b)
if a > b then
max = a
Else
max = b
end if
end Function
' *** Trim or extend these to match the number of balls/primitives/flashers on the table! (will throw errors if there aren't enough objects)
dim objrtx1(3), objrtx2(3)
dim objBallShadow(3)
Dim OnPF(3)
Dim BallShadowA
BallShadowA = Array (BallShadowA0,BallShadowA1,BallShadowA2)
Dim DSSources(30), numberofsources
' *** The Shadow Dictionary
Dim bsDict
Set bsDict = New cvpmDictionary
Const bsNone = "None"
Const bsWire = "Wire"
Const bsRamp = "Ramp"
Const bsRampClear = "Clear"
'Initialization
DynamicBSInit
sub DynamicBSInit()
Dim iii, source
for iii = 0 to tnob - 1 'Prepares the shadow objects before play begins
Set objrtx1(iii) = Eval("RtxBallShadow" & iii)
objrtx1(iii).material = "RtxBallShadow" & iii
objrtx1(iii).z = 1 + iii/1000 + 0.01 'Separate z for layering without clipping
objrtx1(iii).visible = 0
Set objrtx2(iii) = Eval("RtxBall2Shadow" & iii)
objrtx2(iii).material = "RtxBallShadow2_" & iii
objrtx2(iii).z = 1 + iii/1000 + 0.02
objrtx2(iii).visible = 0
Set objBallShadow(iii) = Eval("BallShadow" & iii)
objBallShadow(iii).material = "BallShadow" & iii
UpdateMaterial objBallShadow(iii).material,1,0,0,0,0,0,AmbientBSFactor,RGB(0,0,0),0,0,False,True,0,0,0,0
objBallShadow(iii).Z = 1 + iii/1000 + 0.04
objBallShadow(iii).visible = 0
BallShadowA(iii).Opacity = 100*AmbientBSFactor
BallShadowA(iii).visible = 0
Next
iii = 0
For Each Source in DynamicSources
DSSources(iii) = Array(Source.x, Source.y)
' If Instr(Source.name , "Left") > 0 Then DSGISide(iii) = 0 Else DSGISide(iii) = 1 'Adapted for TZ with GI left / GI right
iii = iii + 1
Next
numberofsources = iii
end sub
Sub BallOnPlayfieldNow(yeh, num) 'Only update certain things once, save some cycles
If yeh Then
OnPF(num) = True
bsRampOff gBOT(num).ID
' debug.print "Back on PF"
UpdateMaterial objBallShadow(num).material,1,0,0,0,0,0,AmbientBSFactor,RGB(0,0,0),0,0,False,True,0,0,0,0
objBallShadow(num).size_x = 5
objBallShadow(num).size_y = 4.5
objBallShadow(num).visible = 1
BallShadowA(num).visible = 0
BallShadowA(num).Opacity = 100 * AmbientBSFactor
Else
OnPF(num) = False
' debug.print "Leaving PF"
End If
End Sub
Sub DynamicBSUpdate
Dim falloff: falloff = 150 'Max distance to light sources, can be changed dynamically if you have a reason
Dim ShadowOpacity1, ShadowOpacity2
Dim s, LSd, iii
Dim dist1, dist2, src1, src2
Dim bsRampType
'Hide shadow of deleted balls
For s = UBound(gBOT) + 1 to tnob - 1
objrtx1(s).visible = 0
objrtx2(s).visible = 0
objBallShadow(s).visible = 0
BallShadowA(s).visible = 0
Next
If UBound(gBOT) < lob Then Exit Sub 'No balls in play, exit
'The Magic happens now
For s = lob to UBound(gBOT)
' *** Normal "ambient light" ball shadow
'Layered from top to bottom. If you had an upper pf at for example 80 units and ramps even above that, your Elseif segments would be z>110; z<=110 And z>100; z<=100 And z>30; z<=30 And z>20; Else (under 20)
'Primitive shadow on playfield, flasher shadow in ramps
If AmbientBallShadowOn = 1 Then
'** Above the playfield
If gBOT(s).Z > 30 Then
If OnPF(s) Then BallOnPlayfieldNow False, s 'One-time update
bsRampType = getBsRampType(gBOT(s).id)
' debug.print bsRampType
If Not bsRampType = bsRamp Then 'Primitive visible on PF
objBallShadow(s).visible = 1
objBallShadow(s).X = gBOT(s).X + (gBOT(s).X - (tablewidth/2))/(Ballsize/AmbientMovement) + offsetX
objBallShadow(s).Y = gBOT(s).Y + offsetY
objBallShadow(s).size_x = 5 * ((gBOT(s).Z+BallSize)/80) 'Shadow gets larger and more diffuse as it moves up
objBallShadow(s).size_y = 4.5 * ((gBOT(s).Z+BallSize)/80)
UpdateMaterial objBallShadow(s).material,1,0,0,0,0,0,AmbientBSFactor*(30/(gBOT(s).Z)),RGB(0,0,0),0,0,False,True,0,0,0,0
Else 'Opaque, no primitive below
objBallShadow(s).visible = 0
End If
If bsRampType = bsRampClear Or bsRampType = bsRamp Then 'Flasher visible on opaque ramp
BallShadowA(s).visible = 1
BallShadowA(s).X = gBOT(s).X + offsetX
BallShadowA(s).Y = gBOT(s).Y + offsetY + BallSize/10
BallShadowA(s).height=gBOT(s).z - BallSize/4 + s/1000 'This is technically 1/4 of the ball "above" the ramp, but it keeps it from clipping the ramp
If bsRampType = bsRampClear Then BallShadowA(s).Opacity = 50 * AmbientBSFactor
Elseif bsRampType = bsWire or bsRampType = bsNone Then 'Turn it off on wires or falling out of a ramp
BallShadowA(s).visible = 0
End If
'** On pf, primitive only
Elseif gBOT(s).Z <= 30 And gBOT(s).Z > 20 Then
If Not OnPF(s) Then BallOnPlayfieldNow True, s
objBallShadow(s).X = gBOT(s).X + (gBOT(s).X - (tablewidth/2))/(Ballsize/AmbientMovement) + offsetX
objBallShadow(s).Y = gBOT(s).Y + offsetY
' objBallShadow(s).Z = gBOT(s).Z + s/1000 + 0.04 'Uncomment (and adjust If/Elseif height logic) if you want the primitive shadow on an upper/split pf
'** Under pf, flasher shadow only
Else
If OnPF(s) Then BallOnPlayfieldNow False, s
objBallShadow(s).visible = 0