-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathSpace Oddity 1.3.vbs
3721 lines (2990 loc) · 120 KB
/
Space Oddity 1.3.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'Space Oddity by BALUTITO
'
' Space Station / IPD No.2261 / December, 1987 / 4 Players
' http://www.ipdb.org/machine.cgi?id=2261
' VP9.16rev626 by MaX
' VP10 by nFozzy
' Version 1.21
'1.21 (1.21 minor hotfix, changed some minor hotfixes)
'Floating Text scores! Implementation of Toxie's idea here http://www.vpforums.org/index.php?showtopic=39255
'New env lighting. Tweaked table lighting, physics. Removed physics hacks.
'New GI color options, GI settings saved to VPReg.stg
'More detailed graphics options (see options at top of table script)
'1.11
'Fixed ball reflections, updated a few scripts
'1.1 changelog
'different GI (and alternative incandescent GI)
'significant memory optimization
'new physics
'Ball shadow routine by Ninuzzu
Option explicit
Randomize
dim FloatingScores
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
'**********************Options********************************
'Graphics options
Const GraphicsLevel = 3 'Between 0 and 4, (Default: 3)
'0 - The barest minimum (will be really dark, turn up day/night slider)
'1 - Low / balanced flashers and GI elements
'2 - All Flasher and GI Elements
'3 - All + GI Ball Reflections + backglass flasher glow + GI compensation
'4 - All That + Habit rail Shadow
const VPXdisplay = 0 'Enable/Disable VPX display. Disable for performance. (Default: 1)
FloatingScores = Table1.ShowDT 'Enable/Disable floating text scores (Default: Table1.ShowDT)
'Does NOT play nicely with B2S at the moment.
'(In a multiplayer game, floating text will only appear for player 1)
Const OldSidewalls = 0 'Restores the old diffuse GI sidewall reflections. More perspective safe. (Default: 0)
Const LoadColorsOverride = 0 'If 'Loadcolors' is erroring for some reason, set this to 1 (Default: 0)
'More options:
const SingleScreenFS = 0 '1 = VPX display 2 = Vpinmame display rotated (Default: 0)
const BackGlassFlasher = 0 'Enable / Disable the backglass rocket flasher in DT mode (Default: 0)
SoundLevelMult = 1 'Increase table SFX (normalization)
'you can switch GI types in-game by pressing the right magnasave with the left magnasave held down
'Debug boxes off
Sub InitTextBoxes() 'turn off debug boxes
dim x : for each x in textboxes : x.visible = 0 : next
End Sub
'Floating text
'*************
ScoreBox.TimerEnabled = FloatingScores
dim FTlow, FTmed, FThigh
InitFloatingText
Sub InitFloatingText()
Set FTlow = New FloatingText
with FTlow
.Sprites(0) = Array(FtLow1_1, FtLow1_2, FtLow1_3, FtLow1_4, FtLow1_5, FTlow1_6)
.Sprites(1) = Array(FtLow2_1, FtLow2_2, FtLow2_3, FtLow2_4, FtLow2_5, FtLow2_6)
.Sprites(2) = Array(FtLow3_1, FtLow3_2, FtLow3_3, FtLow3_4, FtLow3_5, FtLow3_6)
.Sprites(3) = Array(FtLow4_1, FtLow4_2, FtLow4_3, FtLow4_4, FtLow4_5, FtLow4_6)
.Sprites(4) = Array(FtLow5_1, FtLow5_2, FtLow5_3, FtLow5_4, FtLow5_5, FtLow5_6)
.Prefix = "Font_"
.Size = 29/2
.FadeSpeedUp = 1/800
.RotX = -37
end With
Set FTmed = New FloatingText
With FTmed
.Sprites(0) = Array(FtMed1_1, FtMed1_2, FtMed1_3, FtMed1_4, FtMed1_5, FtMed1_6)
.Sprites(1) = Array(FtMed2_1, FtMed2_2, FtMed2_3, FtMed2_4, FtMed2_5, FtMed2_6)
.Sprites(2) = Array(FtMed3_1, FtMed3_2, FtMed3_3, FtMed3_4, FtMed3_5, FtMed3_6)
.Sprites(3) = Array(FtMed4_1, FtMed4_2, FtMed4_3, FtMed4_4, FtMed4_5, FtMed4_6)
.Sprites(4) = Array(FtMed5_1, FtMed5_2, FtMed5_3, FtMed5_4, FtMed5_5, FtMed5_6)
.Prefix = "Font_"
.Size = 29
.FadeSpeedUp = 1/1500
.RotX = -37
End With
Set FThigh = New FloatingText
With FThigh
.Sprites(0) = Array(FtHi1_1, FtHi1_2, FtHi1_3, FtHi1_4, FtHi1_5, FtHi1_6)
.Sprites(1) = Array(FtHi2_1, FtHi2_2, FtHi2_3, FtHi2_4, FtHi2_5, FtHi2_6)
.Sprites(2) = Array(FtHi3_1, FtHi3_2, FtHi3_3, FtHi3_4, FtHi3_5, FtHi3_6)
.Prefix = "Font_"
.Size = 29*4
.FadeSpeedUp = 1/3500
.RotX = -37
End With
End Sub
'A special keyframe animation called with big scores
dim aLutBurst : Set aLutBurst = New cAnimation
with aLutBurst
.AddPoint 0, 0, 0
.AddPoint 1, 130, 20 'up
.AddPoint 2, 150, 14 'hold
.AddPoint 3, 180, 20 'hold
.AddPoint 4, 210, 14 'hold
.AddPoint 5, 240, 20 'hold
.AddPoint 6, 270, 14 'hold
.AddPoint 7, 290, 20 'hold
.AddPoint 8, 320, 14 'hold
.AddPoint 9, 350, 20 'hold
.AddPoint 10,350+130, 0 'down
.Callback = "animLutBurst"
End With
Sub animLutBurst(aLVL)
table1.ColorGradeImage = "RedLut_" & Round(aLVL)
ENd Sub
animlutburst 0
Const UseVPMNVRAM = true
dim LastSwitch : Set LastSwitch = Sw10
dim LastScore : LastScore = 0
Sub ScoreBox_Timer()
Dim NVRAM : NVRAM = Controller.NVRAM
dim str : str = _
ConvertBCD(NVRAM(CInt("&h200"))) & _
ConvertBCD(NVRAM(CInt("&h201"))) & _
ConvertBCD(NVRAM(CInt("&h202"))) & _
ConvertBCD(NVRAM(CInt("&h203"))) 'sys 11 current score
str = round(str)
dim PointGain
PointGain = Str - LastScore
LastScore = str
if PointGain >= 90000 Then 'hi point scores
PlaceFloatingTextHi PointGain, LastSwitch.x, LastSwitch.y
aLutBurst.Play
elseif pointgain >= 2500 then 'medium point scores
ftmed.TextAt PointGain, Lastswitch.x, Lastswitch.Y
elseif pointgain > 0 then 'low point scores
ftlow.TextAt PointGain, Lastswitch.x, Lastswitch.Y
end if
'if debugstr <> "" then
' if tb.text <> debugstr then tb.text = debugstr
'end if
FTlow.Update2
FTmed.Update2
FThigh.Update2
aLutBurst.Update2
End Sub
Function ConvertBCD(v)
ConvertBCD = "" & ((v AND &hF0) / 16) & (v AND &hF)
End Function
'Helper placer sub
Sub PlaceFloatingTextHi(aPointGain, ByVal aX, ByVal aY) 'center text a bit for the big scores
aX = (aX + (table1.width/2))/2
aY = (aY + (table1.Height/2))/2
FThigh.TextAt aPointGain, aX, aY
End Sub
'Switch location handling, or at least the method I use
Sub aSwitches_Hit(aIDX)
Set LastSwitch = aSwitches(aIDX)
End Sub
'Walls don't have x/y coords so a spoof object is used for slingshots.
'Set LastSwitch = LeftSlingPos under 'Sub LeftSlingShot_SlingShot'
Dim LeftSlingPos : Set LeftSlingPos = New WallSwitchPos
Dim RightSlingPos : Set RightSlingPos = New WallSwitchPos
Dim LeftLockPos : Set LeftLockPos = New WallSwitchPos
Class WallSwitchPos : Public x,y,name : End Class
'
LeftLockPos.Name = "LeftLock"
LeftLockPos.x = leftlock.x + 180
LeftLockPos.y = LeftLock.y
LeftSlingPos.Name = "LeftSlingShot"
LeftSlingPos.X = 160+25
LeftSlingPos.Y = 1480
RightSlingPos.Name = "RightSlingShot"
RightSlingPos.X = 700-25
RightSlingPos.Y = 1480
'Some debug boxes
'tb.timerinterval = 2200
'tb.Timerenabled = 1
'Sub tb_timer()
' FTlow.TextAt "1234567", 600, 1000
'End Sub
'Sub tbDB_Timer()
' dim str,x
' for x = 0 to ftlow.count
' str = str & "L&L " & x & ": " & abs(Ftlow.Lock(x)) & "" & abs(Ftlow.loaded(x)) & vbnewline '& " " & FtLow.Text(x)
' Next
' if me.text <> str then me.text = str end if
'End Sub
'End Floating text
'*************
dim BallMass : BallMass = 1
dim BallSize : BallSize = 50
'kas 90, 0.1 : ka k, 419.4706, 945' : coef=1
dim SoundLevelMult, ReflectColor(2), FastFlips, DesktopMode : DesktopMode = Table1.ShowDT
SetLocale(1033) 'Important for lamp routine to work correctly
LoadVPM "01120100", "S11.VBS", 3.65
'*************************************************************
'Debug stuff
Dim DebugFlippers : DebugFlippers = False
dim aDebugBoxes : aDebugBoxes = array(TbBounces, tbpl,tbWR, TbFlipper)
Sub DebugF(input)
dim x
if input = 5 then for each x in aDebugBoxes : x.visible = cBool(input) : next : exit sub
input = cbool(input)
if IsObject(fastflips) then FastFlips.Debug = input
' TiltSol input
destroyer.enabled = input
Sw10.enabled = not input 'space station specific, disable trough
if not input then Sw10.kick -10, 45 'space station specific
for each x in aDebugBoxes : x.visible = input : next
for each x in aDebugBoxes : x.TimerEnabled = input : next
end sub
debugf 0
'debugf 5 'boxes
sub GimmeF() : kl.createsizedballwithmass 25, ballmass : kl.kick 0, 5 : debugf 1 : end Sub
sub Gimmep() : kp.createsizedballwithmass 25, ballmass : kp.kick 0, 5 : debugf 1 : end Sub
sub Gimme() : kr.createsizedballwithmass 25, ballmass : kr.kick 0, 5 : debugf 1 : end Sub
'******************************************************************************
' _______. ______ __ __ .__ __. _______ _______ ___ ___
' / | / __ \ | | | | | \ | | | \ | ____|\ \ / /
' | (----`| | | | | | | | | \| | | .--. | | |__ \ V /
' \ \ | | | | | | | | | . ` | | | | | | __| > <
'.----) | | `--' | | `--' | | |\ | | '--' | | | / . \
'|_______/ \______/ \______/ |__| \__| |_______/ |__| /__/ \__\
'
'******************************************************************************
'10.4 playsound args - name,loopcount,volume,pan,randompitch,pitch,UseExisting,Restart,Fade
'*********Sounds with falloffs*********
Sub Targets_Hit (idx)
PlaySound SoundFX("target",DOFTargets), 0, LVL(0.2), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, Fade(ActiveBall)
PlaySound SoundFX("targethit",0), 0, LVL(Vol(ActiveBall)*18 ), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, Fade(ActiveBall)
End Sub
Sub zCol_Sleeves_Hit() : RandomSoundRubber : End sub
Sub Posts_Hit(idx)
PlaySound RandomPost, 0, LVL(Vol(ActiveBall)*80 ), Pan(ActiveBall)*50, 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
End Sub
Sub Pegs_Hit(idx)
PlaySound RandomPost, 0, LVL(Vol(ActiveBall)*80 ), Pan(ActiveBall)*50, 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall)
End Sub
'*********Other Sounds*********
Sub RampEntry2_Hit() 'Left habitrail out of space station
'Playsound "WireRamp", 0, LVL(0.3)
WireRampOff 'Off of the plastic platform first
WireRampOn False 'Quick hack arg :False = Habitrail, True = Plastic Ramp
End Sub
Sub RampSoundPlunge1_hit() : WireRampOn False : End Sub
Sub RampSoundPlunge2_hit() : WireRampOff : WireRampOn True : End Sub 'Exit Habitrail, onto Mini PF
Sub RampSoundPlunge3_hit() : WireRampOn True : End Sub 'Exit Vuk, onto Mini PF
Sub RampEntry_Hit()
If activeball.vely < -8 then
WireRampOn True
'PlaySound "plasticrolling2", 0, LVL(1), Pan(ActiveBall), 0, Pitch(ActiveBall)*10, 1, 0
PlaySound "ramp_hit2", 0, LVL(Vol(ActiveBall)), Pan(ActiveBall), 0, Pitch(ActiveBall)*10, 0, 0, Fade(activeball)
Elseif activeball.vely > 3 then
'StopSound "plasticrolling2"
PlaySound "PlayfieldHit", 0, LVL(Vol(ActiveBall) ), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, Fade(activeball)
End If
End Sub
'Sub RampSound0_Hit() 'mid plunge
' If Activeball.velx > 0 then
' Playsound "pmaReriW", 0, LVL(1)
' Else
' Playsound "WireRamp1", 0, LVL(1)
' End If
'End Sub
Sub zApron_Hit (idx)
PlaySound "woodhitaluminium", 0, LVL((Vol(ActiveBall))*10), Pan(ActiveBall)/4, 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall)
End Sub
Sub zPlastic_Hit (idx)
PlaySound "Rubber_Hit_2", 0, LVL(Vol(ActiveBall)*30), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall)
End Sub
Sub zInlanes_Hit (idx)
PlaySound "MetalHit2", 0, LVL(Vol(ActiveBall)*5), Pan(ActiveBall)*55, 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall)
End Sub
Sub RampHit2_Hit()
PlaySound "ramp_hit3", 0, LVL(Vol(ActiveBall) ), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall)
End Sub
Sub Metals_Hit (idx)
PlaySound "metalhit_medium", 0, LVL(Vol(ActiveBall)*30 ), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall)
End Sub
Sub Gates_Hit (idx)
PlaySound "gate", 0, LVL(Vol(ActiveBall) ), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall)
End Sub
'Ramp drops using collision events
Sub col_UPF_Fall_hit():if FallSFX1.Enabled = 0 then playsound "drop_mono", 0, LVL(0.5), 0,0,0,0,0,Fade(ActiveBall) :FallSFX1.Enabled = 1 :end if :end sub'name,loopcount,volume,pan,randompitch
Sub FallSFX1_Timer():me.Enabled = 0:end sub
Sub Col_Rramp_Fall_Hit():if FallSFX2.Enabled = 0 then playsound "drop_mono", 0, LVL(0.5), 0.05,0,0,0,0,Fade(ActiveBall) :FallSFX2.Enabled = 1 :end if :end sub'name,loopcount,volume,pan,randompitch
Sub FallSFX2_Timer():me.Enabled = 0:end sub
Sub col_Lramp_Fall_Hit():if FallSFX3.Enabled = 0 then playsound "drop_mono", 0, LVL(0.5), -0.05,0,0,0,0,Fade(ActiveBall) :FallSFX3.Enabled = 1 :end if :end sub'name,loopcount,volume,pan,randompitch
Sub FallSFX3_Timer():me.Enabled = 0:end sub
Sub LeftSlingShot_Hit(): Playsound RandomBand, 0, LVL(Vol(ActiveBall)*100 ), Pan(ActiveBall)*50, 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall) : End Sub
Sub RightSlingShot_Hit(): Playsound RandomBand, 0, LVL(Vol(ActiveBall)*100 ), Pan(ActiveBall)*50, 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall) : End Sub
Sub Bands_Hit(idx) : Playsound RandomBand, 0, LVL(Vol(ActiveBall)*100 ), Pan(ActiveBall)*50, 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall) : End Sub
Sub RandomSoundRubber() : PlaySound RandomPost, 0, LVL(Vol(ActiveBall)*100 ), Pan(ActiveBall)*50, 0, Pitch(ActiveBall), 1, 0, Fade(ActiveBall) : End Sub
'SFX string functions -SFX - Posts 1-5, Bands 1-4 and 11,22,33,44
Function RandomPost() : RandomPost = "Post" & rndnum(1,5) : End Function
Function RandomBand()
dim x : x = rndnum(1,4)
if BallVel(activeball) > 30 then
RandomBand = "Rubber" & x & x 'ex. Playsound "Band44"
else
RandomBand = "Rubber" & x 'ex. Playsound "Band4"
End If
End Function
'Flipper collide sound
Sub LeftFlipper_Collide(parm) : RandomSoundFlipper() : End Sub
Sub RightFlipper_Collide(parm) : RandomSoundFlipper() : End Sub
Sub RandomSoundFlipper()
dim x : x = RndNum(1,3)
PlaySound "flip_hit_" & x, 0, LVL(Vol(ActiveBall)*50 ), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0,Fade(ActiveBall)
End Sub
' Ball Collision Sound
Sub OnBallBallCollision(ball1, ball2, velocity) : PlaySound("fx_collide"), 0, LVL(Csng(velocity) ^2 / 2000), Pan(ball1), 0, Pitch(ball1), 0, 0,Fade(ball1) : End Sub
'*****************************************
' JP's VP10 Rolling Sounds
'*****************************************
Const tnob = 9 ' 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
For b = UBound(BOT) + 1 to tnob ' stop the sound of deleted balls
rolling(b) = False
StopSound("tablerolling" & b)
Next
If UBound(BOT) = -1 Then Exit Sub ' exit the sub if no balls on the table
For b = 0 to UBound(BOT) ' play the rolling sound for each ball
If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
rolling(b) = True
PlaySound("tablerolling" & b), -1, Vol(BOT(b) )^0.8, Pan(BOT(b) )*3, 0, BallPitch(BOT(b)), 1, 0,Fade(BOT(b))*3
Else
If rolling(b) = True Then
StopSound("tablerolling" & b)
rolling(b) = False
End If
End If
Next
End Sub
Sub StopAllRolling() 'call this at table pause!!!
dim b : for b = 0 to tnob
StopSound("tablerolling" & b)
StopSound("RampLoop" & b)
StopSound("wireloop" & b)
next
end sub
'=====================================
' Ramp Rolling SFX updates nf
'=====================================
'Ball tracking ramp SFX 1.0
' Usage:
'- Setup hit events with WireRampOn True or WireRampOn False (True = Plastic ramp, False = Wire Ramp)
'- To stop tracking ball, use WireRampoff
'-- Otherwise, the ball will auto remove if it's below 30 vp units
'Example, from Space Station:
'Sub RampSoundPlunge1_hit() : WireRampOn False : End Sub 'Enter metal habitrail
'Sub RampSoundPlunge2_hit() : WireRampOff : WireRampOn True : End Sub 'Exit Habitrail, enter onto Mini PF
'Sub RampEntry_Hit() : If activeball.vely < -10 then WireRampOn True : End Sub 'Ramp enterance
dim RampMinLoops : RampMinLoops = 4
dim RampBalls(6,2)
'x,0 = ball x,1 = ID, 2 = Protection against ending early (minimum amount of updates)
'0,0 is boolean on/off, 0,1 unused for now
RampBalls(0,0) = False
dim RampType(6) 'Slapped together support for multiple ramp types... False = Wire Ramp, True = Plastic Ramp
Sub WireRampOn(input) : Waddball ActiveBall, input : RampRollUpdate: End Sub
Sub WireRampOff() : WRemoveBall ActiveBall.ID : End Sub
Sub Waddball(input, RampInput) 'Add ball
dim x : for x = 1 to uBound(RampBalls) 'Check, don't add balls twice
if RampBalls(x, 1) = input.id then
if Not IsEmpty(RampBalls(x,1) ) then Exit Sub 'Frustating issue with BallId 0. Empty variable = 0
End If
Next
For x = 1 to uBound(RampBalls)
if IsEmpty(RampBalls(x, 1)) then
Set RampBalls(x, 0) = input
RampBalls(x, 1) = input.ID
RampType(x) = RampInput
RampBalls(x, 2) = 0
'exit For
RampBalls(0,0) = True
RampRoll.Enabled = 1 'Turn on timer
'RampRoll.Interval = RampRoll.Interval 'reset timer
exit Sub
End If
if x = uBound(RampBalls) then 'debug
Debug.print "WireRampOn error, ball queue is full: " & vbnewline & _
RampBalls(0, 0) & vbnewline & _
Typename(RampBalls(1, 0)) & " ID:" & RampBalls(1, 1) & "type:" & RampType(1) & vbnewline & _
Typename(RampBalls(2, 0)) & " ID:" & RampBalls(2, 1) & "type:" & RampType(2) & vbnewline & _
Typename(RampBalls(3, 0)) & " ID:" & RampBalls(3, 1) & "type:" & RampType(3) & vbnewline & _
Typename(RampBalls(4, 0)) & " ID:" & RampBalls(4, 1) & "type:" & RampType(4) & vbnewline & _
Typename(RampBalls(5, 0)) & " ID:" & RampBalls(5, 1) & "type:" & RampType(5) & vbnewline & _
" "
End If
next
End Sub
Sub WRemoveBall(ID) 'Remove ball
dim ballcount : ballcount = 0
dim x : for x = 1 to Ubound(RampBalls)
if ID = RampBalls(x, 1) then 'remove ball
Set RampBalls(x, 0) = Nothing
RampBalls(x, 1) = Empty
RampType(x) = Empty
StopSound("RampLoop" & x)
StopSound("wireloop" & x)
end If
'if RampBalls(x,1) = Not IsEmpty(Rampballs(x,1) then ballcount = ballcount + 1
if not IsEmpty(Rampballs(x,1)) then ballcount = ballcount + 1
next
if BallCount = 0 then RampBalls(0,0) = False 'if no balls in queue, disable timer update
End Sub
Sub RampRoll_Timer():RampRollUpdate:End Sub
Sub RampRollUpdate() 'Timer update
dim x : for x = 1 to uBound(RampBalls)
if Not IsEmpty(RampBalls(x,1) ) then
if BallVel(RampBalls(x,0) ) > 1 then ' if ball is moving, play rolling sound
If RampType(x) then
PlaySound("RampLoop" & x), -1, Vol(RampBalls(x,0) )*10, Pan(RampBalls(x,0) )*3, 0, BallPitchV(RampBalls(x,0) ), 1, 0,Fade(RampBalls(x,0) )'*3
StopSound("wireloop" & x)
Else
StopSound("RampLoop" & x)
PlaySound("wireloop" & x), -1, Vol(RampBalls(x,0) )*10, Pan(RampBalls(x,0) )*3, 0, BallPitch(RampBalls(x,0) ), 1, 0,Fade(RampBalls(x,0) )'*3
End If
RampBalls(x, 2) = RampBalls(x, 2) + 1
Else
StopSound("RampLoop" & x)
StopSound("wireloop" & x)
end if
if RampBalls(x,0).Z < 30 and RampBalls(x, 2) > RampMinLoops then 'if ball is on the PF, remove it
StopSound("RampLoop" & x)
StopSound("wireloop" & x)
Wremoveball RampBalls(x,1)
End If
Else
StopSound("RampLoop" & x)
StopSound("wireloop" & x)
end if
next
if not RampBalls(0,0) then RampRoll.enabled = 0
End Sub
Sub tbWR_Timer() 'debug textbox
me.text = "on? " & RampBalls(0, 0) & " timer: " & RampRoll.Enabled & vbnewline & _
"1 " & Typename(RampBalls(1, 0)) & " ID:" & RampBalls(1, 1) & " type:" & RampType(1) & " Loops:" & RampBalls(1, 2) & vbnewline & _
"2 " & Typename(RampBalls(2, 0)) & " ID:" & RampBalls(2, 1) & " type:" & RampType(2) & " Loops:" & RampBalls(2, 2) & vbnewline & _
"3 " & Typename(RampBalls(3, 0)) & " ID:" & RampBalls(3, 1) & " type:" & RampType(3) & " Loops:" & RampBalls(3, 2) & vbnewline & _
"4 " & Typename(RampBalls(4, 0)) & " ID:" & RampBalls(4, 1) & " type:" & RampType(4) & " Loops:" & RampBalls(4, 2) & vbnewline & _
"5 " & Typename(RampBalls(5, 0)) & " ID:" & RampBalls(5, 1) & " type:" & RampType(5) & " Loops:" & RampBalls(5, 2) & vbnewline & _
"6 " & Typename(RampBalls(6, 0)) & " ID:" & RampBalls(6, 1) & " type:" & RampType(6) & " Loops:" & RampBalls(6, 2) & vbnewline & _
" "
End Sub
' *********************************************************************
' Ball & Sound Functions
' *********************************************************************
'10.4 playsound args - name,loopcount,volume,pan,randompitch,pitch,UseExisting,Restart,Fade
'**************** 3D Audio Vp10.4 Functions ****************
Function Fade(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
Fade = Csng(tmp ^10)
Else
Fade = Csng(-((- tmp) ^10) )
End If
End Function
Function FadeY(Y) ' 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 = y * 2 / table1.height-1
If tmp > 0 Then
FadeY = Csng(tmp ^10)
Else
FadeY = Csng(-((- tmp) ^10) )
End If
End Function
'**************** Other sound functions ****************
Function RndNum(min, max)
RndNum = Int(Rnd() * (max-min + 1) ) + min ' Sets a random number between min and max
End Function
Function LVL(input) : LVL = Input * SoundLevelMult : End Function
Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
Vol = Csng(BallVel(ball) ^2 / 2000)
End Function
Function Vol2(ball1, ball2) ' Calculates the Volume of the sound based on the speed of two balls
Vol2 = (Vol(ball1) + Vol(ball2) ) / 2
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 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 + ball.VelZ^2) )
End Function
Function BallSpeed(ball) 'Calculates the ball speed
BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
End Function
'new
Function BallPitch(ball) ' Calculates the pitch of the sound based on the ball speed
BallPitch = pSlope(BallVel(ball), 1, -1000, 60, 10000)
End Function
Function BallPitchV(ball) ' Calculates the pitch of the sound based on the ball speed Variation
BallPitchV = pSlope(BallVel(ball), 1, -4000, 60, 7000)
End Function
'EOStimer (just switches elast falloff)
'============
'LFHM physics by wrd1972 and Rothbauer
dim EOSAngle,ElastFalloffUp,ElastFalloffDown
ElastFalloffup = LeftFlipper.ElasticityFalloff
ElastFalloffdown = 0.7'0.7
'EOS angle
EOSAngle = 4
'Flipper EOS timer (HMLF)
dim LastAngleL, LastAngleR '
Sub eostimer_Timer() 'use -1 timer interval for this?
If LeftFlipper.CurrentAngle <> LastAngleL then 'slight optimization
'If LeftFlipper.CurrentAngle < LeftFlipper.EndAngle + EOSAngle Then
If LeftFlipper.CurrentAngle = LeftFlipper.EndAngle or _
LeftFlipper.CurrentAngle = LeftFlipper.StartAngle Then
LeftFlipper.ElasticityFalloff = ElastFalloffup
Else
LeftFlipper.ElasticityFalloff = ElastFalloffdown
End If
End If
If RightFlipper.CurrentAngle <> LastAngleR then
'If RightFlipper.CurrentAngle > RightFlipper.EndAngle - EOSAngle Then
If RightFlipper.CurrentAngle = RightFlipper.EndAngle or _
RightFlipper.CurrentAngle = RightFlipper.StartAngle Then
RightFlipper.ElasticityFalloff = ElastFalloffup
Else
RightFlipper.ElasticityFalloff = ElastFalloffdown
End If
End If
'dim str : str = LeftFlipper.ElasticityFalloff
'if tb.text <>str then tb.text = str
LastAngleL = LeftFlipper.CurrentAngle
LastAngleR = RightFLipper.CurrentAngle
End Sub
'**************************************
Siderails.visible = Table1.ShowDT
F31.visible = Table1.ShowDT
'F31.Visible = BackGlassFlasher
P_InstructionsFS.visible = Not Table1.ShowDT : P_InstructionsDT.visible = Table1.ShowDT
Const cGameName = "spstn_l5"
Const UseSolenoids = 1 'Don't touch -nf
Const UseLamps = 0
Const UseGI = 0
Const UseSync = 0
Const HandleMech = 0
' Standard Sounds
Const SCoin = "fx_Coin"
Dim bsTrough, bsLeftBallPopper, bsRightBallPopper, bsRightLock, bsLeftLock, dtdrop, dt3bank, mufo
Dim musicNum
musicNum = int ( rnd * 6)
NextTrack
Sub Table1_Init
vpmInit Me
With Controller
.GameName = cGameName
If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description:Exit Sub
.SplashInfoLine = "Space Station (Williams 1987)"
' .Games(cGameName).Settings.Value("rol") = 0
.HandleKeyboard = 0
.ShowTitle = 0
.ShowDMDOnly = 1
.ShowFrame = 0
.HandleMechanics = 0
.Hidden = 0
.SetDisplayPosition 0,0,GetPlayerHWnd 'if you can't see the DMD then uncomment this line
.Games("spstn_l5").Settings.Value("sound") = 0
.Games("spstn_l5").Settings.Value("samples") = 0
On Error Resume Next
' Controller.SolMask(0) = 0
' vpmTimer.AddTimer 2000, "Controller.SolMask(0)=&Hffffffff'" 'ignore all solenoids - then add the timer to renable all the solenoids after 2 seconds
Controller.Run GetPlayerHwnd
' .DIP(0) = &H00 'Taxi
If Err Then MsgBox Err.Description
On Error Goto 0
End With
If SingleScreenFS = 2 and not Table1.ShowDT then
Controller.Games(cGameName).Settings.Value("rol") = 1
Else
Controller.Games(cGameName).Settings.Value("rol") = 0
Controller.Hidden = 1
End If
If VPXdisplay = 0 then
Controller.Hidden = 0
End If
On Error Goto 0
' Nudging
vpmNudge.TiltSwitch = 9
vpmNudge.Sensitivity = 0.25
vpmNudge.TiltObj = Array(LeftSlingshot, RightSlingshot, bumper1, bumper2)',Bumper3)
'sw41 Left Ball Popper (Top of Table)
Set bsLeftBallPopper = New cvpmSaucer
with bsLeftBallPopper
.InitKicker LeftBallPopper, 41, 85, 85, 100 '82 'switch, direction, force, Zforce '65
' .InitExitVariance 2, 2
End With
'sw42 Right Ball Popper (Mega VUK)
Set bsRightBallPopper = New cvpmSaucer
with bsRightBallPopper
.InitKicker RightBallPopper, 42, 85, 95, 100 'switch, direction, force, Zforce
.InitExitVariance 0, 5
End With
'sw45 Right Lock
Set bsRightLock = New cvpmSaucer
with bsRightLock
.InitKicker RightLock, 45, 0, 32, 0 'switch, direction, force, Zforce '28
.InitExitVariance 1, 2
End With
'sw47 Left Lock
Set bsLeftLock = New cvpmSaucer
with bsLeftLock
'.InitKicker LeftLock, 47, 0, 32, 0 'switch, direction, force, Zforce
.InitKicker LeftLock, 47, 0, 30, 0 'switch, direction, force, Zforce
.InitExitVariance 5, 2
End With
'sw33 Drop Target 1-bank
' Set dtDrop = New cvpmDropTarget
' with dtDrop
' .InitDrop Array(sw33), Array(33)
' .InitSnd "fx_droptarget", "resetdrop"
'' .CreateEvents "dtDrop"
' End With
'Drop Target 3-bank
Set dt3bank = New cvpmDropTarget
with dt3bank
.InitDrop Array(sw57, sw58, sw59), Array(57, 58, 59)
.InitSnd "", SoundFX("resetdrop",DOFDropTargets)
End With
' Main Timer init
PinMAMETimer.Interval = PinMAMEInterval
PinMAMETimer.Enabled = 1
LampTimer.Enabled = 1
' Init Kickback
KickBack.Pullback
'start trough
sw13.CreateSizedBallWithMass 25, BallMass
sw12.CreateSizedBallWithMass 25, BallMass
sw11.CreateSizedBallWithMass 25, BallMass
'Init animations
LeftSling.Showframe 100
LeftSlingArm.Showframe 100
RightSling.Showframe 100
RightSlingArm.Showframe 100
BumperRing1.Showframe 100
BumperRing2.Showframe 100
BumperRing3.Showframe 100
RubberAnim_1.Showframe 100
RubberAnim_2.Showframe 100
BallSearch 'init switches
if GraphicsLevel > 2 then
dim x
for each x in ReflectionsGI
x.state = 1
x.visible = 1
Next
For each x in ReflectionsGIB
x.state = 0
x.visible = 1
next
End If
if cbool(OldSidewalls) then
gi_left.imagea = "GILv"
gi_Right.imagea = "GIRv"
gig_left.imagea = "GIGL"
gig_Right.imagea = "GIGR"
End If
InitAnimations
InitLampsNF
if GraphicsLevel > 3 then
shadowtest.IntensityScale = 1
shadowtestp.IntensityScale = 1
end if
'GI color pulled from VPReg.stg
gic.name = "SpaceStationNF" 'Name (Public) 'String input. Sets Name of game in VPReg.stg. IE 'SpaceStationNF'
gic.Value = "GIcolor" 'Value (Public) 'String input. Sets Key for color in VPReg.stg.IE 'GIcolor'
If Not cBool(LoadColorsOverride) then gic.LoadColors
End Sub
Sub table1_Paused:Controller.Pause = 1: StopAllRolling:End Sub
Sub table1_unPaused:Controller.Pause = 0:End Sub
Sub Table1_exit():gic.SaveColors : Controller.Pause = False:Controller.Stop:End Sub 'Save color to VPReg.stg
Sub Destroyer_Hit:Me.destroyball : End Sub
Sub zCol_Band_Anim1_Hit():RubberAnim_1.Playanim 0, (3*Lampz.FrameTime/500):End Sub
Sub zCol_BandUPF_Hit():RubberAnim_2.Playanim 0, (3*Lampz.FrameTime/500):End Sub
Sub Gate6_Hit(): activeball.velx = activeball.velx*0.95 : activeball.vely = activeball.vely*0.95 : End Sub 'switch and gate slow ball to left vuk
Sub Gate5_Hit(): activeball.velx = activeball.velx*0.95 : activeball.vely = activeball.vely*0.95 : End Sub
dim CatchInput(1) : CatchInput(0) = 0 : CatchInput(1) = 0
Sub Table1_KeyDown(ByVal keycode)
If vpmKeyDown(keycode) Then Exit Sub
If keycode = PlungerKey Then PlaySound SoundFx("plungerpull",0),0,LVL(1),0.25,0.25:Plunger.Pullback:End If
If KeyCode = LeftFlipperKey then FastFlips.FlipL True' : FastFlips.FlipUL True
If KeyCode = RightFlipperKey then FastFlips.FlipR True' : FastFlips.FlipUR True
if Keycode = KeyRules then
If DesktopMode Then
P_InstructionsDT.PlayAnim 0, 3*Lampz.FrameTime/500
Else
P_InstructionsFS.PlayAnim 0, 3*Lampz.FrameTime/500
End If
Exit Sub
End If
if keycode = LeftMagnaSave then catchinput(0) = True
if keycode = RightMagnaSave then catchinput(1) = True : if catchinput(0) and lampz.state(109) > 0 then gic.changeGI : playsound "fx_relay_on", 0, LVL(0.1)
'' if keycode = 31 then Testtu 'test backhand shot
'
' if keycode = 203 then TestL 'test backhand shot 'leftarrow
' if keycode = 200 then TestM 'test backhand shot 'Uparrow
' if keycode = 205 then TestR 'test backhand shot 'Right Arrow
' If keycode = LeftFlipperKey Then :FlippersEnabled = True: flipnf 0, 1: exit sub:End If 'debug always-on flippers
' If keycode = RightFlipperKey Then :FlippersEnabled = True: flipnf 1, 1: exit sub:End If 'debug always-on flippers
End Sub
Sub Table1_KeyUp(ByVal keycode)
If vpmKeyUp(keycode) Then Exit Sub
If keycode = PlungerKey Then
Plunger.Fire
if BallInPlunger then
PlaySound SoundFX("plunger3",0),0,LVL(1),0.05,0.02,0,0,0,FadeY(1900)
Else
PlaySound SoundFX("plunger",0),0,LVL(0.8),0.05,0.02,0,0,0,FadeY(1900)
end if
End If
if Keycode = KeyRules then
If DesktopMode Then
P_InstructionsDT.ShowFrame 0
Else
P_InstructionsFs.ShowFrame 0
End If
Exit Sub
End If
if keycode = LeftMagnaSave then catchinput(0) = False
if keycode = RightMagnaSave then catchinput(1) = False
If KeyCode = LeftFlipperKey then FastFlips.FlipL False' : FastFlips.FlipUL False
If KeyCode = RightFlipperKey then FastFlips.FlipR False' : FastFlips.FlipUR False
End Sub
'******************************
'* HiRez00: Music Mod *
'******************************
Sub NextTrack
If musicNum = 0 Then PlayMusic "bowie1.mp3" End If
If musicNum = 1 Then PlayMusic "bowie2.mp3" End If
If musicNum = 2 Then PlayMusic "bowie3.mp3" End If
If musicNum = 3 Then PlayMusic "bowie4.mp3" End If
If musicNum = 4 Then PlayMusic "bowie5.mp3" End If
If musicNum = 5 Then PlayMusic "bowie6.mp3" End If
musicNum = (musicNum + 1) mod 6
End Sub
Sub Table1_MusicDone
NextTrack
End Sub
'***********
'VP10.2 Style OBJ Animations note
'VP10 animation OBJ squences only play back properly at 60FPS.
'So playback speed must be compensated for in script to play back at the proper speed regardless of framerate.
'x = Lampz.FrameTime y = Playback Speed
'y = 3x/50
Sub TestAnims
dim x
x = 3*Lampz.FrameTime'/500
LeftSling.playanim 0, x
LeftSlingArm.playanim 0, x
RightSling.playanim 0, x
RightSlingArm.playanim 0, x
BumperRing1.playanim 0, x
BumperRing2.playanim 0, x
BumperRing3.playanim 0, x
RubberAnim_1.Playanim 0, x
RubberAnim_2.Playanim 0, x
' lefta.playanim 0, (3*Lampz.FrameTime/500)
End Sub
'Trough Handling
'==============
SolCallback(1) = "TroughIn" ' Drain
SolCallback(2) = "TroughOut" ' Ball Release
Sub TroughIn(enabled)
if Enabled then
sw10.Kick 60, 16 :
Tgate.Open = True
If sw10.BallCntOver > 0 Then Playsound SoundFX("Trough1",DOFcontactors), 0, LVL(0.5), 0.01 : End If
Else
Tgate.Open = False
BallSearch
End If
end Sub
Sub TroughOut(enabled): if Enabled then sw11.Kick 58, 8 :Playsound SoundFX("BallRelease",DOFcontactors), 0, LVL(0.4), 0.02:End If: end Sub
'Trough Switches
'Sub sw10_hit():controller.Switch(10) = 1 : Playsound "Trough2", 0, 0.2, 0: End Sub 'Drain
Sub sw10_hit()
Set LastSwitch = L44 'floatingtext
if sw11.BallCntOver + sw12.BallCntOver + Sw13.BallCntOver + _
PlungerLane.BallcntOver + LeftLock.BallCntOver + _
SafetyL.BallCntOver + safetyR.ballCntOver + _
LeftBallPopper.BallCntOver + RightLock.BallCntOver >= 3 then me.destroyball : exit sub
controller.Switch(10) = 1
End Sub 'Drain
Sub TroughSFX_Hit(): Playsound "Trough2", 0, LVL(0.2), 0:: End Sub
Sub Sw13_hit():controller.Switch(13) = 1 : UpdateTrough : End Sub
Sub Sw12_hit():controller.Switch(12) = 1 : UpdateTrough : End Sub
Sub Sw11_hit():controller.Switch(11) = 1 : UpdateTrough : End Sub
Sub sw10_UnHit():controller.Switch(10) = 0 : UpdateTrough : End Sub
Sub Sw13_UnHit():controller.Switch(13) = 0 : UpdateTrough : End Sub