-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathTruck Stop (Bally 1988) v2.1.0.vbs
2013 lines (1713 loc) · 69.7 KB
/
Truck Stop (Bally 1988) v2.1.0.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
'Big Betty's Truck Stop (Bally 1988)
'
' Development by agentEighty6 2020 for Visual Pinball X
' Version 2.1.0
' I would like to send a very special thanks to the following.
' - sindbad : For being able to use his VP9 table resources.
' - JPSalas : VERY much improved "Arcade Physics 3.0" materials, script changes, and techniques.
' - BrandonLaw : Playfield and plastics cleanup and enhancement
' - bigus1 : Beta testing and lighting tweeks
' - flupper, nFozzy, and others : Flipper physics, flasher lighting, etc.
' - VPX development team: As always, thanks for your work in keeping VP alive and well
' - To anyone I may have forgotten, please let me know and I'll add you.
' Release notes:
' Version 2.1.0 - Physics overhaul and added dampening plus a bunch of table tweeks/corrections
' Version 2.0.0 - Major update to add JPs Arcade Physics V3 and also to clean up a few issues and tweeks.
' Version 1.1.0 - Minor update to clean up a few small asthetic issues and add Brandon's improved PF and images.
' Added changes from Arngrim and Thalamus to improve directional sounds and updates other sounds.
' Version 1.0.0 - New VPX version built from the V9 version graphical resources.
' Script and lighting was (mostly) rebuilt from scratch.
' New VPX routines (flipper physics, shadowing, flasher lighting, ball jumping, etc.).
' Playfield cleanup/optimization.
'Table Components
' Layer1 - Table Mechanics
' Layer2 - Ramps
' Layer3 - Primitives
' Layer4 - Plastics
' Layer5 - Walls
' Layer6 - Misc, timers, outer walls, testing tools, etc.
' Layer7 - Export to Blender, Dampeners
' Layer8 - Flashers
' Layer9 - Table Lamps
' Layer10 - Controlled GI Lights
' Layer11 - GI Lights
' ****************************************************
' OPTIONS
' ****************************************************
' Volume devided by - lower gets higher sound
Const VolDiv = 900 ' Lower number, louder ballrolling/collition sound
Const VolCol = 10 ' Ball collition divider ( voldiv/volcol )
' Thalamus 2020 January : Improved directional sounds
Const VolGates = 1 ' Gates volume.
Const VolTarg = 1 ' Targets volume.
Const VolSpin = 1 ' Spinners volume.
Const VolSen = 1 ' Sensor volume.
Const VolWire = 1.3 ' wireramp volume.
Dim DynamicLampIntensity, DynamicGIIntensity, DynamicFlasherIntensity, LetTheBallJump, ShowBallShadow, OutlanePos, SolControlledLights, CenterPost, Playtest
' LET THE BALL JUMP A BIT
' 0 = off
' 1 to 6 = ball jump intensity (2 = default)
LetTheBallJump = 2
' DYNAMIC LAMP INTENSITY MULTIPLIER
' Numeric value to dynamically multiply every playfield lamp's intensity (default=1)
DynamicLampIntensity = 1
' DYNAMIC GI INTENSITY MULTIPLIER
' Numeric value to dynamically multiply every GI lamp's intensity (default=1, 0=Off)
DynamicGIIntensity = 1
' DYNAMIC FLASHER INTENSITY MULTIPLIER
' Numeric value to dynamically multiply every flasher's intensity (default=1, 0=Off)
DynamicFlasherIntensity = 1
' SHOW BALL SHADOWS
' 0 = no ball shadows
' 1 = ball shadows are visible
ShowBallShadow = 1
' OUTLANE DIFFICULTY
' Change size of outlane width
' 0 = Wide (difficult)
' 1 = Normal (default)
' 2 = Narrow (easy)
OutlanePos = 1
' CENTER POST
' Enable/disable center post between flippers
' 0 = disabled (default)
' 1 = enabled
CenterPost = 0
' SOLENOID CONTROLLED Lights
' 0 = GI lights always on like orig table (default)
' 1 = let the table control the GI lights on/off
SolControlledLights = 0
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 BallSize = 50
Const BallMass = 1
Const cGameName="trucksp3",SSolenoidOn="SolOn",SSolenoidOff="SolOff", SCoin="coin"
Const UseSolenoids = 2
Const UseLamps = 1
Const UseSync = 1
Const HandleMech = 0
Const UseGI = 0
LoadVPM "03020000", "6803.VBS", 3.20
Dim bsTrough, bsSaucerTR, bsKickerTL, bsKickerTR, DropTargetBank
Dim DesktopMode: DesktopMode = Table1.ShowDT
Sub Table1_Init
vpmInit me
With Controller
.GameName=cGameName
If Err Then MsgBox "Can't start Game " & cGameName & vbNewLine & Err.Description : Exit Sub
.SplashInfoLine="Truck Stop, Bally 1988"
.HandleKeyboard=0
.ShowTitle=0
.ShowDMDOnly=1
.ShowFrame=0
.HandleMechanics=0
.Hidden= not DesktopMode
On Error Resume Next
.Run
If Err Then MsgBox Err.Description
On Error Goto 0
End With
' Trough handler
Set bsTrough = New cvpmBallStack
With bsTrough
.InitSw swOuthole, swTroughR, swTroughL, 0, 0, 0, 0, 0
.InitKick BallRelease,90,7
.Balls = 2
End With
' Saucer Top Right
Set bsSaucerTR = New cvpmBallStack
With bsSaucerTR
.InitSaucer SaucerTopRight,swSaucerTopRight,210,30
.KickForceVar = 2
End With
' Kicker Top Right
Set bsKickerTR=New cvpmBallStack
With bsKickerTR
.InitSw 0,swLowerDock,swUpperDock,0,0,0,0,0
.InitKick KickerTopRight,6,35
.InitExitSnd SoundFX("SaucerKick",DOFContactors), SoundFX("SaucerKick",DOFContactors)
End With
' Kicker Top Left
Set bsKickerTL=New cvpmBallStack
With bsKickerTL
.InitSaucer KickerTopLeft, swKickerTopLeft,90,50
.Kickz = 80
.InitExitSnd SoundFX("SaucerKick",DOFContactors), SoundFX("SaucerKick",DOFContactors)
End With
'Drop targets bank
set DropTargetBank = new cvpmDropTarget
DropTargetBank.InitDrop Array(sw25,sw26,sw27), Array(25,26,27)
DropTargetBank.InitSnd SoundFX("DropTargetHit",DOFDropTargets),SoundFX("BankReset",DOFContactors)
vpmNudge.TiltSwitch = swTiltMe
vpmNudge.Sensitivity = 5
vpmNudge.TiltObj = Array(SlingLL, SlingLR, SlingUL, SlingUR)
DisplayTimer.Enabled = DesktopMode
If DesktopMode = True Then
RampLT.Visible = 1
RampRT.Visible = 1
RampLT2.Visible = 0
RampRT2.Visible = 0
Else
RampLT.Visible = 0
RampRT.Visible = 0
RampLT2.Visible = 1
RampRT2.Visible = 1
End If
If CenterPost = 1 Then
MetalCenterPost.isDropped = False
MetalCenterPost.visible = True
RubberCenterPost.collidable=True
RubberCenterPost.visible=True
Else
MetalCenterPost.isDropped = True
MetalCenterPost.visible = False
RubberCenterPost.collidable=False
RubberCenterPost.visible=False
End If
'Reset Slings
Slingshots_Init
'Set Outlane width/difficulty
Outlanes_Init
'Reset Steering wall in upper middle ramp system
LaneSteeringInit
'Reset Mushroom Targets in Upper playfield
MushroomTriggers_Init
vpmMapLights AllLights
'not assigned: 14, 28, 62, 77, 93 (backbox top Lights)
dim xx
For each xx in GILights
xx.intensity = xx.intensity * DynamicGIIntensity * 0.5
Next
dim zz
For each zz in AllLights
zz.intensity = zz.intensity * DynamicLampIntensity
Next
l12a.IntensityScale = 0
l61a.IntensityScale = 0
l29a.IntensityScale = 0
l91a.IntensityScale = 0
If SolControlledLights = 0 Then
GiON
End If
If Playtest = 1 Then
FlipperTrigger001.Enabled=True
FlipperTrigger002.Enabled=True
FlipperTrigger003.Enabled=True
FlipperTrigger004.Enabled=True
Wall001.isDropped=false
Wall002.isDropped=false
Wall003.isDropped=false
Else
FlipperTrigger001.Enabled=False
FlipperTrigger002.Enabled=False
FlipperTrigger003.Enabled=False
FlipperTrigger004.Enabled=False
Wall001.isDropped=True
Wall002.isDropped=True
Wall003.isDropped=True
End If
End Sub
'***********************************************************************************
'**** Keyboard (Input) Handling ****
'***********************************************************************************
Sub Table1_KeyDown(ByVal keycode)
If keycode = PlungerKey Then Plunger.PullBack
If keycode = LeftFlipperKey Then lfpress = 1
If keycode = RightFlipperKey Then rfpress = 1
If vpmKeyDown(keycode) Then Exit Sub
End Sub
Sub Table1_KeyUp(ByVal keycode)
If keycode = PlungerKey Then Plunger.Fire
If keycode = LeftFlipperKey Then
lfpress = 0
leftflipper.eostorqueangle = EOSA
leftflipper.eostorque = EOST
End If
If keycode = RightFlipperKey Then
rfpress = 0
rightflipper.eostorqueangle = EOSA
rightflipper.eostorque = EOST
End If
If vpmKeyUp(keycode) Then Exit Sub
End Sub
'***********************************************************************************
'**** Solenoid reference ****
'***********************************************************************************
const sKickerTopRight = 2 ' mapped in manual to 3
const sSaucerTopRight = 4 ' mapped in manual to 2
const sDropTargetsReset = 6 ' mapped in manual to 4
const sKickerTopLeft = 8 ' mapped in manual to 1
const sEjectToShooter = 12 ' mapped in manual to 9
const sOuthole = 14 ' mapped in manual to 10
const sKnocker = 15 ' mapped in manual to 11
const sFlippersEnable = 19
const sLaneSteering = 18 ' mapped in manual to 12
'***********************************************************************************
'**** Knocker ****
'***********************************************************************************
SolCallback(sKnocker) = "HitKnocker"
Sub HitKnocker(enabled)
If enabled Then PlaySound SoundFX("Knocker",DOFKnocker), 1
End Sub
'***********************************************************************************
'**** Drains and Kickers ****
'***********************************************************************************
Dim KickerTopLeftBall, KickerTopLeftPos, BallOnTopRamp
SolCallback(sEjectToShooter) = "EjectToShooter"
SolCallback(sSaucerTopRight) = "EjectSaucerTopRight"
SolCallback(sKickerTopLeft) = "EjectKickerTopLeft"
SolCallback(sKickerTopRight) = "EjectKickerTopRight"
SolCallback(sOutHole) = "bsTrough.SolIn"
Sub EjectToShooter(enabled)
If enabled = True Then
PlaySoundAtVol SoundFX("BallRelease",DOFContactors), BallRelease, 1
bsTrough.ExitSol_On
End If
End Sub
Sub Drain_Hit()
bsTrough.EntrySol_On
bsTrough.AddBall Me
PlaySoundAtVol "Drain", Drain, 1
End Sub
Sub EjectSaucerTopRight(enabled)
If enabled Then
PlaySoundAtVol SoundFX("SaucerKick",DOFContactors), SaucerTopRight, 1
bsSaucerTR.ExitSol_On
End If
End Sub
Sub EjectKickerTopLeft(enabled)
If enabled Then
PlaySoundAtVol SoundFX("SaucerKick",DOFContactors), KickerTopLeft, 1
If Isobject(KickerTopLeftBall) Then
BallOnTopRamp = True
KickerTopLeft.TimerInterval = 1
KickerTopLeft.TimerEnabled = 1
KickerTopLeftPos = 0
End If
End If
End Sub
Sub EjectKickerTopRight(enabled)
If enabled Then
'PlaySoundAtVol SoundFX("SaucerKick",DOFContactors), KickerTopRight, 1
bsKickerTR.ExitSol_On
End If
End Sub
Sub KickerTopLeft_Timer
If KickerTopLeftPos = 0 then
Controller.Switch(swKickerTopLeft) = 0
End If
KickerTopLeftPos = KickerTopLeftPos + 3
KickerTopLeftBall.z = KickerTopLeftBall.z + 3
If KickerTopLeftPos > 160 then
KickerTopLeftBall.x = KickerTopLeftBall.x + 3
End If
If KickerTopLeftPos > 185 then
KickerTopLeft.Kick 90, 6
'SoundMetalRamp
Set KickerTopLeftBall = Nothing
Me.TimerEnabled = 0
End If
End Sub
'***********************************************************************************
'**** Flippers ****
'***********************************************************************************
SolCallback(sLRFlipper)="SolRightFlipper"
SolCallback(sLLFlipper)="SolLeftFlipper"
SolCallback(sFlippersEnable) = "SolEnableBumpers"
' ****************************************************
' flipper subs
' ****************************************************
Sub SolLeftFlipper(Enabled)
If Enabled Then
LF.fire
PlaySoundAtVol SoundFX("fx_flipperup",DOFFlippers), LeftFlipper, 1
PlaySoundAtVol "fx_flipperup", LeftFlipperTop, 1
LeftFlipperTop.RotateToEnd
Else
PlaySoundAtVol SoundFX("fx_flipperdown",DOFFlippers), LeftFlipper, 1
PlaySoundAtVol "fx_flipperdown", LeftFlipperTop, 1
'LeftFlipper.EOSTorque = 0.1
LeftFlipper.RotateToStart
LeftFlipperTop.RotateToStart
End If
End Sub
Sub SolRightFlipper(Enabled)
If Enabled Then
RF.fire
PlaySoundAtVol SoundFX("fx_flipperup",DOFFlippers), RightFlipper, 1
PlaySoundAtVol "fx_flipperup", RightFlipperTop, 1
RightFlipperTop.RotateToEnd
Else
PlaySoundAtVol SoundFX("fx_flipperdown",DOFFlippers), RightFlipper, 1
PlaySoundAtVol "fx_flipperdown", RightFlipperTop, 1
'RightFlipper.EOSTorque = 0.1
RightFlipper.RotateToStart
RightFlipperTop.RotateToStart
End If
End Sub
Sub FlipperTrigger001_hit
LF.fire
LeftFlipperTop.RotateToEnd
End Sub
Sub FlipperTrigger001_unhit
LeftFlipper.RotateToStart
LeftFlipperTop.RotateToStart
End Sub
Sub FlipperTrigger002_hit
RF.fire
RightFlipperTop.RotateToEnd
End Sub
Sub FlipperTrigger002_unhit
RightFlipper.RotateToStart
RightFlipperTop.RotateToStart
End Sub
Sub FlipperTrigger003_hit
LF.fire
LeftFlipperTop.RotateToEnd
End Sub
Sub FlipperTrigger003_unhit
LeftFlipper.RotateToStart
LeftFlipperTop.RotateToStart
End Sub
Sub FlipperTrigger004_hit
RF.fire
RightFlipperTop.RotateToEnd
End Sub
Sub FlipperTrigger004_unhit
RightFlipper.RotateToStart
RightFlipperTop.RotateToStart
End Sub
'***********************************************************************************
'**** Slingshot and walls ****
'***********************************************************************************
Dim SLLPos, SLRPos, SULPos, SURPos
Sub SlingLL_Slingshot()
LLSling1.Visible = 0:LLSling2.Visible = 0:LLSling3.Visible = 0: LLSling4.Visible = 1: LLSling.TransZ = -27
vpmTimer.PulseSw(swBottomSlingLeft): PlaySoundAtVol SoundFX("SlingL",DOFContactors), LLSling, 1
SLLPos = 0: Me.TimerInterval = 15:Me.TimerEnabled = 1:
End Sub
Sub SlingLL_Timer
Select Case SLLPos
Case 2: LLSling1.Visible = 0:LLSling2.Visible = 0:LLSling3.Visible = 1: LLSling4.Visible = 0: LLSling.TransZ = -17
Case 3: LLSling1.Visible = 0:LLSling2.Visible = 1:LLSling3.Visible = 0: LLSling4.Visible = 0: LLSling.TransZ = -8
Case 4: LLSling1.Visible = 1:LLSling2.Visible = 0:LLSling3.Visible = 0: LLSling4.Visible = 0: LLSling.TransZ = 0 :Me.TimerEnabled = 0
End Select
SLLPos = SLLPos + 1
End Sub
Sub SlingLR_Slingshot()
LRSling1.Visible = 0:LRSling2.Visible = 0:LRSling3.Visible = 0: LRSling4.Visible = 1: LRSling.TransZ = -27
vpmTimer.PulseSw(swBottomSlingRight): PlaySoundAtVol SoundFX("SlingR",DOFContactors), LRSling, 1
SLRPos = 0: Me.TimerInterval = 15:Me.TimerEnabled = 1:
End Sub
Sub SlingLR_Timer
Select Case SLRPos
Case 2: LRSling1.Visible = 0:LRSling2.Visible = 0:LRSling3.Visible = 1: LRSling4.Visible = 0: LRSling.TransZ = -17
Case 3: LRSling1.Visible = 0:LRSling2.Visible = 1:LRSling3.Visible = 0: LRSling4.Visible = 0: LRSling.TransZ = -8
Case 4: LRSling1.Visible = 1:LRSling2.Visible = 0:LRSling3.Visible = 0: LRSling4.Visible = 0: LRSling.TransZ = 0 :Me.TimerEnabled = 0
End Select
SLRPos = SLRPos + 1
End Sub
Sub SlingUL_Slingshot()
ULSling1.Visible = 0:ULSling2.Visible = 0:ULSling3.Visible = 0: ULSling4.Visible = 1: ULSling.TransZ = -27
vpmTimer.PulseSw(swTopSlingLeft): PlaySoundAtVol SoundFX("SlingL",DOFContactors), ULSling, 1
SULPos = 0: Me.TimerInterval = 15:Me.TimerEnabled = 1:
End Sub
Sub SlingUL_Timer
Select Case SULPos
Case 2: ULSling1.Visible = 0:ULSling2.Visible = 0:ULSling3.Visible = 1: ULSling4.Visible = 0: ULSling.TransZ = -17
Case 3: ULSling1.Visible = 0:ULSling2.Visible = 1:ULSling3.Visible = 0: ULSling4.Visible = 0: ULSling.TransZ = -8
Case 4: ULSling1.Visible = 1:ULSling2.Visible = 0:ULSling3.Visible = 0: ULSling4.Visible = 0: ULSling.TransZ = 0 :Me.TimerEnabled = 0
End Select
SULPos = SULPos + 1
End Sub
Sub SlingUR_Slingshot()
URSling1.Visible = 0:URSling2.Visible = 0:URSling3.Visible = 0: URSling4.Visible = 1: URSling.TransZ = -27
vpmTimer.PulseSw(swTopSlingRight): PlaySoundAtVol SoundFX("SlingR",DOFContactors), URSling, 1
SURPos = 0: Me.TimerInterval = 15:Me.TimerEnabled = 1:
End Sub
Sub SlingUR_Timer
Select Case SURPos
Case 2: URSling1.Visible = 0:URSling2.Visible = 0:URSling3.Visible = 1: URSling4.Visible = 0: URSling.TransZ = -17
Case 3: URSling1.Visible = 0:URSling2.Visible = 1:URSling3.Visible = 0: URSling4.Visible = 0: URSling.TransZ = -8
Case 4: URSling1.Visible = 1:URSling2.Visible = 0:URSling3.Visible = 0: URSling4.Visible = 0: URSling.TransZ = 0 :Me.TimerEnabled = 0
End Select
SURPos = SURPos + 1
End Sub
Sub Slingshots_Init
LLSling1.Visible = 1:LLSling2.Visible = 0:LLSling3.Visible = 0: LLSling4.Visible = 0: LLSling.TransZ = 0
LRSling1.Visible = 1:LRSling2.Visible = 0:LRSling3.Visible = 0: LRSling4.Visible = 0: LRSling.TransZ = 0
ULSling1.Visible = 1:ULSling2.Visible = 0:ULSling3.Visible = 0: ULSling4.Visible = 0: ULSling.TransZ = 0
URSling1.Visible = 1:URSling2.Visible = 0:URSling3.Visible = 0: URSling4.Visible = 0: URSling.TransZ = 0
End Sub
Sub SolEnableBumpers(enabled)
If enabled Then
'turn on bumpers and maybe lights
SlingLL.hasHitEvent = True
SlingLR.hasHitEvent = True
SlingUL.hasHitEvent = True
SlingUR.hasHitEvent = True
If SolControlledLights = 1 Then
GiON
End If
Else
'turn off bumpers and maybe lights
SlingLL.hasHitEvent = False
SlingLR.hasHitEvent = False
SlingUL.hasHitEvent = False
SlingUR.hasHitEvent = False
If SolControlledLights = 1 Then
GiOFF
End If
End If
End Sub
Sub GiON
dim xx
For each xx in GILights
xx.State = LightStateOn
Next
End Sub
Sub GiOFF
dim xx
For each xx in GILights
xx.State = LightStateOff
Next
End Sub
'***********************************************************************************
'**** Switch reference ****
'***********************************************************************************
Const swRampEntryC = 1
Const swRampEntryI = 2
Const swRampEntryT = 3
Const swRampEntryY = 4
Const swOuthole = 8
Const swRampExitLeft = 12
Const swRampExitRight = 13
Const swTiltMe = 15
Const swShooterLane = 16
Const swBottomSlingLeft = 17
Const swBottomSlingRight = 18
Const swTopSlingLeft = 19
Const swTopSlingRight = 20
Const swSingleTargetTop = 21
Const swMushroomLeft = 22
Const swMushroomRight = 23
Const swSpinnerTop = 24
Const swDropTargetBottom = 25
Const swDropTargetMiddle = 26
Const swDropTargetTop = 27
Const swTopWalls = 28
Const swKickerTopLeft = 29
Const swSaucerTopRight = 30
Const swInlaneLeft = 31
Const swInlaneRight = 32
Const swBlueTarget1 = 33
Const swBlueTarget2 = 34
Const swBlueTarget3 = 35
Const swBlueTarget4 = 36
Const swBlueTarget5 = 37
Const swBlueTarget6 = 38
Const swOutlaneLeft = 39
Const swOutlaneRight = 40
Const swSingleTargetLeft = 41
Const swSingleTargetRight = 42
Const swLowerDock = 45
Const swUpperDock = 46
Const swTroughL = 47
Const swTroughR = 48
'***********************************************************************************
'**** Rollovers and triggers ****
'***********************************************************************************
Sub sw24_Spin():PlaySoundAtVol "Spinner", sw24, VolSpin:vpmTimer.PulseSw (swSpinnerTop):End Sub
Sub sw1_Hit():vpmTimer.PulseSw(swRampEntryC):PlaySoundAtVol "Gate", ActiveBall, VolGates:End Sub
Sub sw2_Hit():vpmTimer.PulseSw(swRampEntryI):PlaySoundAtVol "Gate", ActiveBall, VolGates:End Sub
Sub sw3_Hit():vpmTimer.PulseSw(swRampEntryT):PlaySoundAtVol "Gate", ActiveBall, VolGates:End Sub
Sub sw4_Hit():vpmTimer.PulseSw(swRampEntryY):PlaySoundAtVol "Gate", ActiveBall, VolGates:End Sub
Sub sw28l_Hit():PlaySoundAtVol "Sensor", ActiveBall, VolSen:vpmTimer.PulseSw(swTopWalls):End Sub
Sub sw28r_Hit():PlaySoundAtVol "Sensor", ActiveBall, VolSen:vpmTimer.PulseSw(swTopWalls):End Sub
Sub sw12a_Hit():PlaySoundAtVol "Sensor", ActiveBall, VolSen:Controller.Switch(swRampExitLeft) = 1:End Sub
Sub sw12a_UnHit():Controller.Switch(swRampExitLeft) = 0:End Sub
Sub sw12b_Hit():PlaySoundAtVol "Sensor", ActiveBall, VolSen:Controller.Switch(swRampExitLeft) = 1:End Sub
Sub sw12b_UnHit():Controller.Switch(swRampExitLeft) = 0:End Sub
Sub sw13a_Hit():PlaySoundAtVol "Sensor", ActiveBall, VolSen:Controller.Switch(swRampExitRight) = 1:End Sub
Sub sw13a_UnHit():Controller.Switch(swRampExitRight) = 0:End Sub
Sub sw13b_Hit():PlaySoundAtVol "Sensor", ActiveBall, VolSen:Controller.Switch(swRampExitRight) = 1:End Sub
Sub sw13b_UnHit():Controller.Switch(swRampExitRight) = 0:End Sub
Sub sw16_Hit():PlaySoundAtVol "Sensor", ActiveBall, VolSen:Controller.Switch(swShooterLane) = 1:End Sub
Sub sw16_UnHit():Controller.Switch(swShooterLane) = 0:End Sub
Sub sw31_Hit():PlaySoundAtVol "Sensor", ActiveBall, VolSen:Controller.Switch(swInlaneLeft) = 1:End Sub
Sub sw31_UnHit():Controller.Switch(swInlaneLeft) = 0:End Sub
Sub sw32_Hit():PlaySoundAtVol "Sensor", ActiveBall, VolSen:Controller.Switch(swInlaneRight) = 1:End Sub
Sub sw32_UnHit():Controller.Switch(swInlaneRight) = 0:End Sub
Sub sw39_Hit():PlaySoundAtVol "Sensor", ActiveBall, VolSen:Controller.Switch(swOutlaneLeft) = 1:End Sub
Sub sw39_UnHit():Controller.Switch(swOutlaneLeft) = 0:End Sub
Sub sw40_Hit():PlaySoundAtVol "Sensor", ActiveBall, VolSen:Controller.Switch(swOutlaneRight) = 1:End Sub
Sub sw40_UnHit():Controller.Switch(swOutlaneRight) = 0:End Sub
'***********************************************************************************
'**** Targets ****
'***********************************************************************************
Sub sw21_Hit:sw21p.TransX = 4:vpmTimer.PulseSw(swSingleTargetTop):StandupTargetHit:Me.TimerEnabled = 1:End Sub
Sub sw21_Timer:sw21p.TransX = 0:Me.TimerEnabled = 0:End Sub
Sub sw33_Hit:sw33p.TransX = 4:vpmTimer.PulseSw(swBlueTarget1):StandupTargetHit:Me.TimerEnabled = 1:End Sub
Sub sw33_Timer:sw33p.TransX = 0:Me.TimerEnabled = 0:End Sub
Sub sw34_Hit:sw34p.TransX = 4:vpmTimer.PulseSw(swBlueTarget2):StandupTargetHit:Me.TimerEnabled = 1:End Sub
Sub sw34_Timer:sw34p.TransX = 0:Me.TimerEnabled = 0:End Sub
Sub sw35_Hit:sw35p.TransX = 4:vpmTimer.PulseSw(swBlueTarget3):StandupTargetHit:Me.TimerEnabled = 1:End Sub
Sub sw35_Timer:sw35p.TransX = 0:Me.TimerEnabled = 0:End Sub
Sub sw36_Hit:sw36p.TransX = 4:vpmTimer.PulseSw(swBlueTarget4):StandupTargetHit:Me.TimerEnabled = 1:End Sub
Sub sw36_Timer:sw36p.TransX = 0:Me.TimerEnabled = 0:End Sub
Sub sw37_Hit:sw37p.TransX = 4:vpmTimer.PulseSw(swBlueTarget5):StandupTargetHit:Me.TimerEnabled = 1:End Sub
Sub sw37_Timer:sw37p.TransX = 0:Me.TimerEnabled = 0:End Sub
Sub sw38_Hit:sw38p.TransX = 4:vpmTimer.PulseSw(swBlueTarget6):StandupTargetHit:Me.TimerEnabled = 1:End Sub
Sub sw38_Timer:sw38p.TransX = 0:Me.TimerEnabled = 0:End Sub
Sub sw41_Hit:sw41p.TransX = 4:vpmTimer.PulseSw(swSingleTargetLeft):StandupTargetHit:Me.TimerEnabled = 1:End Sub
Sub sw41_Timer:sw41p.TransX = 0:Me.TimerEnabled = 0:End Sub
Sub sw42_Hit:sw42p.TransX = 4:vpmTimer.PulseSw(swSingleTargetRight):StandupTargetHit:Me.TimerEnabled = 1:End Sub
Sub sw42_Timer:sw42p.TransX = 0:Me.TimerEnabled = 0:End Sub
'***********************************************************************************
'**** Saucers and Kickers ****
'***********************************************************************************
Sub SaucerTopRight_Hit:PlaySoundAtVol "SaucerHit", ActiveBall, 1:bsSaucerTR.EntrySol_On:bsSaucerTR.AddBall Me:End Sub
Sub KickerTopLeft_Hit: PlaySoundAtVol "SaucerHit", ActiveBall, 1:Controller.Switch(swKickerTopLeft) = 1:Set KickerTopLeftBall = ActiveBall:End Sub
Sub KickerTopRight_Hit:PlaySoundAtVol "SaucerHit", ActiveBall, 1:bsKickerTR.EntrySol_On:bsKickerTR.AddBall Me:BallOnTopRamp = False:End Sub
'***********************************************************************************
'**** Drop Targets ****
'***********************************************************************************
Sub sw25_Hit:DropTargetBank.Hit 1:End Sub 'sw25
Sub sw26_Hit:DropTargetBank.Hit 2:End Sub 'sw26
Sub sw27_Hit:DropTargetBank.Hit 3:End sub 'sw27
SolCallback(sDropTargetsReset) = "DropTargetBank.SolDropUp"
'***********************************************************************************
'**** Mushroom triggers ****
'***********************************************************************************
Dim sw22step, sw23step
Sub sw22_Hit():sw22step = 0: vpmTimer.PulseSw(swMushroomLeft): PlaySoundAtVol "fx_rubber_hit_1", ActiveBall, 1:Me.TimerInterval = 40:Me.TimerEnabled = 1: End Sub
Sub sw23_Hit():sw23step = 0: vpmTimer.PulseSw(swMushroomRight):PlaySoundAtVol "fx_rubber_hit_2", ActiveBall, 1:Me.TimerInterval = 40:Me.TimerEnabled = 1: End Sub
Sub sw22_Timer()
Select Case sw22step
Case 0 : sw22m3.Visible = 1:sw22m2.Visible = 0:sw22m1.Visible = 0
Case 1 : sw22m2.Visible = 1:sw22m3.Visible = 0:sw22m1.Visible = 0
Case 2 : sw22m1.Visible = 1:sw22m2.Visible = 0:sw22m3.Visible = 0:Me.TimerEnabled = 0
End Select
sw22step = sw22step +1
End Sub
Sub sw23_Timer()
Select Case sw23step
Case 0 : sw23m3.Visible = 1:sw23m2.Visible = 0:sw23m1.Visible = 0
Case 1 : sw23m2.Visible = 1:sw23m3.Visible = 0:sw23m1.Visible = 0
Case 2 : sw23m1.Visible = 1:sw23m2.Visible = 0:sw23m3.Visible = 0:Me.TimerEnabled = 0
End Select
sw23step = sw23step +1
End Sub
Sub MushroomTriggers_Init
sw22m1.Visible = 1: sw22m2.Visible = 0: sw22m3.Visible = 0
sw23m1.Visible = 1: sw23m2.Visible = 0: sw23m3.Visible = 0
End Sub
'***********************************************************************************
'**** Lane Steering ****
'***********************************************************************************
Dim LSstep, LSdir
SolCallback(sLaneSteering) = "SetLaneSteering"
Sub SetLaneSteering(enabled)
If enabled = True Then
LSDir = -1: PlaySoundAtVol SoundFX("Solenoid",DOFContactors),Primitive87, 1: LaneSteeringTimer.Enabled = 1
Else
LSDir = 1: PlaySoundAtVol SoundFX("Solenoid",DOFContactors),Primitive87, 1: LaneSteeringTimer.Enabled = 1
End If
End Sub
Sub LaneSteeringTimer_Timer
If LSdir = 1 Then
LSstep = LSstep + 1
Select Case LSstep
Case 1 : LaneSteeringWall1.IsDropped = 0: LaneSteeringWall2.IsDropped = 1: LaneSteeringWall3.IsDropped = 1: LaneSteeringWallHidden.IsDropped = 0
Case 2 : LaneSteeringWall2.IsDropped = 0: LaneSteeringWall1.IsDropped = 1: LaneSteeringWall3.IsDropped = 1: LaneSteeringWallHidden.IsDropped = 0
Case 3 : LaneSteeringWall3.IsDropped = 0: LaneSteeringWall1.IsDropped = 1: LaneSteeringWall2.IsDropped = 1: LaneSteeringWallHidden.IsDropped = 0:Me.Enabled = 0
End Select
Else
LSstep = LSstep - 1
Select Case LSstep
Case 2 : LaneSteeringWall3.IsDropped = 1: LaneSteeringWall2.IsDropped = 0: LaneSteeringWall1.IsDropped = 1: LaneSteeringWallHidden.IsDropped = 1
Case 1 : LaneSteeringWall2.IsDropped = 1: LaneSteeringWall1.IsDropped = 0: LaneSteeringWall3.IsDropped = 1: LaneSteeringWallHidden.IsDropped = 1
Case 0 : LaneSteeringWall1.IsDropped = 1: LaneSteeringWall2.IsDropped = 1: LaneSteeringWall3.IsDropped = 1: LaneSteeringWallHidden.IsDropped = 1:Me.Enabled = 0
End Select
End If
End Sub
Sub LaneSteeringInit
LaneSteeringWall1.IsDropped = 1: LaneSteeringWall2.IsDropped = 1: LaneSteeringWall3.IsDropped = 1: LaneSteeringWallHidden.IsDropped = 1
LSDir = 0: LSstep = 0
End Sub
Sub Outlanes_Init
Dim OutlaneLPosArray: OutlaneLPosArray = Array(45, 1224, 52, 1232.75, 59, 1240.5)
Dim OutlaneRPosArray: OutlaneRPosArray = Array(815, 1226, 815, 1236.75, 815, 1246.5)
Dim io: io = OutlanePos * 2
PegLeftOutLane.X = OutlaneLPosArray(io): PegLeftOutLane.Y = OutlaneLPosArray(io+1)
PegRightOutLane.X = OutlaneRPosArray(io): PegRightOutLane.Y = OutlaneRPosArray(io+1)
RubberLeftOutlane1.Visible = 0: RubberLeftOutlane2.Visible = 0: RubberLeftOutlane3.Visible = 0
RubberLeftOutlane1.Collidable = 0: RubberLeftOutlane2.Collidable = 0: RubberLeftOutlane3.Collidable = 0
RubberRightOutlane1.Visible = 0: RubberRightOutlane2.Visible = 0: RubberRightOutlane3.Visible = 0
RubberRightOutlane1.Collidable = 0: RubberRightOutlane2.Collidable = 0: RubberRightOutlane3.Collidable = 0
Select Case OutlanePos
Case 0: RubberLeftOutlane1.Visible = 1: RubberLeftOutlane1.Collidable = 1
RubberRightOutlane1.Visible = 1: RubberRightOutlane1.Collidable = 1
Case 1: RubberLeftOutlane2.Visible = 1: RubberLeftOutlane2.Collidable = 1
RubberRightOutlane2.Visible = 1: RubberRightOutlane2.Collidable = 1
Case 2: RubberLeftOutlane3.Visible = 1: RubberLeftOutlane3.Collidable = 1
RubberRightOutlane3.Visible = 1: RubberRightOutlane3.Collidable = 1
End Select
End Sub
Dim Digits(27)
Digits(0)=Array(A1,A2,A3,A4,A5,A6,A7,A10,A8,A9)
Digits(1)=Array(A11,A12,A13,A14,A15,A16,A17,A20,A18,A19)
Digits(2)=Array(A31,A32,A33,A34,A35,A36,A37,A40,A38,A39)
Digits(3)=Array(A41,A42,A43,A44,A45,A46,A47,A50,A48,A49)
Digits(4)=Array(A51,A52,A53,A54,A55,A56,A57,A60,A58,A59)
Digits(5)=Array(A61,A62,A63,A64,A65,A66,A67,A70,A68,A69)
Digits(6)=Array(A71,A72,A73,A74,A75,A76,A77,A80,A78,A79)
Digits(7)=Array(A81,A82,A83,A84,A85,A86,A87,A90,A88,A89)
Digits(8)=Array(A91,A92,A93,A94,A95,A96,A97,A100,A98,A99)
Digits(9)=Array(A101,A102,A103,A104,A105,A106,A107,A110,A108,A109)
Digits(10)=Array(A111,A112,A113,A114,A115,A116,A117,A120,A118,A119)
Digits(11)=Array(A121,A122,A123,A124,A125,A126,A127,A130,A128,A129)
Digits(12)=Array(A131,A132,A133,A134,A135,A136,A137,A140,A138,A139)
Digits(13)=Array(A141,A142,A143,A144,A145,A146,A147,A150,A148,A149)
Digits(14)=Array(A151,A152,A153,A154,A155,A156,A157,A160,A158,A159)
Digits(15)=Array(A161,A162,A163,A164,A165,A166,A167,A170,A168,A169)
Digits(16)=Array(A171,A172,A173,A174,A175,A176,A177,A180,A178,A179)
Digits(17)=Array(A181,A182,A183,A184,A185,A186,A187,A190,A188,A189)
Digits(18)=Array(A191,A192,A193,A194,A195,A196,A197,A200,A198,A199)
Digits(19)=Array(A201,A202,A203,A204,A205,A206,A207,A210,A208,A209)
Digits(20)=Array(A211,A212,A213,A214,A215,A216,A217,A220,A218,A219)
Digits(21)=Array(A221,A222,A223,A224,A225,A226,A227,A230,A228,A229)
Digits(22)=Array(A231,A232,A233,A234,A235,A236,A237,A240,A238,A239)
Digits(23)=Array(A241,A242,A243,A244,A245,A246,A247,A250,A248,A249)
Digits(24)=Array(A251,A252,A253,A254,A255,A256,A257,A260,A258,A259)
Digits(25)=Array(A261,A262,A263,A264,A265,A266,A267,A270,A268,A269)
Digits(26)=Array(A271,A272,A273,A274,A275,A276,A277,A280,A278,A279)
Digits(27)=Array(A281,A282,A283,A284,A285,A286,A287,A290,A288,A289)
Sub LEDs_Timer()
Dim chgLED, ii, num, chg, stat, obj
chgLED = Controller.ChangedLEDs(&Hffffffff, &Hffffffff)
If Not IsEmpty(chgLED) Then
If DesktopMode Then
For ii = 0 To UBound(chgLED)
num = chgLED(ii, 0) : chg = chgLED(ii, 1) : stat = chgLED(ii, 2)
if (num < 32) then
For Each obj In Digits(num)
If chg And 1 Then obj.State = stat And 1
chg = chg\2 : stat = stat\2
Next
End If
Next
End If
End If
End Sub
'***********************************************************************************
'**** Sound routines ****
'***********************************************************************************
Sub RampTriggerC_Hit:PlaySoundAtVol "Gate", ActiveBall, 1:End Sub
Sub RampTriggerI_Hit:PlaySoundAtVol "Gate", ActiveBall, 1:End Sub
Sub RampTriggerT_Hit:PlaySoundAtVol "Gate", ActiveBall, 1:End Sub
Sub RampTriggerY_Hit:PlaySoundAtVol "Gate", ActiveBall, 1:End Sub
Sub LeftKickerEntry_Hit():PlaySoundAtVol "fx_kicker_enter_center", ActiveBall, 1:End Sub
Function OnPlayfield(ball)
If ball.Z < 30 Then
OnPlayfield = True
Exit Function
End If
OnPlayfield = False
End Function
' *******************************************************************************************************
' Positional Sound Playback Functions by DJRobX and Rothbauerw
' 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, Volume)
PlaySound sound, 1, Volume, 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
' requires rampbump1 to 7 in Sound Manager
Sub RandomBump(voladj, freq)
Dim BumpSnd:BumpSnd= "rampbump" & CStr(Int(Rnd*7)+1)
PlaySound BumpSnd, 0, Vol(ActiveBall)*voladj, AudioPan(ActiveBall), 0, freq, 0, 1, AudioFade(ActiveBall)
End Sub
Sub PlaySoundAtBOTBallZ(sound, BOT)
PlaySound sound, 0, ABS(BOT.velz)/17, Pan(BOT), 0, Pitch(BOT), 1, 0, AudioFade(BOT)
End Sub
Sub PlaySoundAtBallAbsVol(sound, VolMult)
PlaySound sound, 0, VolMult, AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 1, AudioFade(ActiveBall)
End Sub
' play a looping sound at a location with volume
Sub PlayLoopSoundAtVol(sound, tableobj, Vol)
PlaySound sound, -1, Vol, AudioPan(tableobj), 0, 0, 1, 0, AudioFade(tableobj)
End Sub
' set position as table object and Vol + RndPitch manually
Sub PlaySoundAtVolPitch(sound, tableobj, Vol, RndPitch)
PlaySound sound, 1, Vol, AudioPan(tableobj), RndPitch, 0, 0, 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
On Error Resume Next
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
On Error Resume Next
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
On Error Resume Next
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 BallRollVol(ball) ' Calculates the Volume of the sound based on the ball speed
BallRollVol = Csng(BallVel(ball) ^2 / (80000 - (79900 * Log(RollVol) / Log(100))))
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
Function BallVelZ(ball) 'Calculates the ball speed in the -Z
BallVelZ = INT((ball.VelZ) * -1 )
End Function
Function VolZ(ball) ' Calculates the Volume of the sound based on the ball speed in the Z
VolZ = Csng(BallVelZ(ball) ^2 / 200)*1.2
End Function
'*** Determines if a Points (px,py) is inside a 4 point polygon A-D in Clockwise/CCW order
Function InRect(px,py,ax,ay,bx,by,cx,cy,dx,dy)
Dim AB, BC, CD, DA
AB = (bx*py) - (by*px) - (ax*py) + (ay*px) + (ax*by) - (ay*bx)
BC = (cx*py) - (cy*px) - (bx*py) + (by*px) + (bx*cy) - (by*cx)
CD = (dx*py) - (dy*px) - (cx*py) + (cy*px) + (cx*dy) - (cy*dx)
DA = (ax*py) - (ay*px) - (dx*py) + (dy*px) + (dx*ay) - (dy*ax)
If (AB <= 0 AND BC <=0 AND CD <= 0 AND DA <= 0) Or (AB >= 0 AND BC >=0 AND CD >= 0 AND DA >= 0) Then
InRect = True
Else
InRect = False
End If
End Function
'*****************************************
' Wire Ramp Trigger Processing
'*****************************************
Sub Trigger001_hit
Dim b
BOT = GetBalls
For b = 0 to UBound(BOT)
if BOT(b) is activeball then
MRBallArray(b) = True
end if
next
End Sub
Sub Trigger002_hit
Dim b
BOT = GetBalls
For b = 0 to UBound(BOT)
if BOT(b) is activeball then
MRBallArray(b) = True
end if
next