forked from LegendsUnchained/vpx-standalone-alp4k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKlondike.vbs
2605 lines (2239 loc) · 78.5 KB
/
Klondike.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 X EM Script by JPSalas
' Basic EM script up to 4 players
' uses core.vbs for extra functions
'
' Leon Spalding old version
' DOF config - leeoneil
' https://www.ipdb.org/machine.cgi?id=1388
' Klondike Williams 1971 VPX table by Kiwi, version 1.0.2
' ***********************************************************************
Option Explicit
Randomize
'******************************************** Options ***************************************
'****************************************** Volume Settings ********************************************
Const RolVol = 1 'Ball Rolling
Const RubVol = 1 'Rubbers Collision
Const DroVol = 1 'Ball jump
Const NudVol = 1 'Nudge
Const PlpVol = 1 'Plunger pull
Const PlfVol = 1 'Plunger fire
Const SliVol = 1 'Slingshots
Const BumVol = 1 'Bumpers
Const SwiVol = 1 'Rollovers
Const TarVol = 1 'Targets
Const PouVol = 1 'Post up
Const PodVol = 1 'Post down
Const GatVol = 1 'Gate
Const KicVol = 1 'Kickers catch
Const KieVol = 1 'Kickers eject
Const KidVol = 1 'Kicker Drain
Const BarVol = 1 'Ball release
Const FluVol = 1 'Flippers up
Const FldVol = 1 'Flippers down
Const FlbVol = 0.2 'Flippers buzz
Const CoiVol = 1 'Coin
Const KnoVol = 1 'Knocker
Const TilVol = 1 'Tilt
Const RepVol = 1 'Reels points/credits
Const ResVol = 1 'Reels symbols
Const BdeVol = 0.15 'Bell 10
Const BceVol = 0.3 'Bell 100
Const BmiVol = 0.3 'Bell 1000
Const IniVol = 1 'Initialize/reset, start of game
Const MatVol = 1 'Match, end of game
Const BcuVol = 0.4 'Ball count unit
Const GirVol = 1 'General Illumination Relay
'************************ Balls per game: real pinball have 3 or 5 balls, you can put max 9
Const BallsPerGame = 5
'************************ Ball: 50 unit is standard ball size ** Mass=(50^3)/125000 ,(BallSize^3)/125000 ** Max ball velocity
Const BallSize = 50
Const BallMass = 1
Const MaxVel = 50
'************************ Ball Shadow: 0 hidden , 1 visible
Const BallSHW = 1
'************************ Show score on the instruction card: 0 off, 1 on
Const ScoreOnCard = 0
'************************ Chime 100 & 1000 points same sound (like an real): 0, separated souds: 1
Const Chimesep = 0
'************************ Rails Hidden/Visible in FS mode: 0 hidden , 1 visible
Const RailsVisible = 0
'************************ Color Grading LUT: 1 = Active, any other value = disabled
Const LutEnabled = 1
'******************************************** OPTIONS END ***********************************
' Load extra vbs files
LoadCoreFiles
Sub LoadCoreFiles
On Error Resume Next
ExecuteGlobal GetTextFile("core.vbs")
If Err Then MsgBox "Can't open core.vbs"
On Error Resume Next
ExecuteGlobal GetTextFile("controller.vbs")
If Err Then MsgBox "Can't open controller.vbs"
End Sub
' Constants
Const TableName = "Klondike1971" ' file name to save highscores and other variables
Const cGameName = "Klondike1971" ' B2S name
Const MaxPlayers = 1 ' 1 to 4 can play
Const MaxMultiplier = 1 ' limit bonus multiplier
Const FreePlay = False ' Free play or coins
Const SpecialMode = 4 ' 1 = add-a-ball, 2 = replay, 3 = Novelty, 4 Legacy mode
'Const NoveltyScore = 100000 ' novelty score is set to 100.000 points
Const Electrician_Mode = 1 ' if 1 shows the 100.000 light when the score is over 100K
Dim Special1, Special2, Special3
If BallsPerGame > 4 Then
Special1 = 90000 ' extra ball or credit when reaching this score
Special2 = 150000
Special3 = 180000
ElseIf BallsPerGame < 5 Then
Special1 = 60000
Special2 = 120000
Special3 = 190000
End If
' Global variables
Dim PlayersPlayingGame
Dim CurrentPlayer
Dim Credits
Dim Bonus
Dim BallsRemaining(4)
Dim BonusMultiplier
Dim ExtraBallsAwards(4)
Dim Special1Awarded(4)
Dim Special2Awarded(4)
Dim Special3Awarded(4)
Dim Special4Awarded(4)
Dim Score(4)
Dim HighScore
Dim Match
Dim Tilt
Dim TiltSensitivity
Dim Tilted
Dim Add10
Dim Add100
Dim Add1000
Dim Add10000
Dim x
Dim rv(3)
Dim Dec(4)
Dim Cen(4)
Dim Mil(4)
Dim DMi(4)
Dim Ngr
Dim Bpg
Dim NewGReset
Dim BallsPG
' Control variables
Dim BallsOnPlayfield
' Boolean variables
Dim bAttractMode
Dim bFreePlay
Dim bGameInPlay
Dim bOnTheFirstBall
Dim bExtraBallWonThisBall
Dim bJustStarted
Dim bBallInPlungerLane
Dim bBallSaverActive'********************************** Klondike init
Sub Table1_Init
' Init some objects, like walls, targets
VPObjects_Init
LoadEM
Set Dec(1)=Dec1
Set Cen(1)=Cen1
Set Mil(1)=Mil1
Set DMi(1)=DMi1
Set Dec(2)=Dec2
Set Cen(2)=Cen2
Set Mil(2)=Mil2
Set DMi(2)=DMi2
Set Dec(3)=Dec3
Set Cen(3)=Cen3
Set Mil(3)=Mil3
Set DMi(3)=DMi3
Set Dec(4)=Dec4
Set Cen(4)=Cen4
Set Mil(4)=Mil4
Set DMi(4)=DMi4
' load score/highscore
Score(1) = 0
rv(1) = 0
rv(2) = 0
rv(3) = 0
Credits = 1
Loadhs
CurrentPlayer = 1
ScoreReel1.SetValue Score(1)
UpdateBReels
UpdateCredits
Display_Match
If B2SOn Then
Controller.B2SSetScorePlayer 1, Score(1)
Controller.B2SSetGameOver 1
End If
' init all the global variables
bFreePlay = FreePlay
bAttractMode = False
bOnTheFirstBall = False
bGameInPlay = False
bBallInPlungerLane = False
BallsOnPlayfield = 0
Tilt = 0
TiltSensitivity = 6
Tilted = False
Match = 0
bJustStarted = True
Add10 = 0
Add100 = 0
Add1000 = 0
Add10000 = 0
Ngr = 0
' setup table in game over mode
EndOfGame
'turn on GI lights
vpmtimer.addtimer 1000, "GiOn '"
CheckReels
ReelLeft.RotX = -rv(1)*36
ReelCenter.RotX = -rv(2)*36
ReelRight.RotX = -rv(3)*36
If Table1.ShowDT = True Then
End If
If Table1.ShowDT = False Then
CreditsReel.Visible = 0
ScoreReel1.Visible = 0
BallstoPlayR.Visible = 0
GameOverReel.Visible = 0
MatchR.Visible = 0
CentoMR.Visible = 0
TiltReel.Visible = 0
CabRailSX.Visible = RailsVisible
CabRailDX.Visible = RailsVisible
End If
If Table1.ShowFSS = True Then
CreditsReel.Visible = 0
ScoreReel1.Visible = 0
BallstoPlayR.Visible = 0
GameOverReel.Visible = 0
MatchR.Visible = 0
CentoMR.Visible = 0
TiltReel.Visible = 0
End If
fgi1.IntensityScale = 0
fgi2.IntensityScale = 0
fgi3.IntensityScale = 0
fbgi001.IntensityScale = 0
fbgi002.IntensityScale = 0
fbgi003.IntensityScale = 0
fbgi004.IntensityScale = 0
fbgi005.IntensityScale = 0
fbgi006.IntensityScale = 0
fbgi007.IntensityScale = 0
fbgi008.IntensityScale = 0
fbgi009.IntensityScale = 0
fbgi010.IntensityScale = 0
fbgi011.IntensityScale = 0
fbgi012.IntensityScale = 0
fbgi013.IntensityScale = 0
fbgi014.IntensityScale = 0
fbgi015.IntensityScale = 0
fbgi016.IntensityScale = 0
fbgi017.IntensityScale = 0
fbgi018.IntensityScale = 0
fbgi019.IntensityScale = 0
fb1.Visible = 0
fb2.Visible = 0
fb3.Visible = 0
fb4.Visible = 0
fb5.Visible = 0
fb6.Visible = 0
fb7.Visible = 0
fb8.Visible = 0
fb9.Visible = 0
fTilt.Visible = 0
fCentoM.Visible = 0
' Backbox Flashers Y Position
Const Fpy = 68.2
fbgi001.y = Fpy:fbgi002.y = Fpy:fbgi003.y = Fpy:fbgi004.y = Fpy:fbgi005.y = Fpy:fbgi006.y = Fpy:fbgi007.y = Fpy:fbgi008.y = Fpy
fbgi009.y = Fpy:fbgi010.y = Fpy:fbgi011.y = Fpy:fbgi012.y = Fpy:fbgi013.y = Fpy:fbgi014.y = Fpy
fbgi015.y = 67:fbgi016.y = 67:fbgi017.y = 67:fbgi018.y = 67:fbgi019.y = 67
fb1.y = Fpy:fb2.y = Fpy:fb3.y = Fpy:fb4.y = Fpy:fb5.y = Fpy:fb6.y = Fpy:fb7.y = Fpy:fb8.y = Fpy:fb9.y = Fpy
fGameOver.y = Fpy:fTilt.y = Fpy:fCentoM.y = Fpy
fM00.y = Fpy:fM10.y = Fpy:fM20.y = Fpy:fM30.y = Fpy:fM40.y = Fpy:fM50.y = Fpy:fM60.y = Fpy:fM70.y = Fpy:fM80.y = Fpy:fM90.y = Fpy
End Sub'********************************** Key DownSub Table1_KeyDown(ByVal Keycode)
If EnteringInitials Then
CollectInitials(keycode)
Exit Sub
End If
If Keycode = LeftMagnaSave And LutEnabled = 1 Then bLutActive = True: Lutbox.Text = "level of darkness " & LUTImage + 1
If Keycode = RightMagnaSave Then
If bLutActive Then NextLUT: End If
End If
' add coins, limit to 9 credits
If Keycode = AddCreditKey Then
If(Tilted = False)Then
PlaySoundAtVol "coin3", Bumper3, CoiVol
If Credits < 9 Then
AddCredits 1
End If
End If
End If
' plunger If Keycode = PlungerKey Then:Plunger.Pullback:PlaySoundAtVol "fx_plungerpull", Plunger, PlpVol:End If
' tilt keys If Keycode = LeftTiltKey Then:Nudge 90, 4:PlaySound SoundFX("fx_nudge",0), 0, NudVol, -0.1, 0.25:CheckTilt:End If
If Keycode = RightTiltKey Then:Nudge 270, 4:PlaySound SoundFX("fx_nudge",0), 0, NudVol, 0.1, 0.25:CheckTilt:End If
If Keycode = CenterTiltKey Then:Nudge 0, 5:PlaySound SoundFX("fx_nudge",0), 0, NudVol, 0, 0.25:CheckTilt:End If
' keys during game
If bGameInPlay AND NOT Tilted Then
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
'PlayersReel.SetValue, PlayersPlayingGame
'PlaySound "so_fanfare1"
Else
If(Credits > 0)Then
PlayersPlayingGame = PlayersPlayingGame + 1
AddCredits - 1
Else
' Not Enough Credits to start a game.
'PlaySound "so_nocredits"
End If
End If
End If
End If
Else
If Keycode = StartGameKey Then
If(bFreePlay = True)Then
If(BallsOnPlayfield = 0)Then
ResetScores
ResetForNewGame()
End If
Else
If(Credits > 0)Then
If(BallsOnPlayfield = 0)Then
AddCredits - 1
ResetScores
ResetForNewGame()
End If
Else
' Not Enough Credits to start a game.
'PlaySound "so_nocredits"
End If
End If
End If
End If ' If (GameInPlay)
End Sub
'********************************** Key Up
Sub Table1_KeyUp(ByVal Keycode) If EnteringInitials Then
Exit Sub
End If
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:Plunger.Fire:PlaySoundAtVol "plunger", Plunger, PlfVol * (Plunger.Position/25):End If
If bBallInPlungerLane Then
PlaySoundAt "fx_plunger", Plunger
Else
PlaySoundAt "fx_plunger_empty", Plunger
End If
End Sub
'******************
' Table stop/pause
'******************
Sub Table1_Paused
End Sub
Sub Table1_unPaused
End Sub
Sub Table1_Exit
Savehs
'Controller.Stop
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:FlIntensity = 1:ChangeGIIntensity 1:UpdateFlashers
Case 1:table1.ColorGradeImage = "LUT1":GiIntensity = 1.05:FlIntensity = 1.2:ChangeGIIntensity 1:UpdateFlashers
Case 2:table1.ColorGradeImage = "LUT2":GiIntensity = 1.1:FlIntensity = 1.4:ChangeGIIntensity 1:UpdateFlashers
Case 3:table1.ColorGradeImage = "LUT3":GiIntensity = 1.15:FlIntensity = 1.6:ChangeGIIntensity 1:UpdateFlashers
Case 4:table1.ColorGradeImage = "LUT4":GiIntensity = 1.2:FlIntensity = 1.8:ChangeGIIntensity 1:UpdateFlashers
Case 5:table1.ColorGradeImage = "LUT5":GiIntensity = 1.25:FlIntensity = 2:ChangeGIIntensity 1:UpdateFlashers
Case 6:table1.ColorGradeImage = "LUT6":GiIntensity = 1.3:FlIntensity = 2.2:ChangeGIIntensity 1:UpdateFlashers
Case 7:table1.ColorGradeImage = "LUT7":GiIntensity = 1.35:FlIntensity = 2.4:ChangeGIIntensity 1:UpdateFlashers
Case 8:table1.ColorGradeImage = "LUT8":GiIntensity = 1.4:FlIntensity = 2.6:ChangeGIIntensity 1:UpdateFlashers
Case 9:table1.ColorGradeImage = "LUT9":GiIntensity = 1.45:FlIntensity = 2.8:ChangeGIIntensity 1:UpdateFlashers
Case 10:table1.ColorGradeImage = "LUT10":GiIntensity = 1.5:FlIntensity = 3:ChangeGIIntensity 1:UpdateFlashers
Case 11:table1.ColorGradeImage = "LUT11":GiIntensity = 1.55:FlIntensity = 3.2:ChangeGIIntensity 1:UpdateFlashers
Case 12:table1.ColorGradeImage = "LUT12":GiIntensity = 1.6:FlIntensity = 3.4:ChangeGIIntensity 1:UpdateFlashers
Case 13:table1.ColorGradeImage = "LUT13":GiIntensity = 1.65:FlIntensity = 3.6:ChangeGIIntensity 1:UpdateFlashers
Case 14:table1.ColorGradeImage = "LUT14":GiIntensity = 1.7:FlIntensity = 3.8:ChangeGIIntensity 1:UpdateFlashers
End Select
End Sub
Dim GiIntensity, FlIntensity
GiIntensity = 1 'used by the LUT changing to increase the GI lights when the table is darker
FlIntensity = 1
Sub ChangeGiIntensity(factor) 'changes the intensity scale
Dim bulb
For each bulb in aGiLights
bulb.IntensityScale = GiIntensity * factor
Next
End Sub
'********************
' Flippers
'********************
Dim FlipLOn, FlipROn
Sub SolLFlipper(Enabled)
If Enabled Then
PlaySoundAtVol SoundFXDOF("fx_flipperup", 101, DOFOn, DOFFlippers), LeftFlipper, FluVol
PlaySoundLoopAtVol "buzz", LeftFlipper, FlbVol
LeftFlipper.RotateToEnd:FlipLOn = 1
Else
PlaySoundAtVol SoundFXDOF("fx_flipperdown", 101, DOFOff, DOFFlippers), LeftFlipper, FldVol
StopSound "buzz"
LeftFlipper.RotateToStart:FlipLOn = 0
End If
End Sub
Sub SolRFlipper(Enabled)
If Enabled Then
PlaySoundAtVol SoundFXDOF("fx_flipperup", 102, DOFOn, DOFFlippers), RightFlipper, FluVol
PlaySoundLoopAtVol "buzz1", RightFlipper, FlbVol
RightFlipper.RotateToEnd:FlipROn = 1
Else
PlaySoundAtVol SoundFXDOF("fx_flipperdown", 102, DOFOff, DOFFlippers), RightFlipper, FldVol
StopSound "buzz1"
RightFlipper.RotateToStart:FlipROn = 0
End If
End Sub
'***********
' GI lights
'***********
Sub GiOn 'Turn on GI lights
Dim bulb
PlaySoundAtVol "fx_gion", Bumper3, GirVol
For each bulb in aGiLights
bulb.State = 1
Next
FlasherOn 1
If B2SOn Then
Controller.B2SSetData 50, 1
Controller.B2SSetData 25, 1
End If
End Sub
Sub GiOff 'Turn off GI lights
Dim bulb
PlaySoundAtVol "fx_gioff", Bumper3, GirVol
For each bulb in aGiLights
bulb.State = 0
Next
FlasherOn 0
If B2SOn Then
Controller.B2SSetData 50, 0
Controller.B2SSetData 25, 0
End If
End Sub
'********************************** Tilt
Sub CheckTilt
If bGameInPlay Then
Tilt = Tilt + TiltSensitivity
TiltDecreaseTimer.Enabled = True
If Tilt > 15 Then
Tilted = True
TiltReel.SetValue 1
fTilt.Visible = 1
PlaySoundAtVol "tilt", Bumper3, TilVol
If B2SOn Then
Controller.B2SSetTilt 1
End If
DisableTable True
' BallsRemaining(CurrentPlayer) = 0 'player looses the game
TiltRecoveryTimer.Enabled = True 'wait for all the balls to drain
End If
End If
End Sub
Sub TiltDecreaseTimer_Timer
If Tilt > 0 Then
Tilt = Tilt - 0.1
Else
TiltDecreaseTimer.Enabled = False
End If
End Sub
Sub DisableTable(Enabled)
If Enabled Then
Bumper1.HasHitEvent = 0
Bumper2.HasHitEvent = 0
Bumper3.HasHitEvent = 0
Bumper4.HasHitEvent = 0
Bumper5.HasHitEvent = 0
LeftSlingShot.Disabled = 1
RightSlingShot.Disabled = 1
DOF 101, DOFOff
DOF 102, DOFOff
If FlipLOn = 1 Then:SolLFlipper 0:End If
If FlipROn = 1 Then:SolRFlipper 0:End If
PostDown
TiltSeq.Play SeqAllOff
FlasherOn 0
If B2SOn Then
Controller.B2SSetData 50, 0
Controller.B2SSetData 25, 0
End If
Else
Bumper1.HasHitEvent = 1
Bumper2.HasHitEvent = 1
Bumper3.HasHitEvent = 1
Bumper4.HasHitEvent = 1
Bumper5.HasHitEvent = 1
LeftSlingShot.Disabled = 0
RightSlingShot.Disabled = 0
TiltSeq.StopPlay
FlasherOn 1
If B2SOn Then
Controller.B2SSetData 50, 1
Controller.B2SSetData 25, 1
End If
End If
End Sub
Sub TiltRecoveryTimer_Timer()
' all the balls have drained
If(BallsOnPlayfield = 0)Then
EndOfBall()
TiltRecoveryTimer.Enabled = False
End If
' otherwise repeat
End Sub
'************************************************************************************************************************
' Only for VPX 10.2 and higher.
' FlashForMs will blink light or a flasher for TotalPeriod(ms) at rate of BlinkPeriod(ms)
' When TotalPeriod done, light or flasher will be set to FinalState value where
' Final State values are: 0=Off, 1=On, 2=Return to previous State
'************************************************************************************************************************
Sub FlashForMs(MyLight, TotalPeriod, BlinkPeriod, FinalState)
If TypeName(MyLight) = "Light" Then
If FinalState = 2 Then
FinalState = MyLight.State
End If
MyLight.BlinkInterval = BlinkPeriod
MyLight.Duration 2, TotalPeriod, FinalState
ElseIf TypeName(MyLight) = "Flasher" Then
Dim steps
steps = Int(TotalPeriod / BlinkPeriod + .5)
If FinalState = 2 Then
FinalState = ABS(MyLight.Visible)
End If
MyLight.UserValue = steps * 10 + FinalState
MyLight.TimerInterval = BlinkPeriod
MyLight.TimerEnabled = 0
MyLight.TimerEnabled = 1
ExecuteGlobal "Sub " & MyLight.Name & "_Timer:" & "Dim tmp, steps, fstate:tmp=me.UserValue:fstate = tmp MOD 10:steps= tmp\10 -1:Me.Visible = steps MOD 2:me.UserValue = steps *10 + fstate:If Steps = 0 then Me.Visible = fstate:Me.TimerEnabled=0:End If:End Sub"
End If
End Sub
'****************************************
' Init table for a new game
'****************************************
Sub ResetForNewGame()
'debug.print "ResetForNewGame"
Dim i
bGameInPlay = True
bBallSaverActive = False
NewGReset = 1
StopAttractMode
DOF 200, DOFOn
If Electrician_Mode = 1 Then CentoMR.SetValue 0:fCentoM.Visible = 0
If B2SOn Then
Controller.B2SSetGameOver 0
If Electrician_Mode = 1 Then
Controller.B2SSetData 99, 0 'off
End If
End If
GiOn
Clear_Match
CurrentPlayer = 1
PlayersPlayingGame = 1
bOnTheFirstBall = True
For i = 1 To MaxPlayers
Score(i) = 0
ExtraBallsAwards(i) = 0
Special1Awarded(i) = False
Special2Awarded(i) = False
Special3Awarded(i) = False
Special4Awarded(i) = False
BallsRemaining(i) = BallsPerGame
Next
BonusMultiplier = 1
Bonus = 0
fM00.Visible=0:fM10.Visible=0:fM20.Visible=0:fM30.Visible=0:fM40.Visible=0:fM50.Visible=0:fM60.Visible=0:fM70.Visible=0:fM80.Visible=0:fM90.Visible=0
' init other variables
Tilt = 0
' init game variables
Game_Init()
' start a music?
' first ball
' vpmtimer.addtimer 2000, "FirstBall '"
PlaySoundAtVol "Klondike Init", Bumper3, IniVol
NewGameReset.Enabled = 1
End Sub
'********************************** Reset ball count unit
Sub NewGameReset_Timer
Select Case Ngr
Case 1:ReelScoreReset.Enabled = 1:If BallsPerGame > 0 Then:Bpg = 1:UpdateBallInPlay:End If
Case 2:If BallsPerGame > 1 Then:Bpg = 2:UpdateBallInPlay:End If
Case 3:If BallsPerGame > 2 Then:Bpg = 3:UpdateBallInPlay:End If
Case 4:If BallsPerGame > 3 Then:Bpg = 4:UpdateBallInPlay:End If
Case 5:If BallsPerGame > 4 Then:Bpg = 5:UpdateBallInPlay:End If
Case 6:If BallsPerGame > 5 Then:Bpg = 6:UpdateBallInPlay:End If
Case 7:If BallsPerGame > 6 Then:Bpg = 7:UpdateBallInPlay:End If
Case 8:If BallsPerGame > 7 Then:Bpg = 8:UpdateBallInPlay:End If
Case 9:If BallsPerGame > 8 Then:Bpg = 9:UpdateBallInPlay:End If
Case 14:FirstBall:NewGReset = 0:ReelScoreReset.Enabled = 0:NewGameReset.Enabled = 0
End Select
Ngr = Ngr + 1
End Sub
'********************************** Reset reels backbox
Sub ReelScoreReset_Timer
If Dec1.RotX <> 360 And Dec1.RotX <> 0 Then:Dec1.RotX = Dec1.RotX + 6:End If
If Dec1.RotX = 36 or Dec1.RotX = 72 or Dec1.RotX = 108 or Dec1.RotX = 144 or Dec1.RotX = 180 or Dec1.RotX = 216 or Dec1.RotX = 252 or Dec1.RotX = 288 or Dec1.RotX = 324 Then
PlaySoundAtVol "cluper", Dec1, RepVol
End If
If Cen1.RotX <> 360 And Cen1.RotX <> 0 Then:Cen1.RotX = Cen1.RotX + 6:End If
If Cen1.RotX = 36 or Cen1.RotX = 72 or Cen1.RotX = 108 or Cen1.RotX = 144 or Cen1.RotX = 180 or Cen1.RotX = 216 or Cen1.RotX = 252 or Cen1.RotX = 288 or Cen1.RotX = 324 Then
PlaySoundAtVol "cluper", Cen1, RepVol
End If
If Mil1.RotX <> 360 And Mil1.RotX <> 0 Then:Mil1.RotX = Mil1.RotX + 6:End If
If Mil1.RotX = 36 or Mil1.RotX = 72 or Mil1.RotX = 108 or Mil1.RotX = 144 or Mil1.RotX = 180 or Mil1.RotX = 216 or Mil1.RotX = 252 or Mil1.RotX = 288 or Mil1.RotX = 324 Then
PlaySoundAtVol "cluper", Mil1, RepVol
End If
If DMi1.RotX <> 360 And DMi1.RotX <> 0 Then:DMi1.RotX = DMi1.RotX + 6:End If
If DMi1.RotX = 36 or DMi1.RotX = 72 or DMi1.RotX = 108 or DMi1.RotX = 144 or DMi1.RotX = 180 or DMi1.RotX = 216 or DMi1.RotX = 252 or DMi1.RotX = 288 or DMi1.RotX = 324 Then
PlaySoundAtVol "cluper", DMi1, RepVol
End If
End Sub
Sub FirstBall
'debug.print "FirstBall"
' reset table for a new ball, rise droptargets ++
ResetForNewPlayerBall()
CreateNewBall()
DOF 250, DOFPulse
Ngr = 0
Bpg = 0
UpdateS10 = 0:UpdateS100 = 0:UpdateS1000 = 0:UpdateS10000 = 0
End Sub
' (Re-)init table for a new ball or player
Sub ResetForNewPlayerBall()
'debug.print "ResetForNewPlayerBall"
AddScore 0
' reset multiplier to 1x
' turn on lights, and variables
bExtraBallWonThisBall = False
ResetNewBallLights
ResetNewBallVariables
End Sub
' Crete new ball
Sub CreateNewBall()
BallRelease.CreateSizedBallWithMass BallSize / 2, BallMass
BallsOnPlayfield = BallsOnPlayfield + 1
PlaySoundAt SoundFXDOF ("fx_Ballrel", 150, DOFPulse, DOFContactors), BallRelease
BallRelease.Kick 60, 13
End Sub
' player lost the ball
Sub EndOfBall()
'debug.print "EndOfBall"
Dim AwardPoints, TotalBonus, ii
AwardPoints = 0
TotalBonus = 0
' Lost the first ball, now it cannot accept more players
bOnTheFirstBall = False
'No bonus in this table
' add bonus if no tilt
' tilt system will take care of the next ball
'If NOT Tilted AND LightShootAgain.State Then
'If NOT Tilted Then
' Select Case BonusMultiplier
' Case 1:BonusCountTimer.Interval = 250
' Case 2:BonusCountTimer.Interval = 400
' Case 3:BonusCountTimer.Interval = 550
' End Select
' BonusCountTimer.Enabled = 1
'Else
vpmtimer.addtimer 1000, "EndOfBall2 '"
'End If
End Sub
Sub BonusCountTimer_Timer
'debug.print "BonusCount_Timer"
If Bonus > 0 Then
Bonus = Bonus -1
AddScore 1000 * BonusMultiplier
UpdateBonusLights
Else
BonusCountTimer.Enabled = 0
vpmtimer.addtimer 1000, "EndOfBall2 '"
End If
End Sub
Sub UpdateBonusLights
' Select Case Bonus
' Case 0:bl1.State = 1:bl2.State = 0:bl2a.State = 0:bl3.State = 0:bl3a.State = 0:bl4.State = 0:bl4a.State = 0:bl5.State = 0:bl5a.State = 0:bl5k.State = 0:bl10k.State = 0:bl15k.State = 0:bl20k.State = 0:SpecialL1.State = 0
' End Select
End Sub
' After bonus count go to the next step
'
Sub EndOfBall2()
'debug.print "EndOfBall2"
Tilted = False
Tilt = 0
TiltReel.SetValue 0
fTilt.Visible = 0
If B2SOn Then
Controller.B2SSetTilt 0
End If
DisableTable False
' win extra ball?
If(ExtraBallsAwards(CurrentPlayer) > 0)Then
'debug.print "Extra Ball"
' if so then give it
ExtraBallsAwards(CurrentPlayer) = ExtraBallsAwards(CurrentPlayer)- 1
' turn off light if no more extra balls
If(ExtraBallsAwards(CurrentPlayer) = 0)Then
'LightShootAgain.State = 0
'If B2SOn then
'Controller.B2SSetShootAgain 0
'End If
End If
' extra ball sound?
' reset as in a new ball
ResetForNewPlayerBall()
CreateNewBall()
Else ' no extra ball
BallsRemaining(CurrentPlayer) = BallsRemaining(CurrentPlayer)- 1
UpdateBallInPlay
' last ball?
If(BallsRemaining(CurrentPlayer) <= 0)Then
CheckHighScore()
End If
' this is not the last ball, chack for new player
EndOfBallComplete()
End If
End Sub
Sub EndOfBallComplete()
'debug.print "EndOfBallComplete"
Dim NextPlayer
' other players?
If(PlayersPlayingGame > 1)Then
NextPlayer = CurrentPlayer + 1
' if it is the last player then go to the first one
If(NextPlayer > PlayersPlayingGame)Then
NextPlayer = 1
End If
Else
NextPlayer = CurrentPlayer
End If
'debug.print "Next Player = " & NextPlayer
' end of game?
If((BallsRemaining(CurrentPlayer) <= 0)AND(BallsRemaining(NextPlayer) <= 0))Then
' match if playing with coins
If bFreePlay = False Then
Verification_Match
End If
EndOfGame()
Reel1Advance
Reel3Advance
BallstoPlayR.SetValue 0
fb1.Visible = 0
PlaySoundAtVol "BallCount", Screw027, BcuVol
Else
' next player
CurrentPlayer = NextPlayer
' update score
AddScore 0
' reset table for new player
ResetForNewPlayerBall()
CreateNewBall()
End If
End Sub
' Called at the end of the game
Sub EndOfGame()
'debug.print "EndOfGame"
bGameInPlay = False
bJustStarted = False
If B2SOn Then
Controller.B2SSetGameOver 1
Controller.B2SSetBallInPlay 0
End If
' turn off flippers
If FlipLOn = 1 Then:SolLFlipper 0:End If
If FlipROn = 1 Then:SolRFlipper 0:End If
DOF 250, DOFPulse
DOF 200, DOFOff
' start the attract mode
StartAttractMode
End Sub
' Fuction to calculate the balls left
Function Balls
Dim tmp
tmp = BallsPerGame - BallsRemaining(CurrentPlayer) + 1
If tmp > BallsPerGame Then
Balls = BallsPerGame
Else
Balls = tmp
End If
End Function
' check the highscore
Sub CheckHighscore
Dim playertops, si, sj, i, stemp, stempplayers
For i = 1 to 4
sortscores(i) = 0
sortplayers(i) = 0
Next
playertops = 0
For i = 1 to PlayersPlayingGame
sortscores(i) = Score(i)
sortplayers(i) = i
Next
For si = 1 to PlayersPlayingGame
For sj = 1 to PlayersPlayingGame-1
If sortscores(sj) > sortscores(sj + 1)Then
stemp = sortscores(sj + 1)
stempplayers = sortplayers(sj + 1)
sortscores(sj + 1) = sortscores(sj)
sortplayers(sj + 1) = sortplayers(sj)
sortscores(sj) = stemp
sortplayers(sj) = stempplayers
End If
Next
Next
HighScoreTimer.Interval = 100
HighScoreTimer.Enabled = True
ScoreChecker = 4
CheckAllScores = 1
NewHighScore sortscores(ScoreChecker), sortplayers(ScoreChecker)
End Sub
'******************
' Match
'******************
Sub Verification_Match()
PlaySoundAtVol "fx_match", Bumper3, MatVol
Match = INT(RND(1) * 10) *10 ' random between 0 and 90
Display_Match
If(Score(CurrentPlayer)MOD 100) = Match And (SpecialMode = 2 or SpecialMode = 4) Then
PlaySoundAtVol SoundFXDOF ("knocker", 127, DOFPulse, DOFKnocker), Screw022, KnoVol
DOF 227, DOFPulse
AddCredits 1
End If
End Sub
Sub Clear_Match()
MatchR.SetValue 10
If B2SOn Then
Controller.B2SSetMatch(0)
End If
End Sub
Sub Display_Match()
MatchR.SetValue Match\10
Select Case (Match\10)
Case 0:fM00.Visible=1:fM10.Visible=0:fM20.Visible=0:fM30.Visible=0:fM40.Visible=0:fM50.Visible=0:fM60.Visible=0:fM70.Visible=0:fM80.Visible=0:fM90.Visible=0
Case 1:fM00.Visible=0:fM10.Visible=1:fM20.Visible=0:fM30.Visible=0:fM40.Visible=0:fM50.Visible=0:fM60.Visible=0:fM70.Visible=0:fM80.Visible=0:fM90.Visible=0
Case 2:fM00.Visible=0:fM10.Visible=0:fM20.Visible=1:fM30.Visible=0:fM40.Visible=0:fM50.Visible=0:fM60.Visible=0:fM70.Visible=0:fM80.Visible=0:fM90.Visible=0
Case 3:fM00.Visible=0:fM10.Visible=0:fM20.Visible=0:fM30.Visible=1:fM40.Visible=0:fM50.Visible=0:fM60.Visible=0:fM70.Visible=0:fM80.Visible=0:fM90.Visible=0
Case 4:fM00.Visible=0:fM10.Visible=0:fM20.Visible=0:fM30.Visible=0:fM40.Visible=1:fM50.Visible=0:fM60.Visible=0:fM70.Visible=0:fM80.Visible=0:fM90.Visible=0
Case 5:fM00.Visible=0:fM10.Visible=0:fM20.Visible=0:fM30.Visible=0:fM40.Visible=0:fM50.Visible=1:fM60.Visible=0:fM70.Visible=0:fM80.Visible=0:fM90.Visible=0
Case 6:fM00.Visible=0:fM10.Visible=0:fM20.Visible=0:fM30.Visible=0:fM40.Visible=0:fM50.Visible=0:fM60.Visible=1:fM70.Visible=0:fM80.Visible=0:fM90.Visible=0
Case 7:fM00.Visible=0:fM10.Visible=0:fM20.Visible=0:fM30.Visible=0:fM40.Visible=0:fM50.Visible=0:fM60.Visible=0:fM70.Visible=1:fM80.Visible=0:fM90.Visible=0
Case 8:fM00.Visible=0:fM10.Visible=0:fM20.Visible=0:fM30.Visible=0:fM40.Visible=0:fM50.Visible=0:fM60.Visible=0:fM70.Visible=0:fM80.Visible=1:fM90.Visible=0
Case 9:fM00.Visible=0:fM10.Visible=0:fM20.Visible=0:fM30.Visible=0:fM40.Visible=0:fM50.Visible=0:fM60.Visible=0:fM70.Visible=0:fM80.Visible=0:fM90.Visible=1
Case 10:fM00.Visible=0:fM10.Visible=0:fM20.Visible=0:fM30.Visible=0:fM40.Visible=0:fM50.Visible=0:fM60.Visible=0:fM70.Visible=0:fM80.Visible=0:fM90.Visible=0
End Select
If B2SOn Then
If Match = 0 Then
Controller.B2SSetMatch 10
Else
Controller.B2SSetMatch Match\10
End If
End If
End Sub