-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathGargamel Park (Orginal 2016).vbs
3222 lines (2826 loc) · 96.5 KB
/
Gargamel Park (Orginal 2016).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
' **********************************************
' VISUAL PINBALL X7
' JPSalas Gargamel Park v4.0.2
' **********************************************
Option Explicit
Randomize
' Sound and music volumes
Const SongVolume = 0.05 ' 1 is full volume, but I set it quite low to listen better the other sounds since I use headphones, adjust to your setup :)
Const VoiceVolume = 1 ' Volume of the voices
'FlexDMD in high or normal quality
'change it to True if you have an LCD screen, 256x64
'or keep it False if you have a real DMD at 128x32 in size
Const FlexDMDHighQuality = True
'Use FlexDMD also in desktop mode
Const AlwaysUseFlexDMD = True
Const BallSize = 50
Const BallMass = 1
' Load the core.vbs for supporting Subs and functions
LoadCoreFiles
Sub LoadCoreFiles
On Error Resume Next
ExecuteGlobal GetTextFile("core.vbs")
If Err Then MsgBox "Can't open core.vbs"
ExecuteGlobal GetTextFile("controller.vbs")
If Err Then MsgBox "Can't open controller.vbs"
On Error Goto 0
End Sub
' Use FlexDMD if in FS mode
Dim UseFlexDMD
If Table1.ShowDT = True then
UseFlexDMD = False
Else
UseFlexDMD = True
End If
If AlwaysUseFlexDMD then UseFlexDMD = True
' Define any Constants
Const cGameName = "gargamel_park"
Const TableName = "Gargamel_Park" 'used for saving the highscores
Const myVersion = "4.00"
Const MaxPlayers = 4
Const BallSaverTime = 20 'in seconds
Const MaxMultiplier = 6 '6x is the max in this game
Const BallsPerGame = 5
' Define Global Variables
Dim PlayersPlayingGame
Dim CurrentPlayer
Dim Credits
Dim BonusPoints(4)
Dim BonusMultiplier(4)
Dim BallsRemaining(4)
Dim ExtraBallsAwards(4)
Dim Score(4)
Dim HighScore(4)
Dim HighScoreName(4)
Dim Jackpot
Dim Tilt
Dim TiltSensitivity
Dim Tilted
Dim TotalGamesPlayed
Dim mBalls2Eject
Dim SkillshotValue
Dim x
' Define Game Control Variables
Dim LastSwitchHit
Dim BallsOnPlayfield
Dim BallsInLock
Dim BallsInHole
' Define Game Flags
Dim bFreePlay
Dim bGameInPlay
Dim bOnTheFirstBall
Dim bBallInPlungerLane
Dim bBallSaverActive
Dim bBallSaverReady
Dim bMultiBallMode
Dim bMusicOn
Dim bAutoPlunger
Dim bSkillshotReady
'Define This Table objects and variables
Dim plungerIM, plungerIM2, cbLeft
Dim Bonus
Dim bExtraBallWonThisBall
Dim MusicChannelInUse
Dim CurrentMusicTunePlaying
Dim NCount
Dim R1Count
Dim R2Count
Dim K1Count
Dim K2Count
Dim cbCount
Dim K6Count
Dim P4Count
Dim P2Count
' *********************************************************************
' Visual Pinball Defined Script Events
' *********************************************************************
Sub Table1_Init()
LoadEM
DOF 110, DOFOn
Dim i
Randomize
'Impulse Plunger as autoplunger
Const IMPowerSetting = 30 ' Plunger Power
Const IMTime = 1.1 ' Time in seconds for Full Plunge
Set plungerIM = New cvpmImpulseP
With plungerIM
.InitImpulseP swplunger, IMPowerSetting, IMTime
.Random 1.5
.InitExitSnd "fx_kicker", "fx_solenoid"
.CreateEvents "plungerIM"
End With
' Misc. VP table objects Initialisation, droptargets, animations...
VPObjects_Init
'load saved values, highscore, names, jackpot
Credits = 1
Loadhs
'Init main variables
For i = 1 To MaxPlayers
Score(i) = 0
BonusPoints(i) = 0
BonusMultiplier(i) = 1
BallsRemaining(i) = BallsPerGame
ExtraBallsAwards(i) = 0
Next
' initalise the DMD display
DMD_Init
' freeplay or coins
bFreePlay = FALSE 'we want coins
' initialse any other flags
bOnTheFirstBall = FALSE
bBallInPlungerLane = FALSE
bBallSaverActive = FALSE
bBallSaverReady = FALSE
bMultiBallMode = FALSE
bGameInPlay = FALSE
bMusicOn = TRUE
bAutoPlunger = FALSE
BallsOnPlayfield = 0
BallsInLock = 0
BallsInHole = 0
LastSwitchHit = ""
Tilt = 0
TiltSensitivity = 6
Tilted = FALSE
If Credits > 0 Then DOF 131, DOFOn
EndOfGame()
Realtime.Enabled = 1
LoadLUT
End Sub
Sub Realtime_Timer
GIUpdate
RollingUpdate
End Sub
'******
' Keys
'******
Sub Table1_KeyDown(ByVal Keycode)
If hsbModeActive Then EnterHighScoreKey(keycode):Exit Sub
If keycode = LeftMagnaSave Then bLutActive = True:Lutbox.text = "level of darkness " & LUTImage + 1
If keycode = RightMagnaSave Then
If bLutActive Then NextLUT:End If
End If
If Keycode = AddCreditKey Then
Credits = Credits + 1
DOF 131, DOFOn
If(Tilted = FALSE)Then
DMDFlush
DMD "_", CL("CREDITS: " & Credits), "", eNone, eNone, eNone, 500, TRUE, "fx_coin"
If Credits > 5 Then
PlaySound "ga_iamrich"
Else
PlaySound "ga_diamond1"
End If
If NOT bGameInPlay Then ShowTableInfo
End If
End If
If keycode = PlungerKey Then
PlaySoundAt "fx_plungerpull", Plunger
Plunger.Pullback
End If
If bGameInPlay AND NOT Tilted Then
If keycode = LeftTiltKey Then Nudge 90, 5:PlaySound SoundFX("fx_nudge", 0), 0, 1, -0.1, 0.25:CheckTilt
If keycode = RightTiltKey Then Nudge 270, 5:PlaySound SoundFX("fx_nudge", 0), 0, 1, 0.1, 0.25:CheckTilt
If keycode = CenterTiltKey Then Nudge 0, 6:PlaySound SoundFX("fx_nudge", 0), 0, 1, 1, 0.25:CheckTilt
If keycode = LeftFlipperKey Then SolLFlipper 1
If keycode = RightFlipperKey Then SolRFlipper 1
If keycode = StartGameKey Then
If((PlayersPlayingGame < MaxPlayers)AND(bOnTheFirstBall = TRUE))Then
If(bFreePlay = TRUE)Then
PlayersPlayingGame = PlayersPlayingGame + 1
TotalGamesPlayed = TotalGamesPlayed + 1
Else
If(Credits > 0)then
PlayersPlayingGame = PlayersPlayingGame + 1
TotalGamesPlayed = TotalGamesPlayed + 1
Credits = Credits - 1
If Credits < 1 Then DOF 131, DOFOff
Else
' Not Enough Credits to start a game.
DMDFlush
DMD CL("CREDITS " & Credits), CL("INSERT COIN"), "", eNone, eBlink, eNone, 500, TRUE, "ga_diamonds"
End If
End If
End If
End If
Else ' If (GameInPlay)
If keycode = StartGameKey Then
If(bFreePlay = TRUE)Then
If(BallsOnPlayfield = 0)Then
ResetForNewGame()
End If
Else
If(Credits > 0)Then
If(BallsOnPlayfield = 0)Then
Credits = Credits - 1
If Credits < 1 Then DOF 131, DOFOff
ResetForNewGame()
End If
Else
' Not Enough Credits to start a game.
DMDFlush
DMD CL("CREDITS " & Credits), CL("INSERT COIN"), "", eNone, eBlink, eNone, 500, TRUE, "ga_diamonds"
ShowTableInfo
End If
End If
End If
End If ' If (GameInPlay)
' Table specific
' test keys
End Sub
Sub Table1_KeyUp(ByVal keycode)
If hsbModeActive Then Exit Sub
If keycode = LeftMagnaSave Then bLutActive = False:LutBox.text = ""
If bGameInPLay AND NOT Tilted Then
If keycode = LeftFlipperKey Then SolLFlipper 0
If keycode = RightFlipperKey Then SolRFlipper 0
End If
If keycode = PlungerKey Then
PlaySoundAt "fx_plunger", Plunger
Plunger.Fire
End If
End Sub
'***************************
' LUT - Darkness control
'***************************
Dim bLutActive, LUTImage
Sub LoadLUT
bLutActive = False
x = LoadValue(cGameName, "LUTImage")
If(x <> "")Then LUTImage = x Else LUTImage = 0
UpdateLUT
End Sub
Sub SaveLUT
SaveValue cGameName, "LUTImage", LUTImage
End Sub
Sub NextLUT:LUTImage = (LUTImage + 1)MOD 15:UpdateLUT:SaveLUT:Lutbox.text = "level of darkness " & LUTImage + 1:End Sub
Sub UpdateLUT
Select Case LutImage
Case 0:table1.ColorGradeImage = "LUT0":GiIntensity = 1:ChangeGIIntensity 1
Case 1:table1.ColorGradeImage = "LUT1":GiIntensity = 1.05:ChangeGIIntensity 1
Case 2:table1.ColorGradeImage = "LUT2":GiIntensity = 1.1:ChangeGIIntensity 1
Case 3:table1.ColorGradeImage = "LUT3":GiIntensity = 1.15:ChangeGIIntensity 1
Case 4:table1.ColorGradeImage = "LUT4":GiIntensity = 1.2:ChangeGIIntensity 1
Case 5:table1.ColorGradeImage = "LUT5":GiIntensity = 1.25:ChangeGIIntensity 1
Case 6:table1.ColorGradeImage = "LUT6":GiIntensity = 1.3:ChangeGIIntensity 1
Case 7:table1.ColorGradeImage = "LUT7":GiIntensity = 1.35:ChangeGIIntensity 1
Case 8:table1.ColorGradeImage = "LUT8":GiIntensity = 1.4:ChangeGIIntensity 1
Case 9:table1.ColorGradeImage = "LUT9":GiIntensity = 1.45:ChangeGIIntensity 1
Case 10:table1.ColorGradeImage = "LUT10":GiIntensity = 1.5:ChangeGIIntensity 1
Case 11:table1.ColorGradeImage = "LUT11":GiIntensity = 1.55:ChangeGIIntensity 1
Case 12:table1.ColorGradeImage = "LUT12":GiIntensity = 1.6:ChangeGIIntensity 1
Case 13:table1.ColorGradeImage = "LUT13":GiIntensity = 1.65:ChangeGIIntensity 1
Case 14:table1.ColorGradeImage = "LUT14":GiIntensity = 1.7:ChangeGIIntensity 1
End Select
End Sub
Dim GiIntensity
GiIntensity = 1 'used by the LUT changing to increase the GI lights when the table is darker
Sub ChangeGiIntensity(factor) 'changes the intensity scale
Dim bulb
For each bulb in aGiLights
bulb.IntensityScale = GiIntensity * factor
Next
End Sub
'*************
' Pause Table
'*************
Sub table1_Paused
End Sub
Sub table1_unPaused
End Sub
Sub table1_Exit
Savehs
If B2SOn Then Controller.Stop
End Sub
'********************
' Special JP Flippers
'********************
Sub SolLFlipper(Enabled)
If Enabled Then
PlaySound SoundFXDOF("fx_flipperup", 101, DOFOn, DOFContactors), 0, 1, -0.05, 0.15
LeftFlipper.EOSTorque = 0.65:LeftFlipper.RotateToEnd
LeftFlipper1.EOSTorque = 0.65:LeftFlipper1.RotateToEnd
LeftFlipper2.EOSTorque = 0.65:LeftFlipper2.RotateToEnd
LeftFlipper3.EOSTorque = 0.65:LeftFlipper3.RotateToEnd
LeftFlipper4.EOSTorque = 0.65:LeftFlipper4.RotateToEnd
RotateLaneLightsLeft
Else
PlaySound SoundFXDOF("fx_flipperdown", 101, DOFOff, DOFContactors), 0, 1, -0.05, 0.15
LeftFlipper.EOSTorque = 0.15:LeftFlipper.RotateToStart
LeftFlipper1.EOSTorque = 0.15:LeftFlipper1.RotateToStart
LeftFlipper2.EOSTorque = 0.15:LeftFlipper2.RotateToStart
LeftFlipper3.EOSTorque = 0.15:LeftFlipper3.RotateToStart
LeftFlipper4.EOSTorque = 0.15:LeftFlipper4.RotateToStart
End If
End Sub
Sub SolRFlipper(Enabled)
If Enabled Then
PlaySound SoundFXDOF("fx_flipperup", 102, DOFOn, DOFContactors), 0, 1, 0.05, 0.15
RightFlipper.EOSTorque = 0.65:RightFlipper.RotateToEnd
RightFlipper1.EOSTorque = 0.65:RightFlipper1.RotateToEnd
RightFlipper2.EOSTorque = 0.65:RightFlipper2.RotateToEnd
RightFlipper3.EOSTorque = 0.65:RightFlipper3.RotateToEnd
RotateLaneLightsRight
Else
PlaySound SoundFXDOF("fx_flipperdown", 102, DOFOff, DOFContactors), 0, 1, 0.05, 0.15
RightFlipper.EOSTorque = 0.15:RightFlipper.RotateToStart
RightFlipper1.EOSTorque = 0.15:RightFlipper1.RotateToStart
RightFlipper2.EOSTorque = 0.15:RightFlipper2.RotateToStart
RightFlipper3.EOSTorque = 0.15:RightFlipper3.RotateToStart
End If
End Sub
' flippers hit Sound
Sub LeftFlipper_Collide(parm)
PlaySound "fx_rubber_flipper", 0, Vol(ActiveBall), pan(ActiveBall), 0.2, 0, 0, 0, AudioFade(ActiveBall)
End Sub
Sub LeftFlipper1_Collide(parm)
PlaySound "fx_rubber_flipper", 0, Vol(ActiveBall), pan(ActiveBall), 0.2, 0, 0, 0, AudioFade(ActiveBall)
End Sub
Sub LeftFlipper2_Collide(parm)
PlaySound "fx_rubber_flipper", 0, Vol(ActiveBall), pan(ActiveBall), 0.2, 0, 0, 0, AudioFade(ActiveBall)
End Sub
Sub LeftFlipper3_Collide(parm)
PlaySound "fx_rubber_flipper", 0, Vol(ActiveBall), pan(ActiveBall), 0.2, 0, 0, 0, AudioFade(ActiveBall)
End Sub
Sub LeftFlipper4_Collide(parm)
PlaySound "fx_rubber_flipper", 0, Vol(ActiveBall), pan(ActiveBall), 0.2, 0, 0, 0, AudioFade(ActiveBall)
End Sub
Sub RightFlipper_Collide(parm)
PlaySound "fx_rubber_flipper", 0, Vol(ActiveBall), pan(ActiveBall), 0.2, 0, 0, 0, AudioFade(ActiveBall)
End Sub
Sub RightFlipper1_Collide(parm)
PlaySound "fx_rubber_flipper", 0, Vol(ActiveBall), pan(ActiveBall), 0.2, 0, 0, 0, AudioFade(ActiveBall)
End Sub
Sub RightFlipper2_Collide(parm)
PlaySound "fx_rubber_flipper", 0, Vol(ActiveBall), pan(ActiveBall), 0.2, 0, 0, 0, AudioFade(ActiveBall)
End Sub
Sub RightFlipper3_Collide(parm)
PlaySound "fx_rubber_flipper", 0, Vol(ActiveBall), pan(ActiveBall), 0.2, 0, 0, 0, AudioFade(ActiveBall)
End Sub
Sub RotateLaneLightsLeft
Dim TempState
TempState = LightSS.State
LightSS.State = LightM.State
LightSpin.State = LightM.State
LightM.State = LightU.State
LightU.State = LightR.State
LightR.State = LightF.State
LightF.State = TempState
End Sub
Sub RotateLaneLightsRight
Dim TempState
TempState = LightF.State
LightF.State = LightR.State
LightR.State = LightU.State
LightU.State = LightM.State
LightM.State = LightSS.State
LightSS.State = TempState
LightSpin.State = TempState
End Sub
'*********
' TILT
'*********
'NOTE: The Game Timer Subtracts .01 from the "Tilt" variable every round
Sub CheckTilt 'Called when table is nudged
Tilt = Tilt + TiltSensitivity 'Add to tilt count
TiltDecreaseTimer.Enabled = TRUE
If(Tilt > TiltSensitivity)AND(Tilt < 15)Then 'show a warning
DMD "_", CL("CAREFUL"), "", eNone, eBlinkFast, eNone, 500, TRUE, ""
End if
If Tilt > 15 Then 'If more that 15 then TILT the table
Tilted = TRUE
'display Tilt
DMDFlush
DMD CL("TILT"), "", "", eBlinkFast, eNone, eNone, 200, FALSE, ""
DMD "", CL("TILT"), "", eBlinkFast, eNone, eNone, 200, FALSE, ""
DisableTable TRUE
TiltRecoveryTimer.Enabled = TRUE 'start the Tilt delay to check for all the balls to be drained
End If
End Sub
Sub TiltDecreaseTimer_Timer
' DecreaseTilt
If Tilt > 0 Then
Tilt = Tilt - 0.1
Else
Me.Enabled = FALSE
End If
End Sub
Sub DisableTable(Enabled)
If Enabled Then
'turn off GI and turn off all the lights
GiOff
'Disable slings, bumpers etc
LeftFlipper.RotateToStart
RightFlipper.RotateToStart
LeftFlipper1.RotateToStart
RightFlipper1.RotateToStart
Bumper1.Threshold = 100
Bumper2.Threshold = 100
Bumper3.Threshold = 100
Bumper4.Threshold = 100
LeftSlingshot.Disabled = 1
RightSlingshot.Disabled = 1
Else
'turn back on GI and the lights
GiOn
Bumper1.Threshold = 1
Bumper2.Threshold = 1
Bumper3.Threshold = 1
Bumper4.Threshold = 1
LeftSlingshot.Disabled = 0
RightSlingshot.Disabled = 0
'clean up the buffer display
DMDFlush
End If
End Sub
Sub TiltRecoveryTimer_Timer()
' if all the balls have been drained then..
If(BallsOnPlayfield = 0)Then
' do the normal end of ball thing (this doesn't give a bonus if the table is tilted)
EndOfBall()
Me.Enabled = FALSE
End If
' else retry (checks again in another second or so)
End Sub
'***************
' Random Music
'***************
Dim currentsong, song(21), SongLength(21)
currentsong = 0
For x = 1 to 21
song(x) = "M_Song" &x
Next
SongLength(1) = 189000 '3:09
SongLength(2) = 230000 '3:50
SongLength(3) = 102000 '1:42
SongLength(4) = 222000 '3:42
SongLength(5) = 187000 '3:07
SongLength(6) = 234000 '3:54
SongLength(7) = 233000 '3:53
SongLength(8) = 230000 '3:50
SongLength(9) = 209000 '3:29
SongLength(10) = 166000 '2:46
SongLength(11) = 225000 '3:45
SongLength(12) = 191000 '3:12
SongLength(13) = 189000 '3:09
SongLength(14) = 209000 '3:29
SongLength(15) = 240000 '4:00
SongLength(16) = 218000 '3:38
SongLength(17) = 203000 '3:23
SongLength(18) = 188000 '3:08
SongLength(19) = 188000 '3:08
SongLength(20) = 210000 '3:30
SongLength(21) = 202000 '3:22
Sub PlaySong 'random
Dim tmp
If bMusicOn Then
StopSound song(currentsong)
tmp = RndNbr(21)
PlaySound Song(tmp), 0, SongVolume
ReplaySong.Interval = SongLength(tmp)
ReplaySong.Enabled = 0
ReplaySong.Enabled = 1
currentsong = tmp
End If
End Sub
Sub ReplaySong_Timer:PLaySong:End Sub
'**********************
' GI effects
' independent routine
' it turns on the gi
' when there is a ball
' in play
'**********************
Dim OldGiState
OldGiState = -1 'start witht the Gi off
Sub ChangeGi(Gi) 'changes the gi color
Dim gilight
Select Case Gi
Case "Normal"
For each giLight in aGILights
giLight.color = RGB(255, 197, 143)
giLight.colorfull = RGB(255, 252, 224)
Next
Case "Green"
For each giLight in aGILights
giLight.color = RGB(0, 18, 0)
giLight.colorfull = RGB(0, 180, 0)
Next
Case "Red"
For each giLight in aGILights
giLight.color = RGB(18, 0, 0)
giLight.colorfull = RGB(180, 0, 0)
Next
End Select
End Sub
Sub GIUpdate
Dim tmp, obj
tmp = Getballs
If UBound(tmp) <> OldGiState Then
OldGiState = Ubound(tmp)
If UBound(tmp) = -1 Then
GiOff
Else
Gion
End If
End If
End Sub
Sub GiOn
Dim bulb
PlaySound "fx_gion"
For each bulb in aGiLights
bulb.State = 1
Next
For each bulb in aFarolas
bulb.State = 2
Next
End Sub
Sub GiOff
Dim bulb
PlaySound "fx_gioff"
For each bulb in aGiLights
bulb.State = 0
Next
For each bulb in aFarolas
bulb.State = 0
Next
End Sub
'***************************************************************
' Supporting Ball & Sound Functions v4.0
'***************************************************************
Dim TableWidth, TableHeight
TableWidth = Table1.width
TableHeight = Table1.height
Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
Vol = Csng(BallVel(ball) ^2 / 2000)
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 / TableWidth-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 = (SQR((ball.VelX ^2) + (ball.VelY ^2)))
End Function
Function AudioFade(ball) 'only on VPX 10.4 and newer
Dim tmp
tmp = ball.y * 2 / TableHeight-1
If tmp > 0 Then
AudioFade = Csng(tmp ^10)
Else
AudioFade = Csng(-((- tmp) ^10))
End If
End Function
Sub PlaySoundAt(soundname, tableobj) 'play sound at X and Y position of an object, mostly bumpers, flippers and other fast objects
PlaySound soundname, 0, 1, Pan(tableobj), 0.2, 0, 0, 0, AudioFade(tableobj)
End Sub
Sub PlaySoundAtBall(soundname) ' play a sound at the ball position, like rubbers, targets, metals, plastics
PlaySound soundname, 0, Vol(ActiveBall), pan(ActiveBall), 0.2, Pitch(ActiveBall) * 10, 0, 0, AudioFade(ActiveBall)
End Sub
Function RndNbr(n) 'returns a random number between 1 and n
Randomize timer
RndNbr = Int((n * Rnd) + 1)
End Function
'***********************************************
' JP's VP10 Rolling Sounds + Ballshadow v4.0
' uses a collection of shadows, aBallShadow
'***********************************************
Const tnob = 19 'total number of balls
Const lob = 0 'number of locked balls
Const maxvel = 46 'max ball velocity
ReDim rolling(tnob)
InitRolling
Sub InitRolling
Dim i
For i = 0 to tnob
rolling(i) = False
Next
End Sub
Sub RollingUpdate()
Dim BOT, b, ballpitch, ballvol, speedfactorx, speedfactory
BOT = GetBalls
' stop the sound of deleted balls
For b = UBound(BOT) + 1 to tnob
rolling(b) = False
StopSound("fx_ballrolling" & b)
aBallShadow(b).Y = 3000
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 and draw the shadow
For b = lob to UBound(BOT)
aBallShadow(b).X = BOT(b).X
aBallShadow(b).Y = BOT(b).Y
aBallShadow(b).Height = BOT(b).Z - Ballsize / 2
If BallVel(BOT(b)) > 1 Then
If BOT(b).z < 30 Then
ballpitch = Pitch(BOT(b))
ballvol = Vol(BOT(b))
Else
ballpitch = Pitch(BOT(b)) + 50000 'increase the pitch on a ramp
ballvol = Vol(BOT(b)) * 10
End If
rolling(b) = True
PlaySound("fx_ballrolling" & b), -1, ballvol, Pan(BOT(b)), 0, ballpitch, 1, 0, AudioFade(BOT(b))
Else
If rolling(b) = True Then
StopSound("fx_ballrolling" & b)
rolling(b) = False
End If
End If
' rothbauerw's Dropping Sounds
If BOT(b).VelZ < -1 and BOT(b).z < 55 and BOT(b).z > 27 Then 'height adjust for ball drop sounds
PlaySound "fx_balldrop", 0, ABS(BOT(b).velz) / 17, Pan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
End If
' jps ball speed control
If BOT(b).VelX AND BOT(b).VelY <> 0 Then
speedfactorx = ABS(maxvel / BOT(b).VelX)
speedfactory = ABS(maxvel / BOT(b).VelY)
If speedfactorx < 1 Then
BOT(b).VelX = BOT(b).VelX * speedfactorx
BOT(b).VelY = BOT(b).VelY * speedfactorx
End If
If speedfactory < 1 Then
BOT(b).VelX = BOT(b).VelX * speedfactory
BOT(b).VelY = BOT(b).VelY * speedfactory
End If
End If
Next
End Sub
'*****************************
' Ball 2 Ball Collision Sound
'*****************************
Sub OnBallBallCollision(ball1, ball2, velocity)
PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, Pan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
End Sub
'******************************
' Diverse Collection Hit Sounds
'******************************
Sub aMetals_Hit(idx):PlaySoundAtBall "fx_MetalHit":End Sub
Sub aMetalWires_Hit(idx):PlaySoundAtBall "fx_MetalWire":End Sub
Sub aRubber_Bands_Hit(idx):PlaySoundAtBall "fx_rubber_band":End Sub
Sub aRubber_LongBands_Hit(idx):PlaySoundAtBall "fx_rubber_longband":End Sub
Sub aRubber_Posts_Hit(idx):PlaySoundAtBall "fx_rubber_post":End Sub
Sub aRubber_Pins_Hit(idx):PlaySoundAtBall "fx_rubber_pin":End Sub
Sub aRubber_Pegs_Hit(idx):PlaySoundAtBall "fx_rubber_peg":End Sub
Sub aPlastics_Hit(idx):PlaySoundAtBall "fx_PlasticHit":End Sub
Sub aWoods_Hit(idx):PlaySoundAtBall "fx_Woodhit":End Sub
Sub aGates_Hit(idx)
PlaySoundAtBall "fx_Gate"
If(idx = 1)AND(bMultiBallMode = FALSE)Then bAutoPlunger = FALSE
End Sub
' Ramp Soundss
Sub aRHelps_Hit(idx)
ActiveBall.VelY = 0
ActiveBall.VelX = 0
PlaySoundAt"fx_balldrop", aRHelps(idx)
End Sub
' *********************************************************************
' User Defined Script Events
' *********************************************************************
' Initialise the Table for a new Game
'
Sub ResetForNewGame()
Dim i
bGameInPLay = TRUE
'resets the score display, and turn off attrack mode
StopAttractMode
GiOn
TotalGamesPlayed = TotalGamesPlayed + 1
CurrentPlayer = 1
PlayersPlayingGame = 1
bOnTheFirstBall = TRUE
For i = 1 To MaxPlayers
Score(i) = 0
BonusPoints(i) = 0
BonusMultiplier(i) = 1
BallsRemaining(i) = BallsPerGame
ExtraBallsAwards(i) = 0
Next
' initialise any other flags
bMultiBallMode = FALSE
Tilt = 0
' initialise Game variables
Game_Init()
' you may wish to start some music, play a sound, do whatever at this point
' set up the start delay to handle any Start of Game Attract Sequence
FirstBallDelayTimer.Enabled = TRUE
End Sub
' This is used to delay the start of a game to allow any attract sequence to
' complete. When it expires it creates a ball for the player to start playing with
Sub FirstBallDelayTimer_Timer
' stop the timer
Me.Enabled = FALSE
' reset the table for a new ball
ResetForNewPlayerBall()
' create a new ball in the shooters lane
CreateNewBall()
End Sub
' (Re-)Initialise the Table for a new ball (either a new ball after the player has
' lost one or we have moved onto the next player (if multiple are playing))
Sub ResetForNewPlayerBall()
' make sure the correct display is upto date
AddScore 0
' set the current players bonus multiplier back down to 1X
SetBonusMultiplier 1
' reset any drop targets, lights, game modes etc..
'LightShootAgain.State = 0
Bonus = 0
bExtraBallWonThisBall = FALSE
ResetNewBallLights()
'This is a new ball, so activate the ballsaver
bBallSaverReady = TRUE
'and the skillshot
bSkillShotReady = TRUE
'Change the music ?
End Sub
' Create a new ball on the Playfield
Sub CreateNewBall()
' create a ball in the plunger lane kicker.
BallRelease.Createball
' There is a (or another) ball on the playfield
BallsOnPlayfield = BallsOnPlayfield + 1
' kick it out..
PlaySoundAt SoundFXDOF("fx_Ballrel", 109, DOFPulse, DOFContactors), BallRelease
BallRelease.Kick 90, 4
' if there is 2 or more balls then set the multibal flag
If BallsOnPlayfield > 1 Then
bMultiBallMode = TRUE
DOF 108, DOFOn
DOF 110, DOFOff
End If
End Sub
' Add extra balls to the table with autoplunger
' Use it as AddMultiball 4 to add 4 extra balls to the table
Sub AddMultiball(nballs)
mBalls2Eject = mBalls2Eject + nballs
CreateMultiballTimer.Enabled = TRUE
End Sub
' Eject the ball after the delay, AddMultiballDelay
Sub CreateMultiballTimer_Timer()
bAutoPlunger = TRUE
' wait if there is a ball in the plunger lane
If bBallInPlungerLane Then
Exit Sub
Else
CreateNewBall()
mBalls2Eject = mBalls2Eject -1
If mBalls2Eject = 0 Then 'if there are no more balls to eject then stop the timer
Me.Enabled = FALSE
End If
End If
End Sub
' The Player has lost his ball (there are no more balls on the playfield).
' Handle any bonus points awarded
'
Sub EndOfBall()
Dim BonusDelayTime
' the first ball has been lost. From this point on no new players can join in
bOnTheFirstBall = FALSE
' only process any of this if the table is not tilted. (the tilt recovery
' mechanism will handle any extra balls or end of game)
If(Tilted = FALSE)Then
Dim AwardPoints
' add in any bonus points (multipled by the bunus multiplier)
AwardPoints = BonusPoints(CurrentPlayer) * BonusMultiplier(CurrentPlayer)
AddScore AwardPoints
debug.print "Bonus Points = " & AwardPoints
DMD "_", CL("BONUS: " & BonusPoints(CurrentPlayer) & " X" & BonusMultiplier(CurrentPlayer)), "", eNone, eBlink, eNone, 1000, TRUE, ""
' add a bit of a delay to allow for the bonus points to be added up
BonusDelayTime = 1000
Else
'no bonus to count so move quickly to the next stage
BonusDelayTime = 20
End If
' start the end of ball timer which allows you to add a delay at this point
EndOfBall2Timer.Interval = BonusDelayTime
EndOfBall2Timer.Enabled = TRUE
End Sub
' The Timer which delays the machine to allow any bonus points to be added up
' has expired. Check to see if there are any extra balls for this player.
' if not, then check to see if this was the last ball (of the currentplayer)
'
Sub EndOfBall2Timer_Timer()
' disable the timer
Me.Enabled = FALSE
' if were tilted, reset the internal tilted flag (this will also
' set TiltWarnings back to zero) which is useful if we are changing player LOL
Tilted = FALSE
Tilt = 0
DisableTable FALSE 'enable again bumpers and slingshots
' has the player won an extra-ball ? (might be multiple outstanding)
If(ExtraBallsAwards(CurrentPlayer) <> 0)Then
debug.print "Extra Ball"
DMD "_", CL(("EXTRA BALL")), "d_border", eNone, eBlink, eNone, 1000, TRUE, ""
' yep got to give it to them
ExtraBallsAwards(CurrentPlayer) = ExtraBallsAwards(CurrentPlayer)- 1
' if no more EB's then turn off any shoot again light
If(ExtraBallsAwards(CurrentPlayer) = 0)Then
LightShootAgain.State = 0
End If
' You may wish to do a bit of a song AND dance at this point
' Create a new ball in the shooters lane
CreateNewBall()
Else ' no extra balls
BallsRemaining(CurrentPlayer) = BallsRemaining(CurrentPlayer)- 1
' was that the last ball ?
If(BallsRemaining(CurrentPlayer) <= 0)Then
debug.print "No More Balls, High Score Entry"
' Submit the currentplayers score to the High Score system
CheckHighScore()
' you may wish to play some music at this point
Else
' not the last ball (for that player)
' if multiple players are playing then move onto the next one
EndOfBallComplete()