-
Notifications
You must be signed in to change notification settings - Fork 37
/
Arena (Gottlieb 1987).02.vbs
1167 lines (935 loc) · 35.5 KB
/
Arena (Gottlieb 1987).02.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
Const cGameName = "arena"
On Error Resume Next
ExecuteGlobal GetTextFile("controller.vbs")
If Err Then MsgBox "Can't open controller.vbs"
On Error Goto 0
LoadVPM "01210000", "sys80.VBS", 3.1
' Thalamus 2020 January : Improved directional sounds
' !! 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 )
'**********************************************************
'******** OPTIONS *******************************
'**********************************************************
Dim BallShadows: Ballshadows=0 '******************set to 1 to turn on Ball shadows
Dim FlipperShadows: FlipperShadows=1 '***********set to 1 to turn on Flipper shadows
Dim ROMSounds: ROMSounds=1 '**********set to 0 for no rom sounds, 1 to play rom sounds.. mostly used for testing
'************************************************
'************************************************
'************************************************
'************************************************
'************************************************
Const UseSolenoids = 2
Const UseLamps = True
Const UseSync = False
Const UseGI = False
' Standard Sounds
Const SSolenoidOn = "fx_solenoid"
Const SSolenoidOff = "fx_solenoidoff"
Const SCoin = "fx_coin"
Dim bsTrough, bslLock, bsRLock, FastFlips, objekt, xx
Dim showdmd
Sub Arena_Init
' Thalamus : Was missing 'vpminit me'
vpminit me
if B2SOn then
showdmd=0
else
showdmd=1
end if
With Controller
.GameName = cGameName
If Err Then MsgBox "Can't start Game " & cGameName & vbNewLine & Err.Description:Exit Sub
.SplashInfoLine = "Alien Star (Gottlieb 1984)"&chr(13)&"1.0"
.HandleKeyboard = 0
.ShowTitle = 0
.ShowDMDOnly = showdmd
.ShowFrame = 0
.HandleMechanics = False
.Games(cGameName).Settings.Value("sound") = ROMSounds
.Hidden = 0
On Error Resume Next
.Run GetPlayerHWnd
If Err Then MsgBox Err.Description
On Error Goto 0
End With
If B2SOn then
for each objekt in backdropstuff : objekt.visible = 0 : next
End If
Intensity 'sets GI brightness depending on day/night slider settings
PinMAMETimer.Interval = PinMAMEInterval
PinMAMETimer.Enabled = 1
'************************Trough
sw76.CreateBall
sw20.CreateBall
sw10.CreateBall
Controller.Switch(76) = 1
Controller.Switch(20) = 1
Controller.Switch(10) = 1
'Kickers
Set bslLock=New cvpmBallStack
with bslLock
.InitSaucer sw21,21, 120,8.5
.InitExitSnd Soundfx("holekick",DOFContactors), Soundfx("HoleKick",DOFContactors)
end with
Set bsRLock=New cvpmBallStack
with bsRLock
.InitSaucer sw31,31,120,8.5
.InitExitSnd Soundfx("holekick",DOFContactors), Soundfx("HoleKick",DOFContactors)
end with
' Nudging
vpmNudge.TiltSwitch = 57
vpmNudge.Sensitivity = 1
vpmNudge.TiltObj = Array(leftslingshot, rightslingshot)
if ballshadows=1 then
BallShadowUpdate.enabled=1
else
BallShadowUpdate.enabled=0
end if
if flippershadows=1 then
FlipperLSh.visible=1
FlipperRSh.visible=1
else
FlipperLSh.visible=0
FlipperRSh.visible=0
end if
vpmMapLights CPULights
Set FastFlips = new cFastFlips
with FastFlips
.CallBackL = "SolLflipper" 'Point these to flipper subs
.CallBackR = "SolRflipper" '...
' .CallBackUL = "SolULflipper"'...(upper flippers, if needed)
' .CallBackUR = "SolURflipper"'...
.TiltObjects = True 'Optional, if True calls vpmnudge.solgameon automatically. IF YOU GET A LINE 1 ERROR, DISABLE THIS! (or setup vpmNudge.TiltObj!)
' .DebugOn = False 'Debug, always-on flippers. Call FastFlips.DebugOn True or False in debugger to enable/disable.
end with
End Sub
'************************************************
' Solenoids
'************************************************
SolCallback(2) = "SolBankReset"
SolCallback(4) = "SolFlasherR"
SolCallback(5) = "SolRLock"
SolCallback(6) = "SolLLock"
SolCallback(7) = "SolFlasherL"
SolCallback(8) = "solknocker"
SolCallback(9) = "solballrelease"
SolCallback(10) = "FastFlips.TiltSol"
SolCallback(sLRFlipper) = "SolRFlipper"
SolCallback(sLLFlipper) = "SolLFlipper"
Sub SolLFlipper(Enabled)
If Enabled Then
PlaySoundAtVol SoundFX("fx_Flipperup",DOFFlippers), LeftFlipper, 1:LeftFlipper.RotateToEnd
' controller.Switch(48)=1
Else
PlaySoundAtVol SoundFX("fx_Flipperdown",DOFFlippers), LeftFlipper, 1:LeftFlipper.RotateToStart
' controller.Switch(48)=0
End If
End Sub
Sub SolRFlipper(Enabled)
If Enabled Then
PlaySoundAtVol SoundFX("fx_Flipperup",DOFFlippers), RightFlipper, 1:RightFlipper.RotateToEnd
controller.Switch(45)=1
Else
PlaySoundAtVol SoundFX("fx_Flipperdown",DOFFlippers), RightFlipper, 1:RightFlipper.RotateToStart
controller.Switch(45)=0
End If
End Sub
Sub SolFlasherR(enabled)
if enabled Then
F4.state=1
F4a.state=1
else
F4.state=0
F4a.state=0
end if
end sub
Sub SolFlasherL(enabled)
if enabled Then
F7.state=1
F7a.state=1
else
F7.state=0
F7a.state=0
end if
end sub
Sub SolBankReset(Enabled)
If Enabled Then
PlaySoundAt "DTreset", sw40
for each objekt in DropTargets: objekt.isdropped=0: Next
end if
end sub
Dim GILevel, DayNight
Sub Intensity
If DayNight <= 20 Then
GILevel = .5
ElseIf DayNight <= 40 Then
GILevel = .4125
ElseIf DayNight <= 60 Then
GILevel = .325
ElseIf DayNight <= 80 Then
GILevel = .2375
Elseif DayNight <= 100 Then
GILevel = .15
End If
For each xx in GI: xx.IntensityScale = xx.IntensityScale * (GILevel): Next
End Sub
Sub DSLightsTimer_timer
DSLights(DSLightsTimer.uservalue).duration 1, 40, 0
DSLightsTimer.uservalue = DSLightsTimer.uservalue + 1
if DSLightsTimer.uservalue>9 then DSLightsTimer.uservalue=0
end sub
Sub FlipperTimer_Timer
Dim PI: PI=3.1415926
'testbox.text = "LDS1.timer "&DSLightsTimer.enabled
'testbox1.text = "LDS1.uv "&DSLightsTimer.uservalue
'testbox2.text = ((DSLightsTimer.uservalue+3) MOD 9)
LFlip.RotZ = LeftFlipper.CurrentAngle
RFlip.RotZ = RightFlipper.CurrentAngle
Lflip1.RotZ = LeftFlipper.CurrentAngle
RFlip1.RotZ = RightFlipper.CurrentAngle
' Pgate.rotx = Gate.currentangle*0.6
' Pgate1.rotx = Gate1.currentangle*0.6
Dim SpinnerRadius: SpinnerRadius=7
SpinnerRod.TransZ = (cos((sw24.CurrentAngle + 180) * (PI/180))+1) * SpinnerRadius
SpinnerRod.TransY = sin((sw24.CurrentAngle) * (PI/180)) * -SpinnerRadius
if FlipperShadows=1 then
FlipperLSh.RotZ = LeftFlipper.currentangle
FlipperRSh.RotZ = RightFlipper.currentangle
end if
End Sub
' Ball locks / kickers
Sub sw21_Hit:PlaySoundAtVol "holein", ActiveBall, 1:bslLock.AddBall 0:End Sub
Sub sw31_Hit:PlaySoundAtVol "holein", ActiveBall, 1:bsRLock.AddBall 0:End Sub
Sub SolLLock(enabled)
If enabled Then
bslLock.ExitSol_On
DOF 106, DOFpulse
LeftKickTimer.uservalue = 0
PkickarmL.RotZ = 15
LeftKickTimer.Enabled = 1
End If
End Sub
Sub LeftKickTimer_timer
select case me.uservalue
case 5:
PkickarmL.rotz=0
me.enabled=0
end Select
me.uservalue = me.uservalue+1
End Sub
Sub SolRLock(enabled)
If enabled Then
bsRLock.ExitSol_On
DOF 106, DOFpulse
RightKickTimer.uservalue = 0
PkickarmR.RotZ = 15
RightKickTimer.Enabled = 1
End If
End Sub
Sub RightKickTimer_timer
select case me.uservalue
case 5:
PkickarmR.rotz=0
me.enabled=0
end Select
me.uservalue = me.uservalue+1
End Sub
'******************************************************
' TROUGH BASED ON NFOZZY'S via bord's pink panther
'******************************************************
Sub sw10_Hit():Controller.Switch(10) = 1:UpdateTrough:End Sub
Sub sw10_UnHit():Controller.Switch(10) = 0:UpdateTrough:End Sub
Sub sw20_Hit():Controller.Switch(20) = 1:UpdateTrough:End Sub
Sub sw20_UnHit():Controller.Switch(20) = 0:UpdateTrough:End Sub
Sub sw76_Hit():Controller.Switch(76) = 1:UpdateTrough:End Sub
Sub sw76_UnHit():Controller.Switch(76) = 0:UpdateTrough:End Sub
Sub UpdateTrough()
UpdateTroughTimer.Interval = 500
UpdateTroughTimer.Enabled = 1
End Sub
Sub UpdateTroughTimer_Timer()
If sw76.BallCntOver = 0 Then sw20.kick 54, 1
UpdateTroughTimer1.Interval = 500
UpdateTroughTimer1.Enabled = 1
Me.Enabled = 0
End Sub
Sub UpdateTroughTimer1_Timer()
If sw20.BallCntOver = 0 Then sw10.kick 54, 1
Me.Enabled = 0
End Sub
'******************************************************
' DRAIN & RELEASE
'******************************************************
Sub sw66_Hit()
PlaySoundat "drain", sw66
UpdateTrough
Controller.Switch(66) = 1
End Sub
Sub sw66_UnHit()
Controller.Switch(66) = 0
End Sub
Sub solballrelease(enabled)
If enabled Then
sw66.kick 54,40
PlaySoundat SoundFX("fx_Solenoid",DOFContactors), sw66
End If
End Sub
set Lights(12) = L12
Set LampCallback = GetRef("UpdateMultipleLamps")
Sub UpdateMultipleLamps
if controller.lamp(12)=true and sw76.BallCntOver > 0 then
sw76.kick 60, 7
PlaySoundAt SoundFX("ballrelease",DOFContactors), sw76
UpdateTrough
end if
if controller.lamp(13)=true then 'Inside Gate Relay
InsideGate.rotatetoend
controller.Switch(35)=1
else
InsideGate.rotatetostart
Controller.Switch(35)=0
end if
if controller.lamp(14)=true then 'Outside Gate Relay
OutsideGate.rotatetoend
else
OutsideGate.rotatetostart
end if
if controller.lamp(17)=true then 'ramp DS lights
DSLightsTimer.enabled=1
else
DSLightsTimer.enabled=0
for each objekt in DSLights: objekt.state=0: next
end if
if Controller.Lamp(24) then
F24.visible = True
else
F24.visible = False
end if
if Controller.Lamp(25) then
F25.visible = True
else
F25.visible = False
end if
if Controller.Lamp(26) then
F26.visible = True
F26A.visible = True
else
F26.visible = False
F26A.visible = False
end if
End Sub
'**********************************************************************************************************
'Plunger code
'**********************************************************************************************************
Sub Arena_KeyDown(ByVal KeyCode)
If KeyCode = LeftFlipperKey then FastFlips.FlipL True : FastFlips.FlipUL True
If KeyCode = RightFlipperKey then FastFlips.FlipR True : FastFlips.FlipUR True
If keycode = PlungerKey Then Plunger.Pullback:PlaySoundAt "plungerpull", Plunger
'************************ Start Ball Control 1/3
if keycode = 46 then ' C Key
If contball = 1 Then
contball = 0
Else
contball = 1
End If
End If
if keycode = 48 then 'B Key
If bcboost = 1 Then
bcboost = bcboostmulti
Else
bcboost = 1
End If
End If
if keycode = 203 then bcleft = 1 ' Left Arrow
if keycode = 200 then bcup = 1 ' Up Arrow
if keycode = 208 then bcdown = 1 ' Down Arrow
if keycode = 205 then bcright = 1 ' Right Arrow
'************************ End Ball Control 1/3
If KeyDownHandler(keycode) Then Exit Sub
End Sub
Sub Arena_KeyUp(ByVal KeyCode)
If KeyCode = LeftFlipperKey then FastFlips.FlipL False : FastFlips.FlipUL False
If KeyCode = RightFlipperKey then FastFlips.FlipR False : FastFlips.FlipUR False
If keycode = PlungerKey Then
Plunger.Fire
if startcontrol.BallCntOver>0 then
PlaySoundAt "plungerreleaseball", Plunger
else
PlaySoundAt "plungerreleasefree", Plunger
end if
end if
'************************ Start Ball Control 2/3
if keycode = 203 then bcleft = 0 ' Left Arrow
if keycode = 200 then bcup = 0 ' Up Arrow
if keycode = 208 then bcdown = 0 ' Down Arrow
if keycode = 205 then bcright = 0 ' Right Arrow
'************************ End Ball Control 2/3
If KeyUpHandler(keycode) Then Exit Sub
End Sub
'************************ Start Ball Control 3/3
Sub StartControl_Hit()
Set ControlBall = ActiveBall
contballinplay = true
End Sub
Sub StopControl_Hit()
contballinplay = false
End Sub
Dim bcup, bcdown, bcleft, bcright, contball, contballinplay, ControlBall, bcboost
Dim bcvel, bcyveloffset, bcboostmulti
bcboost = 1 'Do Not Change - default setting
bcvel = 4 'Controls the speed of the ball movement
bcyveloffset = -0.01 'Offsets the force of gravity to keep the ball from drifting vertically on the table, should be negative
bcboostmulti = 3 'Boost multiplier to ball veloctiy (toggled with the B key)
Sub BallControl_Timer()
If Contball and ContBallInPlay then
If bcright = 1 Then
ControlBall.velx = bcvel*bcboost
ElseIf bcleft = 1 Then
ControlBall.velx = - bcvel*bcboost
Else
ControlBall.velx=0
End If
If bcup = 1 Then
ControlBall.vely = -bcvel*bcboost
ElseIf bcdown = 1 Then
ControlBall.vely = bcvel*bcboost
Else
ControlBall.vely= bcyveloffset
End If
End If
End Sub
'************************ End Ball Control 3/3
'Wire Triggers
Sub SW22_Hit:Controller.Switch(22)=1:End Sub
Sub SW22_unHit:Controller.Switch(22)=0:End Sub
Sub SW30_Hit:Controller.Switch(30)=1:End Sub
Sub SW30_unHit:Controller.Switch(30)=0:End Sub
Sub SW32_Hit:Controller.Switch(32)=1:End Sub
Sub SW32_unHit:Controller.Switch(32)=0:End Sub
Sub SW42_Hit:Controller.Switch(42)=1:End Sub
Sub SW42_unHit:Controller.Switch(42)=0:End Sub
Sub SW44_Hit:Controller.Switch(44)=1:End Sub
Sub SW44_unHit:Controller.Switch(44)=0:End Sub
Sub SW54_Hit:Controller.Switch(54)=1:End Sub
Sub SW54_unHit:Controller.Switch(54)=0:End Sub
Sub SW55_Hit:Controller.Switch(55)=1:End Sub
Sub SW55_unHit:Controller.Switch(55)=0:End Sub
Sub SW41_Hit:Controller.Switch(41)=1:End Sub
Sub SW41_unHit:Controller.Switch(41)=0:End Sub
Sub SW51_Hit:Controller.Switch(51)=1:End Sub
Sub SW51_unHit:Controller.Switch(51)=0:End Sub
Sub SW61_Hit:Controller.Switch(61)=1:End Sub
Sub SW61_unHit:Controller.Switch(61)=0:End Sub
Sub SW71_Hit:Controller.Switch(71)=1:End Sub
Sub SW71_unHit:Controller.Switch(71)=0:End Sub
Sub SW64_Hit:Controller.Switch(64)=1:End Sub
Sub SW64_unHit:Controller.Switch(64)=0:End Sub
Sub SW74_Hit:Controller.Switch(74)=1:End Sub
Sub SW74_unHit:Controller.Switch(74)=0:End Sub
Sub SW65_Hit:Controller.Switch(65)=1:End Sub
Sub SW65_unHit:Controller.Switch(65)=0:End Sub
Sub SW75_Hit:Controller.Switch(75)=1:End Sub
Sub SW75_unHit:Controller.Switch(75)=0:End Sub
'Targets
Sub sw23_Hit:vpmTimer.PulseSw (23):End Sub
Sub sw33_Hit:vpmTimer.PulseSw (33):End Sub
Sub sw43_Hit:vpmTimer.PulseSw (43):End Sub
Sub sw52_Hit:vpmTimer.PulseSw (52):End Sub
Sub sw62_Hit:vpmTimer.PulseSw (62):End Sub
Sub sw72_Hit:vpmTimer.PulseSw (72):End Sub
Sub sw53_Hit:vpmTimer.PulseSw (53):End Sub
Sub sw63_Hit:vpmTimer.PulseSw (63):End Sub
Sub sw73_Hit:vpmTimer.PulseSw (73):End Sub
Sub sw02_Hit:vpmTimer.PulseSw (02):End Sub
Sub sw03_Hit:vpmTimer.PulseSw (03):End Sub
'Drop Targets
Sub SW40_Hit:vpmTimer.PulseSw (40):End Sub
Sub SW50_Hit:vpmTimer.PulseSw (50):End Sub
Sub SW60_Hit:vpmTimer.PulseSw (60):End Sub
Sub SW70_Hit:vpmTimer.PulseSw (70):End Sub
'Rollunder Gates
Sub SW34_Hit:vpmTimer.PulseSw (34):End Sub
'Spinners
Sub Sw24_Spin
vpmTimer.PulseSw (24)
PlaySound "fx_spinner", 0, .25, AudioPan(sw53), 0.25, 0, 0, 1, AudioFade(sw53)
End Sub
Sub SolKnocker(Enabled)
If Enabled Then PlaySoundAt SoundFX("Knock",DOFKnocker), Plunger
End Sub
'**********Rubber Animations
sub sw55a_hit
vpmtimer.PulseSw(55)
Rsw55a.visible=0
Rsw55a1.visible=1
me.uservalue=1
Me.timerenabled=1
end sub
sub sw55a_timer 'default 50 timer
select case me.uservalue
Case 1: Rsw55A1.visible=0: Rsw55A.visible=1
case 2: Rsw55A.visible=0: Rsw55A2.visible=1
Case 3: Rsw55A2.visible=0: Rsw55A.visible=1: Me.timerenabled=0
end Select
me.uservalue=me.uservalue+1
end sub
sub sw55b_hit
vpmtimer.PulseSw(55)
Rsw55b.visible=0
Rsw55b1.visible=1
me.uservalue=1
Me.timerenabled=1
end sub
sub sw55b_timer 'default 50 timer
select case me.uservalue
Case 1: Rsw55b1.visible=0: Rsw55b.visible=1
case 2: Rsw55b.visible=0: Rsw55b2.visible=1
Case 3: Rsw55b2.visible=0: Rsw55b.visible=1: Me.timerenabled=0
end Select
me.uservalue=me.uservalue+1
end sub
'**********Sling Shot Animations
' Rstep and Lstep are the variables that increment the animation
'****************
Dim RStep, Lstep, Tstep, URstep
Sub RightSlingShot_Slingshot
PlaySoundAt SoundFX("fx_slingshot",DOFContactors), slingR
DOF 105, DOFPulse
vpmtimer.PulseSw(25)
RSling.Visible = 0
RSling1.Visible = 1
slingR.objroty = -15
RStep = 0
RightSlingShot.TimerEnabled = 1
End Sub
Sub RightSlingShot_Timer
Select Case RStep
Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:slingR.objroty = -7
Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:slingR.objroty = 0:RightSlingShot.TimerEnabled = 0
End Select
RStep = RStep + 1
End Sub
Sub LeftSlingShot_Slingshot
PlaySoundAt SoundFX("fx_slingshot",DOFContactors), slingL
DOF 104, DOFPulse
vpmtimer.pulsesw(25)
LSling.Visible = 0
LSling1.Visible = 1
slingL.objroty = 15
LStep = 0
LeftSlingShot.TimerEnabled = 1
End Sub
Sub LeftSlingShot_Timer
Select Case LStep
Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:slingL.objroty = 7
Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:slingL.objroty=0:LeftSlingShot.TimerEnabled = 0
End Select
LStep = LStep + 1
End Sub
' *******************************************************************************************************
' 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
Sub PlaySoundAtBOTBallZ(sound, BOT)
PlaySound sound, 0, ABS(BOT.velz)/17, Pan(BOT), 0, Pitch(BOT), 1, 0, AudioFade(BOT)
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
'*********************************************************************
' 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
'*****************************************
' Ball Rolling Sounds by JP
'*****************************************
Const tnob = 15 ' 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
'**********************
' Object Hit Sounds
'**********************
Sub a_Woods_Hit(idx)
PlaySound "fx_Woodhit", 0, Vol(ActiveBall), Audiopan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
End Sub
Sub a_Triggers_Hit(idx)
PlaySound "fx_switch", 0, Vol(ActiveBall), Audiopan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
End Sub
Sub a_Pins_Hit (idx)
PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
End Sub
Sub a_Targets_Hit (idx)
PlaySound SoundFX("fx_target",DOFTargets), 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
End Sub
Sub a_DropTargets_Hit (idx)
PlaySound "fx_drop1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
End Sub
Sub a_Metals_Thin_Hit (idx)
PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
End Sub
Sub a_Metals_Medium_Hit (idx)
PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
End Sub
Sub a_Metals2_Hit (idx)
PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
End Sub
Sub a_Gates_Hit (idx)
PlaySound "gate4", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
End Sub
Sub a_Rubbers_Hit(idx)
dim finalspeed
finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
If finalspeed > 20 then
PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
End if
If finalspeed >= 6 AND finalspeed <= 20 then
RandomSoundRubber()
End If
End Sub
Sub a_Posts_Hit(idx)
dim finalspeed
finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
If finalspeed > 16 then
PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
End if
If finalspeed >= 6 AND finalspeed <= 16 then
RandomSoundRubber()
End If
End Sub
Sub RandomSoundRubber()
Select Case Int(Rnd*3)+1
Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
End Select
End Sub
Sub LeftFlipper_Collide(parm)
RandomSoundFlipper()
End Sub
Sub RightFlipper_Collide(parm)
RandomSoundFlipper()
End Sub
Sub RandomSoundFlipper()
Select Case Int(Rnd*3)+1
Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
End Select
End Sub
'*********************************
'GI uselamps workaround by nfozzy
'*********************************
dim GIlamps : set GIlamps = New GIcatcherobject
Class GIcatcherObject 'object that disguises itself as a light. (UseLamps workaround for System80 GI circuit)
Public Property Let State(input)
dim x
if input = 1 then 'If GI switch is engaged, turn off GI.
for each x in gi : x.state = 0 : next
elseif input = 0 then
for each x in gi : x.state = 1 : next
end if
End Property
End Class
set Lights(1) = GIlamps 'GI circuit
'*****************************************
' BALL SHADOW by ninnuzu
'*****************************************
Dim BallShadow
BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
Sub BallShadowUpdate_timer()
Dim BOT, b
Dim maxXoffset
maxXoffset=6
BOT = GetBalls
' render the shadow for each ball
For b = 0 to UBound(BOT)
BallShadow(b).X = BOT(b).X-maxXoffset*(1-(Bot(b).X)/(Arena.Width/2))
BallShadow(b).Y = BOT(b).Y + 10
If BOT(b).Z > 0 and BOT(b).Z < 30 Then
BallShadow(b).visible = 1
Else
BallShadow(b).visible = 0
End If
Next
End Sub
'Gottlieb Arena
'added by Inkochnito
Sub editDips
Dim vpmDips : Set vpmDips = New cvpmDips
With vpmDips
.AddForm 700,400,"Arena - DIP switches"