-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathCSI (Stern 2008)_VPX_1.00.vbs
1163 lines (961 loc) · 35.7 KB
/
CSI (Stern 2008)_VPX_1.00.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
Option Explicit
Randomize
' Thalamus 2018-07-24
' Added InitVpmFFlipsSAM
' Thalamus 2018-11-01 : Improved directional sounds
' Please import fx_kicker-enter and fx_sensor to the table, they are
' referenced but not included.
' !! NOTE : Table not verified yet !!
' Options
' Volume devided by - lower gets higher sound
Const VolDiv = 2000 ' Lower number, louder ballrolling/collition sound
Const VolCol = 10 ' Ball collition divider ( voldiv/volcol )
' The rest of the values are multipliers
'
' .5 = lower volume
' 1.5 = higher volume
Const VolBump = 2 ' Bumpers volume.
Const VolRol = 1 ' Rollovers volume.
Const VolGates = 1 ' Gates volume.
Const VolMetal = 1 ' Metals volume.
Const VolRB = 1 ' Rubber bands volume.
Const VolRH = 1 ' Rubber hits volume.
Const VolPo = 1 ' Rubber posts volume.
Const VolPi = 1 ' Rubber pins volume.
Const VolPlast = 1 ' Plastics volume.
Const VolTarg = 1 ' Targets volume.
Const VolWood = 1 ' Woods volume.
Const VolKick = 1 ' Kicker volume.
Const VolSpin = 1.5 ' Spinners volume.
Const VolFlip = 1 ' Flipper volume.
Const BallSize =48
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 cGameName="csi_240",UseSolenoids=1,UseLamps=0,UseGI=0,SSolenoidOn="SolOn",SSolenoidOff="SolOff", SCoin="coin"
LoadVPM "01560000", "Sam.VBS", 3.38
Dim DesktopMode: DesktopMode = Table1.ShowDT
If DesktopMode = True Then 'Show Desktop components
Ramp16.visible=1
Ramp15.visible=1
Primitive13.visible=1
Else
Ramp16.visible=0
Ramp15.visible=0
Primitive13.visible=0
End if
'*************************************************************
'Solenoid Call backs
'**********************************************************************************************************
SolCallBack(1) = "SolTrough"
SolCallBack(2) = "SolAutoPlungerIM"
SolCallback(3) = "Mag.MagnetOn= "
SolCallback(4) = "bsLEject.SolOut" 'Left Eject
SolCallback(5) = "SolLeftPostDown" 'Left up down Post
SolCallback(6) = "SolCentrifuge" 'Centrifuge Motor
SolCallback(7) = "dtLDrop.SolDropUp" 'Drop Targets
SolCallback(12) = "SolCLock" 'CenterLock
SolCallback(13) = "bsRVuk.SolOut" 'Rig77ht Eject
SolCallback(15) = "SolLFlipper"
SolCallback(16) = "SolRFlipper"
'SolCallback(27) = "SolIman" 'Centrifuge Motor Relay
SolCallback(29) = "SolSkullMotor" 'Skull Motor
'SolCallback(30) = "SolRightPostDown" 'Right up down Post
SolCallback(32) = "SolSkullMotorRelay" 'Skull Motor Relay
'Flash Lamps
SolCallBack(19) = "setlamp 119," 'Bumpers x2
SolCallBack(20) = "setlamp 120," 'Centrifuge
SolCallBack(21) = "Setlamp 121," 'Skull x3
SolCallBack(22) = "setlamp 122," 'Bumpers x3
SolCallBack(23) = "setlamp 123," 'Background x2
SolCallBack(26) = "setlamp 126," 'Left Spinner
SolCallBack(28) = "setlamp 128," 'Microscopio
SolCallBack(31) = "setlamp 131," 'Right Spinner
Sub SolLFlipper(Enabled)
If Enabled Then
PlaySoundAtVol SoundFX("fx_Flipperup",DOFContactors),LeftFlipper,VolFlip:LeftFlipper.RotateToEnd:LeftFlipper1.RotateToEnd
Else
PlaySoundAtVol SoundFX("fx_Flipperdown",DOFContactors),LeftFlipper,VolFlip:LeftFlipper.RotateToStart:LeftFlipper1.RotateToStart
End If
End Sub
Sub SolRFlipper(Enabled)
If Enabled Then
PlaySoundAtVol SoundFX("fx_Flipperup",DOFContactors),RightFlipper,VolFlip:RightFlipper.RotateToEnd
Else
PlaySoundAtVol SoundFX("fx_Flipperdown",DOFContactors),RightFlipper,VolFlip:RightFlipper.RotateToStart
End If
End Sub
'**********************************************************************************************************
'Solenoid Controlled toys
'**********************************************************************************************************
'Trough Ball
Sub SolTrough(Enabled)
If Enabled Then
bsTrough.ExitSol_On
vpmTimer.PulseSw 22
End If
End Sub
Sub SolAutoPlungerIM(Enabled)
If Enabled Then
PlungerIM.AutoFire
End If
End Sub
'Locks Post Down
'Left
Sub SolLeftPostDown(Enabled)
If Enabled Then
LockPosDown.IsDropped = 0
LockPosDownP.z = 35
PlaySound SoundFX("Diverter",DOFContactors) ' TODO
else
LockPosDown.IsDropped = 1
LockPosDownP.z = -65
PlaySound SoundFX("Diverter",DOFContactors)
End If
End Sub
'Right
Sub SolRightPostDown(Enabled)
If Enabled Then
LockPosDownR.IsDropped = 0
LockPosDownRP.z = 35
PlaySound SoundFX("Diverter",DOFContactors)
else
LockPosDownR.IsDropped = 1
LockPosDownRP.z = -65
PlaySound SoundFX("Diverter",DOFContactors)
End If
End Sub
'Centrifuge Motor
Sub SolCentrifuge(Enabled)
If Enabled Then
Sw34a.Enabled = 1
Else
Sw34a.Enabled = 0
End If
End Sub
'Ball Locks
Sub SolCLock(Enabled)
If Enabled Then
Div.IsDropped = 0
else
Div.IsDropped = 1
End If
End Sub
'Stern-Sega GI
set GICallback = GetRef("UpdateGI")
Sub UpdateGI(no, Enabled)
If Enabled Then
dim xx, xxx
For each xx in GI:xx.State = 1: Next
For each xxx in GI2:xxx.visible = 1: Next
PlaySound "fx_relay"
Else
For each xx in GI:xx.State = 0: Next
For each xxx in GI2:xxx.visible = 0: Next
PlaySound "fx_relay"
End If
End Sub
'**********************************************************************************************************
'Initiate Table
'**********************************************************************************************************
Dim bsTrough, Mag, bsLEject, bsRVuk, dtLDrop
Sub Table1_Init
vpmInit Me
On Error Resume Next
With Controller
.GameName = cGameName
If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
.SplashInfoLine = "CSI (Stern 2008)"&chr(13)&"You Suck"
.HandleMechanics=0
.HandleKeyboard=0
.ShowDMDOnly=1
.ShowFrame=0
.ShowTitle=0
.hidden = 0
On Error Resume Next
.Run GetPlayerHWnd
If Err Then MsgBox Err.Description
On Error Goto 0
End With
On Error Goto 0
PinMAMETimer.Interval = PinMAMEInterval
PinMAMETimer.Enabled = 1
vpmNudge.TiltSwitch = -7
vpmNudge.Sensitivity = 1
vpmNudge.TiltObj = Array(LeftSlingshot, RightSlingshot)
' Trough & Ball Release
Set bsTrough = New cvpmBallStack
bsTrough.InitSw 0, 21, 20, 19, 18, 0, 0, 0
bsTrough.InitKick BallRelease, 90, 10
bsTrough.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors)
bsTrough.IsTrough = True
bsTrough.Balls = 4
Set Mag= New cvpmMagnet
Mag.InitMagnet Magnet, 105
Mag.Solenoid = 3
Mag.GrabCenter = true
Mag.CreateEvents "Mag"
'Left Eject
Set bsLEject = New cvpmSaucer
With bsLEject
.InitExitVariance 3,4
.InitKicker Sw35, 35, 170, 30, 1.56
.InitSounds "fx_sensor", SoundFX(SSolenoidOn,DOFContactors), SoundFX("Popper",DOFContactors)
.CreateEvents "bsLEject", Sw35
End With
' Set bsLEject = new cvpmBallStack
' bsLEject.InitSw 0, 35, 0, 0, 0, 0, 0, 0
' bsLEject.InitKick sw35, 170, 25, 1.5
' bsLEject.KickZ = 1.5
' bsLEject.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
' bsLEject.KickAngleVar = 2
' bsLEject.KickBalls = 1
' Right vuk
Set bsRVuk = New cvpmBallStack
bsRVuk.InitSaucer Sw36, 36, 237, 29
bsRVuk.KickZ = 1.38
bsRVuk.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
Set dtLDrop = new cvpmDropTarget
dtLDrop.Initdrop Array(Sw2,Sw3,Sw4), Array(2,3,4)
dtLDrop.InitSnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
Div.IsDropped = 1
Controller.switch(10) = 1 'Opto switch: inverted logic
Controller.switch(11) = 1 'Opto switch: inverted logic
Controller.switch(12) = 1 'Opto switch: inverted logic
BolaPL.Visible = 0
BolaPR.Visible = 0
InitVpmFFlipsSAM
End Sub
'**********************************************************************************************************
'Plunger code
'**********************************************************************************************************
Sub Table1_KeyDown(ByVal KeyCode)
If KeyDownHandler(keycode) Then Exit Sub
If keycode = PlungerKey Then Plunger.Pullback:playsoundAtVol"plungerpull", plunger, 1
if KeyCode = LeftTiltKey Then Nudge 90, 4
if KeyCode = RightTiltKey Then Nudge 270, 4
if KeyCode = CenterTiltKey Then Nudge 0, 4
End Sub
Sub Table1_KeyUp(ByVal KeyCode)
If KeyUpHandler(keycode) Then Exit Sub
If keycode = PlungerKey Then Plunger.Fire:PlaySoundAtVol"plunger", plunger, 1
End Sub
' Impulse Plunger
Dim PlungerIM
Const IMPowerSetting = 60
Const IMTime = 0.6
Set plungerIM = New cvpmImpulseP
With plungerIM
.InitImpulseP swplunger, IMPowerSetting, IMTime
.Random 0.3
.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
.CreateEvents "plungerIM"
End With
'**********************************************************************************************************
' Drain hole and kickers
Sub Drain_Hit:bsTrough.addball me : playsoundAtVol"drain",drain,1 : End Sub
Sub Sw36_Hit: bsRVuk.AddBall 0: playsoundAtVol "popper_ball",sw36,1: End Sub
Sub Sw35b_hit:PlaySoundAtVol "fx_kicker-enter",ActiveBall, 1: Sw35b.enabled = 0 : End Sub
Sub Sw35_UnHit: Sw35bTimer.interval = 400: Sw35bTimer.enabled = 1 :End Sub'vpmtimer.addtimer 200, "Sw35b.enabled = 1 '" :End Sub
Sub Sw35bTimer_Timer
Sw35bTimer.enabled = 0
Sw35b.enabled = 1
End Sub
'Dim bBall
'Sub sw35_Hit
' playsound "popper_ball"
' Set bBall = ActiveBall:Me.TimerEnabled = 1
' bsLEject.AddBall 0
'End Sub
'Sub sw35_Timer
' Do While bBall.Z > 0
' bBall.Z = bBall.Z -5
' Exit Sub
' Loop
' Me.DestroyBall
' Me.TimerEnabled = 0
'End Sub
'Drop Targets
Sub Sw2_Dropped:dtLDrop.Hit 1:End Sub
Sub Sw3_Dropped:dtLDrop.Hit 2:End Sub
Sub Sw4_Dropped:dtLDrop.Hit 3:End Sub
'Mircroscope magnet
Sub Magnet_Hit:Mag.AddBall ActiveBall:End Sub
Sub Magnet_UnHit:Mag.RemoveBall ActiveBall:End Sub
'Stand Up Targets
Sub Sw1_Hit:vpmTimer.PulseSw 1:End Sub
Sub Sw41_Hit:vpmTimer.PulseSw 41:End Sub
Sub Sw44_Hit:vpmTimer.PulseSw 44:End Sub
Sub Sw45_Hit:vpmTimer.PulseSw 45:End Sub
Sub Sw49_Hit:vpmTimer.PulseSw 49:End Sub
'Rollovers
Sub Sw5_Hit:Controller.Switch(5)=1 : playsoundAtVol"rollover" ,ActiveBall, 1: End Sub
Sub Sw5_UnHit:Controller.Switch(5)=0: End Sub
Sub Sw6_Hit:Controller.Switch(6)=1 : playsoundAtVol"rollover" ,ActiveBall, 1: End Sub
Sub Sw6_UnHit:Controller.Switch(6)=0: End Sub
Sub Sw14_Hit:Controller.Switch(14)=1 : playsoundAtVol"rollover" ,ActiveBall, 1: End Sub
Sub Sw14_UnHit:Controller.Switch(14)=0: End Sub
Sub sw23_Hit:Controller.Switch(23)=1 : playsoundAtVol"rollover" ,ActiveBall, 1: End Sub
Sub sw23_UnHit:Controller.Switch(23)=0: End Sub
Sub Sw24_Hit:Controller.Switch(24)=1 : playsoundAtVol"rollover" ,ActiveBall, 1: End Sub
Sub Sw24_UnHit:Controller.Switch(24)=0: End Sub
Sub Sw25_Hit:Controller.Switch(25)=1 : playsoundAtVol"rollover" ,ActiveBall, 1: End Sub
Sub Sw25_UnHit:Controller.Switch(25)=0: End Sub
Sub Sw28_Hit:Controller.Switch(28)=1 : playsoundAtVol"rollover" ,ActiveBall, 1: End Sub
Sub Sw28_UnHit:Controller.Switch(28)=0: End Sub
Sub Sw29_Hit:Controller.Switch(29)=1 : playsoundAtVol"rollover" ,ActiveBall, 1: End Sub
Sub Sw29_UnHit:Controller.Switch(29)=0: End Sub
Sub Sw39_Hit:Controller.Switch(39)=1 : playsoundAtVol"rollover" ,ActiveBall, 1: End Sub
Sub Sw39_UnHit:Controller.Switch(39)=0: End Sub
Sub Sw40_Hit:Controller.switch(40)=1 : playsoundAtVol"rollover" ,ActiveBall, 1: End Sub
Sub Sw40_UnHit:Controller.switch(40) = 0 End Sub
Sub Sw51_Hit:Controller.Switch(51)=1 : playsoundAtVol"rollover" ,ActiveBall, 1: End Sub
Sub Sw51_UnHit:Controller.Switch(51)=0: End Sub
'Bumpers
Sub Bumper1_Hit : vpmTimer.PulseSw(30) : playsoundAtVol SoundFX("fx_bumper1",DOFContactors),Bumper1, VolBump: End Sub
Sub Bumper2_Hit : vpmTimer.PulseSw(31) : playsoundAtVol SoundFX("fx_bumper1",DOFContactors),Bumper2, VolBump: End Sub
Sub Bumper3_Hit : vpmTimer.PulseSw(32) : playsoundAtVol SoundFX("fx_bumper1",DOFContactors),Bumper3, VolBump: End Sub
'Centrifuge
Sub Sw33_Hit:Controller.switch(33) = 1 End Sub
Sub Sw33_UnHit:Controller.switch(33) = 0 End Sub
Sub Sw34_Hit:Controller.switch(34) = 1 End Sub
Sub Sw34_UnHit:Controller.switch(34) = 0 End Sub
Sub Sw34a_Hit():Sw34a.Kick 280,30:End Sub
'Ramp Trigger
Sub Sw37_Hit:vpmTimer.PulseSw 37 : End Sub
'Spinners
Sub Sw7_Spin:vpmTimer.PulseSw 7 : playsoundAtVol"fx_spinner",sw7,VolSpin : End Sub
Sub Sw38_Spin:vpmTimer.PulseSw 38 : playsoundAtVol"fx_spinner",sw38,VolSpin : End Sub
'Generic Sounds
Sub Trigger1_Hit : playsoundAtVol"fx_ballrampdrop" ,ActiveBall, 1: End Sub
Sub Trigger2_Hit : playsoundAtVol"fx_ballrampdrop" ,ActiveBall, 1: End Sub
Sub Trigger3_Hit : playsoundAtVol"Wire Ramp" ,ActiveBall, 1: End Sub
Sub Trigger4_Hit : playsoundAtVol"Wire Ramp" ,ActiveBall, 1: End Sub
Sub Trigger5_Hit : playsoundAtVol"fx_ballrampdrop" ,ActiveBall, 1: End Sub
'**********************************************************************************************************
'Skull
'**********************************************************************************************************
Dim mSkull
Sub SolSkullMotor(Enabled)
If Enabled Then
UpdateSkull.Enabled=1
'debug.print Timer & " SOL:SkullMotor ON" & sDir
Else
UpdateSkull.Enabled=0
'debug.print Timer & " SOL:SkullMotor OFF" & sDir
End If
End Sub
Dim BallsInPlay
Sub SolSkullMotorRelay (enabled)
if Enabled Then
sDir = - SkullStepSize 'down
'debug.print timer & " SOL:SkullMotorDir DOWN"
else
sDir = SkullStepSize 'Up
'debug.print timer & " SOL:SkullMotorDir UP"
end if
If sPos >= 135 Then
SwLock.Enabled = 1
else
SwLock.Enabled = 0
End If
If sPos >= 149 and LockBall > 1 then
Sw8.Createball: Sw8.Kick 150, 0.5: controller.switch(8) = 0: BolaPL.Visible = 0: PlaySoundAtVol "fx_kout", sw8, VolKick
Sw9.Createball: Sw9.Kick 150, 0.5: controller.switch(9) = 0: BolaPR.Visible = 0: PlaySoundAtVol "fx_kout", sw9, VolKick
LockBall = 0
BallsInPlay = BallsInPlay + 2
End If
If sPos >= 149 and LockBall = 1 then
Sw8.Createball: Sw8.Kick 150, 0.5: controller.switch(8) = 0: BolaPL.Visible = 0: PlaySoundAtVol "fx_kout", sw8, VolKick
LockBall = 0
BallsInPlay = BallsInPlay + 1
End If
End Sub
Sub SwLock_Hit
If LockBall = 0 Then
controller.switch(8) = 1
Me.DestroyBall
BolaPL.Visible = 1
LockBall = LockBall + 1
' BallsInPlay = BallsInPlay - 1
ElseIf LockBall >= 1 Then
controller.switch(9) = 1
Me.DestroyBall
BolaPR.Visible = 1
LockBall = LockBall + 1
'BallsInPlay = BallsInPlay - 1
End If
playsoundAtVol "popper_ball", SWLock, 1
End Sub
Const SkullStepSize = .2
Dim LockBall: LockBall = 0
Dim sPos, sDir
sPos = SkullP.Z
sDir = SkullStepSize
Sub UpdateSkull_Timer()
PlaySound "motor"
sPos = sPos + sDir
If sPos <= 80 then 'DOWN position
'debug.print Timer & " down12 sw 0:" & sPos
controller.switch(12) = 0
Else
'debug.print Timer & " down12 sw 1:" & sPos
controller.switch(12) = 1
End if
If sPos >= 139 and sPos <= 142 then 'MIDDLE position
'debug.print timer & " middle11 sw 0:" & sPos
controller.switch(11) = 0
Else
'debug.print timer & " middle11 sw 1:" & sPos
controller.switch(11) = 1
End if
If sPos >= 150 then 'UP position
'debug.print timer & "up10 sw 0:" & sPos
controller.switch(10) = 0
Else
'debug.print timer & " up10 sw 1:" & sPos
controller.switch(10) = 1
End if
'When motor reaches end of travel, change direction
If sPos <= 75 then 'change direction of motor
sdir = SkullStepSize
debug.print "skull changing direction (up)"
Elseif sPos >= 155 Then
sdir = -SkullStepSize
debug.print "skull changing direction (down)"
End If
SkullP.Z = sPos
BolaPL.TransY = sPos
BolaPR.TransY = sPos
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)
InitLamps() ' turn off the lights and flashers and reset them to the default parameters
LampTimer.Interval = 5 'lamp fading speed
LampTimer.Enabled = 1
' Lamp & Flasher Timers
Sub LampTimer_Timer()
Dim chgLamp, num, chg, ii
chgLamp = Controller.ChangedLamps
If Not IsEmpty(chgLamp) Then
For ii = 0 To UBound(chgLamp)
LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
Next
End If
UpdateLamps
End Sub
Sub UpdateLamps
NFadeL 3, l3
NFadeL 4, l4
NFadeL 5, l5
NFadeL 6, l6
' NFadeL 7, l7
' NFadeL 8, l8
NFadeL 9, l9
NFadeL 10, l10
NFadeL 11, l11
NFadeL 12, l12
NFadeL 13, l13
NFadeL 14, l14
NFadeL 15, l15
NFadeL 16, l16
NFadeL 17, l17
NFadeL 18, l18
NFadeL 19, l19
NFadeObjm 20, l20, "bulbcover1_greenON", "bulbcover1_green" 'Left Spinner sign Green LED
Flash 20, f20
NFadeObjm 21, l21, "bulbcover1_greenON", "bulbcover1_green" 'Right Spinner sign Green LED
Flash 21, f21
NFadeL 22, l22
NFadeL 23, l23
NFadeL 24, l24
NFadeL 25, l25
NFadeL 26, l26
NFadeL 27, l27
NFadeL 28, l28
NFadeL 29, l29
NFadeL 30, l30
NFadeL 31, l31
NFadeL 32, l32
NFadeL 33, l33 'Right Spot Light
NFadeL 34, l34
NFadeL 35, l35
NFadeL 36, l36
NFadeL 37, l37
NFadeL 38, l38
' NFadeL 39, l39
NFadeL 40, l40
NFadeL 41, l41
NFadeL 42, l42
NFadeL 43, l43
NFadeL 44, l44
NFadeL 45, l45
NFadeObjm 46, l46, "bulbOn", "[plastic-white3]" 'Bullet
Flash 46, f46
NFadeL 47, l47
NFadeL 48, l48
NFadeL 49, l49
NFadeL 50, l50
NFadeL 51, l51
NFadeL 52, l52
NFadeL 53, l53
NFadeL 54, l54
NFadeL 55, l55
NFadeL 56, l56
NFadeL 57, l57
NFadeL 58, l58
NFadeL 59, l59
NFadeObjm 60, P60, "lampbulbON", "lampbulb"
NFadeL 60, l60 'top left bumper
NFadeObjm 61, P61, "lampbulbON", "lampbulb"
NFadeL 61, l61 'right bumper
NFadeObjm 62, P62, "lampbulbON", "lampbulb"
NFadeL 62, l62 'lower left bumper
NFadeL 63, l63
NFadeL 64, l64
NFadeL 65, l65
NFadeL 66, l66
NFadeL 67, l67
NFadeL 68, l68
NFadeL 69, l69
NFadeL 70, l70
NFadeL 71, l71
NFadeL 72, l72
NFadeL 73, l73
NFadeL 74, l74
NFadeL 75, l75
NFadeL 76, l76
NFadeL 77, l77
NFadeL 78, l78
NFadeL 79, l79
NFadeL 80, l80
Flash 86, F86
Flash 87, F87
Flash 88, F88
'Solenoid Controlled Flashers
NFadeObjm 119, f119, "dome2_0_yellowON", "dome2_0_yellow"
NFadeObjm 119, f119a, "dome2_0_yellowON", "dome2_0_yellow"
NFadeLm 119, f119b
NFadeL 119, f119c
NFadeLm 120, f120
NFadeL 120, f120a
NFadeObjm 121, SkullP, "skull03", "skull02" 'Skull
NFadeL 122, f122
NFadeObjm 123, f123, "dome2_0_greenON", "dome2_0_green"
NFadeObjm 123, f123a, "dome2_0_greenON", "dome2_0_green"
Flashm 123, f123b
Flash 123, f123c
Flash 126, f126
NFadeLm 128, f128
Flash 131, f131
End Sub
' div lamp subs
Sub InitLamps()
Dim x
For x = 0 to 200
LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
FadingLevel(x) = 4 ' used to track the fading state
FlashSpeedUp(x) = 0.4 ' faster speed when turning on the flasher
FlashSpeedDown(x) = 0.2 ' slower speed when turning off the flasher
FlashMax(x) = 1 ' the maximum value when on, usually 1
FlashMin(x) = 0 ' the minimum value when off, usually 0
FlashLevel(x) = 0 ' the intensity of the flashers, usually from 0 to 1
Next
End Sub
Sub AllLampsOff
Dim x
For x = 0 to 200
SetLamp x, 0
Next
End Sub
Sub SetLamp(nr, value)
If value <> LampState(nr) Then
LampState(nr) = abs(value)
FadingLevel(nr) = abs(value) + 4
End If
End Sub
' Lights: used for VP10 standard lights, the fading is handled by VP itself
Sub NFadeL(nr, object)
Select Case FadingLevel(nr)
Case 4:object.state = 0:FadingLevel(nr) = 0
Case 5:object.state = 1:FadingLevel(nr) = 1
End Select
End Sub
Sub NFadeLm(nr, object) ' used for multiple lights
Select Case FadingLevel(nr)
Case 4:object.state = 0
Case 5:object.state = 1
End Select
End Sub
'Lights, Ramps & Primitives used as 4 step fading lights
'a,b,c,d are the images used from on to off
Sub FadeObj(nr, object, a, b, c, d)
Select Case FadingLevel(nr)
Case 4:object.image = b:FadingLevel(nr) = 6 'fading to off...
Case 5:object.image = a:FadingLevel(nr) = 1 'ON
Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
Case 9:object.image = c:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
Case 13:object.image = d:FadingLevel(nr) = 0 'Off
End Select
End Sub
Sub FadeObjm(nr, object, a, b, c, d)
Select Case FadingLevel(nr)
Case 4:object.image = b
Case 5:object.image = a
Case 9:object.image = c
Case 13:object.image = d
End Select
End Sub
Sub NFadeObj(nr, object, a, b)
Select Case FadingLevel(nr)
Case 4:object.image = b:FadingLevel(nr) = 0 'off
Case 5:object.image = a:FadingLevel(nr) = 1 'on
End Select
End Sub
Sub NFadeObjm(nr, object, a, b)
Select Case FadingLevel(nr)
Case 4:object.image = b
Case 5:object.image = a
End Select
End Sub
' Flasher objects
Sub Flash(nr, object)
Select Case FadingLevel(nr)
Case 4 'off
FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
If FlashLevel(nr) < FlashMin(nr) Then
FlashLevel(nr) = FlashMin(nr)
FadingLevel(nr) = 0 'completely off
End if
Object.IntensityScale = FlashLevel(nr)
Case 5 ' on
FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
If FlashLevel(nr) > FlashMax(nr) Then
FlashLevel(nr) = FlashMax(nr)
FadingLevel(nr) = 1 'completely on
End if
Object.IntensityScale = FlashLevel(nr)
End Select
End Sub
Sub Flashm(nr, object) 'multiple flashers, it just sets the flashlevel
Object.IntensityScale = FlashLevel(nr)
End Sub
'Reels
Sub FadeReel(nr, reel)
Select Case FadingLevel(nr)
Case 2:FadingLevel(nr) = 0
Case 3:FadingLevel(nr) = 2
Case 4:reel.Visible = 0:FadingLevel(nr) = 3
Case 5:reel.Visible = 1:FadingLevel(nr) = 1
End Select
End Sub
'Inverted Reels
Sub FadeIReel(nr, reel)
Select Case FadingLevel(nr)
Case 2:FadingLevel(nr) = 0
Case 3:FadingLevel(nr) = 2
Case 4:reel.Visible = 1:FadingLevel(nr) = 3
Case 5:reel.Visible = 0:FadingLevel(nr) = 1
End Select
End Sub
'**********************************************************************************************************
'**********************************************************************************************************
' Start of VPX functions
'**********************************************************************************************************
'**********************************************************************************************************
'**********Sling Shot Animations
' Rstep and Lstep are the variables that increment the animation
'****************
Dim RStep, Lstep
Sub RightSlingShot_Slingshot
vpmTimer.PulseSw 27
PlaySoundAtVol SoundFX("right_slingshot",DOFContactors), sling1, 1
RSling.Visible = 0
RSling1.Visible = 1
sling1.TransZ = -20
RStep = 0
RightSlingShot.TimerEnabled = 1
End Sub
Sub RightSlingShot_Timer
Select Case RStep
Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.TransZ = -10
Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.TransZ = 0:RightSlingShot.TimerEnabled = 0:
End Select
RStep = RStep + 1
End Sub
Sub LeftSlingShot_Slingshot
vpmTimer.PulseSw 26
PlaySoundAtVol SoundFX("left_slingshot",DOFContactors), sling2, 1
LSling.Visible = 0
LSling1.Visible = 1
sling2.TransZ = -20
LStep = 0
LeftSlingShot.TimerEnabled = 1
End Sub
Sub LeftSlingShot_Timer
Select Case LStep
Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.TransZ = -10
Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.TransZ = 0:LeftSlingShot.TimerEnabled = 0
End Select
LStep = LStep + 1
End Sub
' *******************************************************************************************************
' Positional Sound Playback Functions by DJRobX
' PlaySound sound, 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 1, AudioFade(ActiveBall)
' *******************************************************************************************************
' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
End Sub
' Set position as table object (Use object or light but NOT wall) and Vol to 1
Sub PlaySoundAt(soundname, tableobj)
PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
End Sub
'Set all as per ball position & speed.
Sub PlaySoundAtBall(soundname)
PlaySoundAt soundname, ActiveBall
End Sub
'Set position as table object and Vol manually.
Sub PlaySoundAtVol(sound, tableobj, Volum)
PlaySound sound, 1, Volum, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
End Sub
'Set all as per ball position & speed, but Vol Multiplier may be used eg; PlaySoundAtBallVol "sound",3
Sub PlaySoundAtBallVol(sound, VolMult)
PlaySound sound, 0, Vol(ActiveBall) * VolMult, AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 1, AudioFade(ActiveBall)
End Sub
'Set position as bumperX and Vol manually.
Sub PlaySoundAtBumperVol(sound, tableobj, Vol)
PlaySound sound, 1, Vol, AudioPan(tableobj), 0,0,1, 1, AudioFade(tableobj)
End Sub
'*********************************************************************
' Supporting Ball & Sound Functions
'*********************************************************************
Function RndNum(min, max)
RndNum = Int(Rnd() * (max-min + 1) ) + min ' Sets a random number between min and max
End Function
Function AudioFade(tableobj) ' Fades between front and back of the table (for surround systems or 2x2 speakers, etc), depending on the Y position on the table. "table1" is the name of the table
Dim tmp
tmp = tableobj.y * 2 / table1.height-1
If tmp > 0 Then
AudioFade = Csng(tmp ^10)
Else
AudioFade = Csng(-((- tmp) ^10) )
End If
End Function
Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
Dim tmp
tmp = tableobj.x * 2 / table1.width-1
If tmp > 0 Then
AudioPan = Csng(tmp ^10)
Else
AudioPan = Csng(-((- tmp) ^10) )
End If
End Function
Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
Dim tmp
tmp = ball.x * 2 / table1.width-1
If tmp > 0 Then
Pan = Csng(tmp ^10)
Else
Pan = Csng(-((- tmp) ^10) )
End If
End Function
Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
Vol = Csng(BallVel(ball) ^2 / VolDiv)
End Function
Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
Pitch = BallVel(ball) * 20
End Function
Function BallVel(ball) 'Calculates the ball speed
BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
End Function
'*****************************************
' JP's VP10 Rolling Sounds
'*****************************************
Const tnob = 5 ' total number of balls
ReDim rolling(tnob)
InitRolling
Sub InitRolling
Dim i
For i = 0 to tnob
rolling(i) = False
Next
End Sub
Sub RollingTimer_Timer()
Dim BOT, b
BOT = GetBalls
' stop the sound of deleted balls
For b = UBound(BOT) + 1 to tnob
rolling(b) = False
StopSound("fx_ballrolling" & b)
Next
' exit the sub if no balls on the table
If UBound(BOT) = -1 Then Exit Sub
' play the rolling sound for each ball
For b = 0 to UBound(BOT)
If BallVel(BOT(b) ) > 1 Then
rolling(b) = True
if BOT(b).z < 30 Then ' Ball on playfield
PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) ), AudioPan(BOT(b) ), 0, Pitch(BOT(b) ), 1, 0, AudioFade(BOT(b) )
Else ' Ball on raised ramp
PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) )*.5, AudioPan(BOT(b) ), 0, Pitch(BOT(b) )+50000, 1, 0, AudioFade(BOT(b) )
End If
Else
If rolling(b) = True Then
StopSound("fx_ballrolling" & b)
rolling(b) = False
End If
End If
Next
End Sub
'**********************
' Ball Collision Sound
'**********************
Sub OnBallBallCollision(ball1, ball2, velocity)
PlaySound("fx_collide"), 0, Csng(velocity) ^2 / (VolDiv/VolCol), AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
End Sub
'*****************************************
' ninuzzu's FLIPPER SHADOWS
'*****************************************