-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathBarracora (Williams 1981) mod v1.3.vbs
641 lines (494 loc) · 20.2 KB
/
Barracora (Williams 1981) mod v1.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
'Barracora - Williams 1981 by Dids666
'
'Thanks to JP and gtxJoe for some of the code used and the lamp numbers(VP9 version and Titan VPX) (I would have no idea otherwise)
'
'Thanks to DJRobX for adding surround support and solving some errors
'
'Thanks to the testers:...
'
'Ver 1.1
' Thalamus 2018-07-19
' Added/Updated "Positional Sound Playback Functions" and "Supporting Ball & Sound Functions"
' Changed UseSolenoids=1 to 2
' No special SSF tweaks yet.
Option Explicit
Randomize
' ===============================================================================================
' Load game controller
' ===============================================================================================
On Error Resume Next
ExecuteGlobal GetTextFile("controller.vbs")
If Err Then MsgBox "Can't open controller.vbs"
On Error Goto 0
LoadVPM "00990300", "S7.VBS", 3.36
' ===============================================================================================
' General constants and variables
' ===============================================================================================
Const UseSolenoids = 2
Const UseLamps = 1
Const UseGI = 1
Const UseSync = 0 'set it to 1 if the table runs too fast
Const HandleMech = 0
' Standard Sounds
Const SSolenoidOn = "fx_Solenoid"
Const SSolenoidOff = ""
Const SFlipperOn = "fx_Flipperup"
Const SFlipperOff = "fx_Flipperdown"
Const SCoin = "fx_Coin"
Dim bsTrough, dtbank1, dtbank2, bsLeftSaucer, bsRightSaucer, x
Const cGameName = "barra_l1"
Dim bsLowerEject,bsUpperEject
Dim gameRun
' Lights
vpmMapLights AllLights
' ===============================================================================================
' Init routines
' ===============================================================================================
Sub table1_Init
vpmInit me
With Controller
.GameName = cGameName
If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description:Exit Sub
.SplashInfoLine = "Barracora - Williams 1981" & vbNewLine & "VPX table by Dids666"
.HandleKeyboard = 0
.ShowTitle = 0
.ShowDMDOnly = 1
.ShowFrame = 0
.HandleMechanics = 0
.Games(cGameName).Settings.Value("rol") = 0 '1= rotated display, 0= normal
'.SetDisplayPosition 0,0, GetPlayerHWnd 'restore dmd window position
On Error Resume Next
Controller.SolMask(0) = 1
'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
On Error Goto 0
End With
' Nudging
vpmNudge.TiltSwitch = 1
vpmNudge.Sensitivity = 3
vpmNudge.TiltObj = Array(sw20, sw21, sw22, LeftSlingshot, RightSlingshot)
' Trough
set bsTrough= new cvpmballstack
bsTrough.initsw 0,15,14,13,0,0,0,0
bsTrough.initkick ballrelease,90,1
bsTrough.balls=3
' Saucers
Set bsUpperEject = New cvpmBallStack
bsUpperEject.InitSaucer sw10, 10,65,8
bsUpperEject.kickanglevar=5
bsUpperEject.InitExitSnd SoundFX("fx_kicker", DOFContactors), SoundFX("fx_Solenoid", DOFContactors)
bsUpperEject.KickForceVar = 6
Set bsLowerEject = New cvpmBallStack
bsLowerEject.InitSaucer sw11, 11,169,5
bsLowerEject.kickanglevar=5
bsLowerEject.InitExitSnd SoundFX("fx_kicker", DOFContactors), SoundFX("fx_Solenoid", DOFContactors)
bsLowerEject.KickForceVar = 6
' Drop targets
set dtbank1 = new cvpmdroptarget
dtbank1.InitDrop Array(sw41, sw42, sw43), Array(41, 42, 43)
dtbank1.initsnd SoundFX("", DOFDropTargets), SoundFX("fx2_droptargetreset", DOFContactors)
set dtbank2 = new cvpmdroptarget
dtbank2.InitDrop Array(sw44, sw45, sw46, sw47, sw48), Array(44, 45, 46, 47, 48)
dtbank2.initsnd SoundFX("", DOFDropTargets), SoundFX("fx2_droptargetreset", DOFContactors)
vpmTimer.AddTimer 2000, "Controller.SolMask(0)=&Hffffffff'"
End Sub
Sub table1_Paused:Controller.Pause = 1:End Sub
Sub table1_unPaused:Controller.Pause = 0:End Sub
Sub table1_exit:Controller.stop:End Sub
' ===============================================================================================
' KeyDown routines
' ===============================================================================================
Sub table1_KeyDown(ByVal Keycode)
If keycode = LeftTiltKey Then Nudge 90, 5:PlaySound SoundFX("fx_nudge", 0), 0, 1, -0.1, 0.25
If keycode = RightTiltKey Then Nudge 270, 5:PlaySound SoundFX("fx_nudge", 0), 0, 1, 0.1, 0.25
If keycode = CenterTiltKey Then Nudge 0, 6:PlaySound SoundFX("fx_nudge", 0), 0, 1, 0, 0.25
If keycode = PlungerKey Then PlaySoundAt "fx_PlungerPull", Plunger:Plunger.Pullback
if keycode = rightflipperkey then controller.switch(35) = 1 'Mudas as lampadas de cima
if keycode = leftflipperkey then controller.switch(34) = 1
If vpmKeyDown(keycode)Then Exit Sub
End Sub
' ===============================================================================================
' KeyUp routines
' ===============================================================================================
Sub table1_KeyUp(ByVal Keycode)
if keycode = rightflipperkey then controller.switch(35) = 0
if keycode = leftflipperkey then controller.switch(34) = 0
If vpmKeyUp(keycode)Then Exit Sub
If keycode = PlungerKey Then PlaySoundAt "fx_plunger", Plunger:Plunger.Fire
End Sub
' ===============================================================================================
' Solenoids constants and routines
' ===============================================================================================
Const sBallRampThrow=12
Const sBell=15
'Const sCoin=16
Const sUpperGate=17
Const sJetLeft=18
Const sJetRight=19
Const sJetCenter=20
Const sSlingLeft=21
Const sSlingRight=22
Const sEnable=25
Const sDTLeftB_S1=1
Const sDTLeftA_S2=2
Const sDTLeftRR_S3=3
Const sDTRightA_S4=4
Const sDTRightC_S5=5
Const sDTRightO_S6=6
Const sDTRightR_S7=7
Const sDTRightA2_S8=8
Const sDTLeftRel_S9=9
Const sDTRightRel_S10=10
Const sBallRel=11
Const sEjectUpper=13
Const sEjectLower=14
'SolCallbacks
SolCallback(sDTLeftB_S1) = "dtbank1.SolUnhit 1,"
SolCallback(sDTLeftA_S2) = "dtbank1.SolUnhit 2,"
SolCallback(sDTLeftRR_S3) = "dtbank1.SolUnhit 3,"
SolCallback(sDTRightA_S4) = "dtbank2.SolUnhit 1,"
SolCallback(sDTRightC_S5) = "dtbank2.SolUnhit 2,"
SolCallback(sDTRightO_S6) = "dtbank2.SolUnhit 3,"
SolCallback(sDTRightR_S7) = "dtbank2.SolUnhit 4,"
SolCallback(sDTRightA2_S8) = "dtbank2.SolUnhit 5,"
SolCallback(sDTLeftRel_S9) = "dtbank1.SolDropDown"
SolCallback(sDTRightRel_S10) = "dtbank2.SolDropDown"
SolCallback(sBallRel)="sBallRelease"
'SolCallback(1) = "bsTrough.SolOut"
SolCallback(sBallRampThrow)="sBallRampThrower"
SolCallback(sEjectUpper)="bsUpperEject.solout"
SolCallback(sEjectLower)="bsLowerEject.solout"
SolCallback(sBell)="vpmsolsound""fx2_bell"","
''SolCallback(sCoin)= - Not Used
SolCallback(sUpperGate)="UpperKickerGate"
SolCallback(sJetLeft) = "vpmsolsound""fx2_Bumper_2"","
SolCallback(sJetRight) = "vpmsolsound ""fx2_Bumper_2"","
SolCallback(sJetCenter) = "vpmsolsound ""fx2_Bumper_2"","
SolCallback(sSlingLeft) = "vpmsolsound ""fx_slingshot1"","
SolCallback(sSlingRight) = "vpmsolsound ""fx_slingshot2"","
SolCallback(sllflipper)="SolLFlipper"
SolCallback(slrflipper)="SolRFlipper"
'----- Solenoid Subroutines
Sub sBallRelease(enabled) '11
controller.switch (12)=False
End Sub
Dim SyncLampsFlag
Sub sBallRampThrower(enabled)
if enabled then
controller.switch (12)=False
bsTrough.exitsol_on
playsoundat "fx_BallRel", Plunger
'SyncLamps 'ensure lights are synchronized at start of new ball
SyncLampsFlag = 4
end if
End Sub
Sub UpperKickerGate(enabled): gate1.open=True: End Sub
' ===============================================================================================
' Trigger/Switch routines
' ===============================================================================================
'----- Kickers -----
Sub sw10_Hit() 'Switch10
bsUpperEject.addball 0
PlaySoundAt "kicker_enter_left", sw10
End Sub
Sub sw11_Hit() 'Switch11
bsLowerEject.addball 0
PlaySoundAt "kicker_enter_left", sw11
End Sub
Sub Drain_Hit() 'Switch12
Drain.DestroyBall
PlaySound "fx_drain"
bsTrough.addball me
controller.switch (12)=True
End Sub
'----- Flippers -----
Sub LaneChangeRight:vpmtimer.pulsesw 35:End Sub
Sub LangeChangeLeft:vpmtimer.pulsesw 34:End Sub
'********************
' JP Flippers
'********************
Sub SolLFlipper(Enabled)
If Enabled Then
PlaySound SoundFX("fx_flipperup",DOFContactors), 0, 1, -0.1, 0.25, 0, 0, 1, 1
LeftFlipper.RotateToEnd
Else
PlaySound SoundFX("fx_flipperdown",DOFContactors), 0, 1, -0.1, 0.25, 0, 0, 1, 1
LeftFlipper.RotateToStart
End If
End Sub
Sub SolRFlipper(Enabled)
If Enabled Then
PlaySound SoundFX("fx_flipperup",DOFContactors), 0, 1, 0.1, 0.25, 0, 0, 1, 1
RightFlipper.RotateToEnd
Else
PlaySound SoundFX("fx_flipperdown",DOFContactors), 0, 1, 0.1, 0.25, 0, 0, 1, 1
RightFlipper.RotateToStart
End If
End Sub
Sub LeftFlipper_Collide(parm)
PlaySoundAtBall "fx_rubber_flipper"
End Sub
Sub RightFlipper_Collide(parm)
PlaySoundAtBall "fx_rubber_flipper"
End Sub
'----Rollovers---
Sub sw23_Hit:Controller.Switch(23) = 1:PlaySoundAtBall "fx_sensor":End Sub
Sub sw23_UnHit:Controller.Switch(23) = 0:End Sub
Sub sw31_Hit:Controller.Switch(31) = 1:PlaySoundAtBall "fx_sensor":End Sub
Sub sw31_UnHit:Controller.Switch(31) = 0:End Sub
Sub sw32_Hit:Controller.Switch(32) = 1:PlaySoundAtBall "fx_sensor":End Sub
Sub sw32_UnHit:Controller.Switch(32) = 0:End Sub
Sub sw24_Hit:Controller.Switch(24) = 1:PlaySoundAtBall "fx_sensor":End Sub
Sub sw24_UnHit:Controller.Switch(24) = 0:End Sub
Sub sw26_Hit:Controller.Switch(26) = 1:PlaySoundAtBall "fx_sensor":End Sub
Sub sw26_UnHit:Controller.Switch(26) = 0:End Sub
Sub sw19_Hit:Controller.Switch(19) = 1:PlaySoundAtBall "fx_sensor":End Sub
Sub sw19_UnHit:Controller.Switch(19) = 0:End Sub
Sub sw18_Hit:Controller.Switch(18) = 1:PlaySoundAtBall "fx_sensor":End Sub
Sub sw18_UnHit:Controller.Switch(18) = 0:End Sub
Sub sw16_Hit:Controller.Switch(16) = 1:PlaySoundAtBall "fx_sensor":End Sub
Sub sw16_UnHit:Controller.Switch(16) = 0:End Sub
Sub sw17_Hit:Controller.Switch(17) = 1:PlaySoundAtBall "fx_sensor":End Sub
Sub sw17_UnHit:Controller.Switch(17) = 0:End Sub
Sub sw9_Hit:Controller.Switch(9) = 1:PlaySoundAtBall "fx_sensor":End Sub
Sub sw9_UnHit:Controller.Switch(9) = 0:End Sub
Sub sw18_Hit:Controller.Switch(18) = 1:PlaySoundAtBall "fx_sensor":End Sub
Sub sw18_UnHit:Controller.Switch(18) = 0:End Sub
Sub sw18_Hit:Controller.Switch(18) = 1:PlaySoundAtBall "fx_sensor":End Sub
Sub sw18_UnHit:Controller.Switch(18) = 0:End Sub
Sub sw12_Hit:Controller.Switch(12) = 1:PlaySoundAtBall "fx_sensor":End Sub
Sub sw12_UnHit:Controller.Switch(12) = 0:End Sub
Sub Launchball_Hit
If Activeball.VelY < 0 Then
PlaySoundAt "fx_launchball", Launchball
End If
End Sub
'----- Spinner -----
Sub sw25_Spin():vpmtimer.pulsesw 25:PlaySoundAt "fx_spinner", sw25:End Sub
'---- Gate ----
Sub sw16_Hit()
gate1.open=False
Controller.Switch(16)=True
End Sub
'----- Bumpers/Jets -----
Dim bumpl, bumpr, bumpc
Sub sw20_Hit
PlaySound "Bumper_1"
bumpl = 1
Me.TimerEnabled = 1
vpmTimer.PulseSwitch 20, 0, 0
Execute SolCallback(sJetLeft) & 1
End Sub
Sub sw21_Hit
PlaySound "Bumper_2"
bumpr = 1
Me.TimerEnabled = 1
vpmTimer.PulseSwitch 21, 0, 0
Execute SolCallback(sJetRight) & 1
End Sub
Sub sw22_Hit
PlaySound "Bumper_3"
bumpc = 1
Me.TimerEnabled = 1
vpmTimer.PulseSwitch 22, 0, 0
Execute SolCallback(sJetCenter) & 1
End Sub
'----Targets-----
Sub sw33_Hit:vpmTimer.PulseSw 33:PlaySoundAtBall SoundFX("fx_target", DOFTargets):End Sub
Sub sw27_Hit:vpmTimer.PulseSw 27:PlaySoundAtBall SoundFX("fx_target", DOFTargets):End Sub
Sub sw28_Hit:vpmTimer.PulseSw 28:PlaySoundAtBall SoundFX("fx_target", DOFTargets):End Sub
'---- Drop Targets ----
Sub sw41_Dropped:dtbank1.Hit 1:End Sub
Sub sw42_Dropped:dtbank1.Hit 2:End Sub
Sub sw43_Dropped:dtbank1.Hit 3:End Sub
Sub sw44_Dropped:dtbank2.Hit 1:End Sub
Sub sw45_Dropped:dtbank2.Hit 2:End Sub
Sub sw46_Dropped:dtbank2.Hit 3:End Sub
Sub sw47_Dropped:dtbank2.Hit 4:End Sub
Sub sw48_Dropped:dtbank2.Hit 5:End Sub
'----- Standup Targets -----
Sub sw37_Hit():vpmtimer.pulsesw 37:End Sub
Sub sw38_Hit():vpmtimer.pulsesw 38:End Sub
Sub sw39_Hit():vpmtimer.pulsesw 39:End Sub
Sub sw40_Hit():vpmtimer.pulsesw 40:End Sub
'---- Slings ----
Dim LStep, RStep
Sub LeftSlingShot_Slingshot
vpmTimer.PulseSwitch 29, 0, 0
PlaySound SoundFX("fx_slingshot", DOFContactors), 0, 1, -0.05, 0.05, 0, 0, 1, .8
DOF 101, DOFPulse
LeftSling4.Visible = 1
Lemk.RotX = 26
LStep = 0
vpmTimer.PulseSw 29
LeftSlingShot.TimerEnabled = 1
End Sub
Sub LeftSlingShot_Timer
Select Case LStep
Case 1:LeftSLing4.Visible = 0:LeftSLing3.Visible = 1:Lemk.RotX = 14
Case 2:LeftSLing3.Visible = 0:LeftSLing2.Visible = 1:Lemk.RotX = 2
Case 3:LeftSLing2.Visible = 0:Lemk.RotX = -10:LeftSlingShot.TimerEnabled = 0
End Select
LStep = LStep + 1
End Sub
Sub RightSlingShot_Slingshot
vpmTimer.PulseSwitch 30, 0, 0
PlaySound SoundFX("fx_slingshot", DOFContactors), 0, 1, 0.05, 0.05, 0, 0, 1, .8
DOF 102, DOFPulse
RightSling4.Visible = 1
Remk.RotX = 26
RStep = 0
vpmTimer.PulseSw 30
RightSlingShot.TimerEnabled = 1
End Sub
Sub RightSlingShot_Timer
Select Case RStep
Case 1:RightSLing4.Visible = 0:RightSLing3.Visible = 1:Remk.RotX = 14
Case 2:RightSLing3.Visible = 0:RightSLing2.Visible = 1:Remk.RotX = 2
Case 3:RightSLing2.Visible = 0:Remk.RotX = -10:RightSlingShot.TimerEnabled = 0
End Select
RStep = RStep + 1
End Sub
'******************************
' Diverse Collection Hit Sounds
'******************************
Sub aMetals_Hit(idx):PlaySound "fx3_EM_metalhit_medium", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
Sub aRubber_Bands_Hit(idx):PlaySound "fx_rubber_band", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
Sub aRubber_Posts_Hit(idx):PlaySound "fx2_plastichit", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
Sub aRubber_Pins_Hit(idx):PlaySound "fx_rubber_pin", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
Sub aPlastics_Hit(idx):PlaySound "fx_PlasticHit", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
Sub aGates_Hit(idx):PlaySound "fx3_EM_gate", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
Sub aWoods_Hit(idx):PlaySound "fx_Woodhit", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
' Williams Flippers
Sub GraphicsTimer_Timer()
batleft.objrotz = LeftFlipper.CurrentAngle + 1
batright.objrotz = RightFlipper.CurrentAngle - 1
End Sub
' *******************************************************************************************************
' Positional Sound Playback Functions by DJRobX
' PlaySound sound, 0, Vol(ActiveBall), Pan(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, Vol)
PlaySound sound, 1, Vol, Pan(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, Pan(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, Pan(tableobj), 0,0,1, 1, AudioFade(tableobj)
End Sub
'*********************************************************************
' Supporting Ball & Sound Functions
'*********************************************************************
Function AudioFade(tableobj) ' Fades between front and back of the table (for surround systems or 2x2 speakers, etc), depending on the Y position on the table. "table1" is the name of the table
Dim tmp
tmp = tableobj.y * 2 / table1.height-1
If tmp > 0 Then
AudioFade = Csng(tmp ^10)
Else
AudioFade = Csng(-((- tmp) ^10) )
End If
End Function
Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
Dim tmp
tmp = tableobj.x * 2 / table1.width-1
If tmp > 0 Then
AudioPan = Csng(tmp ^10)
Else
AudioPan = Csng(-((- tmp) ^10) )
End If
End Function
Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
Dim tmp
tmp = ball.x * 2 / table1.width-1
If tmp > 0 Then
Pan = Csng(tmp ^10)
Else
Pan = Csng(-((- tmp) ^10) )
End If
End Function
Function AudioFade(ball) ' Can this be together with the above function ?
Dim tmp
tmp = ball.y * 2 / Table1.height-1
If tmp > 0 Then
AudioFade = Csng(tmp ^10)
Else
AudioFade = 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 / 2000)
End Function
Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
Pitch = BallVel(ball) * 20
End Function
Function BallVel(ball) 'Calculates the ball speed
BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
End Function
'*****************************************
' JP's VP10 Rolling Sounds
'*****************************************
Const tnob = 20 ' total number of balls
Const lob = 0 'number of locked 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, ballpitch
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) = lob - 1 Then Exit Sub 'there no extra balls on this table
' 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) ), Pan(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, Pan(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)
If Table1.VersionMinor > 3 OR Table1.VersionMajor > 10 Then
PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 200, Pan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
Else
PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 200, Pan(ball1), 0, Pitch(ball1), 0, 0
End if
End Sub