-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathCheck Mate (Taito - 1977) 1.0.0.vbs
1679 lines (1441 loc) · 47 KB
/
Check Mate (Taito - 1977) 1.0.0.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 por JPSalas
' Script Básico para juegos EM Script hasta 4 players
' usa el core.vbs para funciones extras
' ****************************************************************
Option Explicit
Randomize
' Valores Constantes de las físicas de los flippers - se usan en la creación de las bolas, tienen que cargarse antes del core.vbs
Const BallSize = 25 ' el radio de la bola. el tamaño normal es 50 unidades de VP
Const BallMass = 1 ' la pesadez de la bola, este valor va de acuerdo a la fuerza de los flippers y el plunger
' Carga el core.vbs para poder usas sus funciones, sobre todo el vpintimer.addtimer
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
' Valores Constants
Const TableName = "CheckMate"
Const cGameName = "CheckMate"
Const MaxPlayers = 4 ' de 1 a 4
Const MaxMultiplier = 5 ' limita el bonus multiplicador a 5
Const BallsPerGame = 5 ' normalmente 3 ó 5
Const Special1 = 560000 ' puntuación a obtener para partida extra
Const Special2 = 720000 ' puntuación a obtener para partida extra
Const Special3 = 999000 ' puntuación a obtener para partida extra
' Variables Globales
Dim PlayersPlayingGame
Dim CurrentPlayer
Dim Credits
Dim Bonus
Dim DoubleBonus
Dim BallsRemaining(4)
Dim ExtraBallsAwards(4)
Dim Special1Awarded(4)
Dim Special2Awarded(4)
Dim Special3Awarded(4)
Dim Score(4)
Dim HighScore
Dim Match
Dim Tilt
Dim TiltSensitivity
Dim Tilted
Dim Add10
Dim Add100
Dim Add1000
' Variables de control
Dim BallsOnPlayfield
' Variables de tipo Boolean (verdadero ó falso, True ó False)
Dim bAttractMode
Dim bFreePlay
Dim bGameInPlay
Dim bOnTheFirstBall
Dim bExtraBallWonThisBall
Dim bJustStarted
Dim bBallInPlungerLane
Dim bBallSaverActive
Dim x
' core.vbs variables, como imanes, impulse plunger
' *********************************************************************
' Rutinas comunes para todas las mesas
' *********************************************************************
Sub Table1_Init()
' Inicializar diversos objetos de la mesa, como droptargets, animations...
VPObjects_Init
LoadEM
' Carga los valores grabados highscore y créditos
Loadhs
'HighscoreReel.SetValue Highscore
' también pon el highscore en el reel del primer jugador
' ScoreReel1.SetValue Highscore
' en esta mesa el attractmode se encarga de mostrar el highscore
UpdateCredits
' Juego libre o con monedas: si es True entonces no se usarán monedas
bFreePlay = False 'queremos monedas
' Inicialiar las variables globales de la mesa
bAttractMode = False
bOnTheFirstBall = False
bGameInPlay = False
bBallInPlungerLane = False
BallsOnPlayfield = 0
Tilt = 0
TiltSensitivity = 6
Tilted = False
bJustStarted = True
Add10 = 0
Add100 = 0
Add1000 = 0
' pone la mesa en modo de espera
EndOfGame
'Enciende las luces GI despues de un segundo
vpmtimer.addtimer 1000, "GiOn '"
' Quita los laterales y las puntuaciones cuando la mesa se juega en modo FS
If Table1.ShowDT = False then
lrail.Visible = False
rrail.Visible = False
For each x in aReels
x.Visible = 0
Next
End If
' Arranca el Game Timer de las animaciones, sonido de las bolas rodando, etc
GameTimer.Enabled = 1
End Sub
'******
' Keys
'******
Sub Table1_KeyDown(ByVal Keycode)
' añade monedas
If Keycode = AddCreditKey Then
If(Tilted = False)Then
AddCredits 1
PlaySound "fx_coin"
PlaySound "coin"
End If
End If
' el plunger
If keycode = PlungerKey Then
Plunger.Pullback
PlaySoundAt "fx_plungerpull", plunger
End If
' Funcionamiento normal de los flipers y otras teclas durante el juego
If bGameInPlay AND NOT Tilted Then
' teclas de la falta
If keycode = LeftTiltKey Then Nudge 90, 8:PlaySound "fx_nudge", 0, 1, -0.1, 0.25:CheckTilt
If keycode = RightTiltKey Then Nudge 270, 8:PlaySound "fx_nudge", 0, 1, 0.1, 0.25:CheckTilt
If keycode = CenterTiltKey Then Nudge 0, 9:PlaySound "fx_nudge", 0, 1, 1, 0.25:CheckTilt
If keycode = MechanicalTilt Then Nudge 0, 4:PlaySound "fx_nudge",0,1,1,0,25:CheckTilt
' teclas de los flipers
If keycode = LeftFlipperKey Then SolLFlipper 1
If keycode = RightFlipperKey Then SolRFlipper 1
' tecla de empezar el juego
If keycode = StartGameKey Then
If((PlayersPlayingGame < MaxPlayers)AND(bOnTheFirstBall = True))Then
If(bFreePlay = True)Then
PlayersPlayingGame = PlayersPlayingGame + 1
PlaySound "start"
Else
If(Credits > 0)then
PlayersPlayingGame = PlayersPlayingGame + 1
Credits = Credits - 1
UpdateCredits
UpdateBallInPlay
PlaySound "start"
Else
' no hay suficientes créditos para empezar el juego.
PlaySound "10000"
End If
End If
End If
End If
Else ' If (GameInPlay)
If keycode = StartGameKey Then
If(bFreePlay = True)Then
If(BallsOnPlayfield = 0)Then
ResetScores
ResetForNewGame()
PlaySound "start"
End If
Else
If(Credits > 0)Then
If(BallsOnPlayfield = 0)Then
Credits = Credits - 1
UpdateCredits
ResetScores
ResetForNewGame()
PlaySound "start"
End If
Else
' Not Enough Credits to start a game.
PlaySound "10000"
End If
End If
End If
End If ' If (GameInPlay)
End Sub
Sub Table1_KeyUp(ByVal keycode)
If bGameInPlay AND NOT Tilted Then
' teclas de los flipers
If keycode = LeftFlipperKey Then SolLFlipper 0
If keycode = RightFlipperKey Then SolRFlipper 0
End If
If keycode = PlungerKey Then
Plunger.Fire
If bBallInPlungerLane Then
PlaySoundAt "fx_plunger", plunger
Else
PlaySoundAt "fx_plunger_empty", plunger
End If
End If
End Sub
'*************
' Para la mesa
'*************
Sub table1_Paused
End Sub
Sub table1_unPaused
End Sub
Sub table1_Exit
Savehs
If B2SOn Then Controller.Stop
End Sub
'********************
' Flippers
'********************
Sub SolLFlipper(Enabled)
If Enabled Then
PlaySoundAt "fx_flipperup", LeftFlipper
LeftFlipper.RotateToEnd
Else
PlaySoundAt "fx_flipperdown", LeftFlipper
LeftFlipper.RotateToStart
End If
End Sub
Sub SolRFlipper(Enabled)
If Enabled Then
PlaySoundAt "fx_flipperup", RightFlipper
RightFlipper.RotateToEnd
Else
PlaySoundAt "fx_flipperdown", RightFlipper
RightFlipper.RotateToStart
End If
End Sub
' el sonido de la bola golpeando los flipers
Sub LeftFlipper_Collide(parm)
PlaySoundAtBall "fx_rubber_flipper"
End Sub
Sub RightFlipper_Collide(parm)
PlaySoundAtBall "fx_rubber_flipper"
End Sub
'*******************
' Luces GI
'*******************
Sub GiOn 'enciende las luces GI
Dim bulb
For each bulb in aGiLights
bulb.State = 1
Next
If B2SOn Then Controller.B2SSetData 60,1
End Sub
Sub GiOff 'apaga las luces GI
Dim bulb
For each bulb in aGiLights
bulb.State = 0
Next
If B2SOn Then Controller.B2SSetData 60,0
End Sub
'**************
' TILT - Falta
'**************
'el "timer" TiltDecreaseTimer resta .01 de la variable "Tilt" cada ronda
Sub CheckTilt 'esta rutina se llama cada vez que das un golpe a la mesa
Tilt = Tilt + TiltSensitivity 'añade un valor al contador "Tilt"
TiltDecreaseTimer.Enabled = True
If Tilt > 15 Then 'Si la variable "Tilt" es más de 15 entonces haz falta
Tilted = True
TiltReel.SetValue 1 'muestra Tilt en la pantalla
If B2SOn then
Controller.B2SSetTilt 1
end if
DisableTable True
TiltRecoveryTimer.Enabled = True 'empieza una pausa a fin de que todas las bolas se cuelen
End If
End Sub
Sub TiltDecreaseTimer_Timer
' DecreaseTilt
If Tilt > 0 Then
Tilt = Tilt - 0.1
Else
TiltDecreaseTimer.Enabled = False
End If
End Sub
Sub DisableTable(Enabled)
If Enabled Then
'Apaga todas las luces Gi de la mesa
GiOff
'Disable slings, bumpers etc
LeftFlipper.RotateToStart
RightFlipper.RotateToStart
Bumper1.Force = 0
Bumper2.Force = 0
LeftSlingshot.Disabled = 1
RightSlingshot.Disabled = 1
Else
'enciende de nuevo todas las luces GI
GiOn
Bumper1.Force = 10
Bumper2.Force = 10
LeftSlingshot.Disabled = 0
RightSlingshot.Disabled = 0
End If
End Sub
Sub TiltRecoveryTimer_Timer()
' si todas las bolas se han colado, entonces ..
If(BallsOnPlayfield = 0)Then
'... haz el fin de bola normal
EndOfBall()
TiltRecoveryTimer.Enabled = False
End If
' de lo contrario la rutina mirará si todavía hay bolas en la mesa
End Sub
' *********************************************************************
' Funciones para los sonidos de la mesa
' *********************************************************************
Function Vol(ball) ' Calcula el volumen del sonido basado en la velocidad de la bola
Vol = Csng(BallVel(ball) ^2 / 2000)
End Function
Function Pan(ball) ' Calculala posición estéreo de la bola (izquierda a derecha)
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) ' Calcula el tono según la velocidad de la bola
Pitch = BallVel(ball) * 20
End Function
Function BallVel(ball) 'Calcula la velocidad de la bola
BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2)))
End Function
Function AudioFade(ball) 'Solo para VPX 10.4 y siguentes: calcula la posición de arriba/abajo de la bola, para mesas con el sonido dolby
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
Sub PlaySoundAt(soundname, tableobj) ' Hace sonar un sonido en la posición de un objeto, como bumpers y flippers
PlaySound soundname, 0, 1, Pan(tableobj), 0, 0, 0, 0, AudioFade(tableobj)
End Sub
Sub PlaySoundAtBall(soundname) ' hace sonar un sonido en la posición de la bola
PlaySound soundname, 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
End Sub
'*****************************************
' Los sonidos de la bola/s rodando
'*****************************************
Const tnob = 6 ' número total de bola
Const lob = 0 'número de bola encerradas
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
BOT = GetBalls
' para el sonido de bolas perdidas
For b = UBound(BOT) + 1 to tnob
rolling(b) = False
StopSound("fx_ballrolling" & b)
Next
' sale de la rutina si no hay más bolas en la mesa
If UBound(BOT) = lob - 1 Then Exit Sub
' hace sonar el sonido de la bola rodando para cada bola
For b = lob to UBound(BOT)
If BallVel(BOT(b)) > 1 Then
If BOT(b).z < 30 Then
ballpitch = Pitch(BOT(b))
Else
ballpitch = Pitch(BOT(b)) + 20000 'aumenta el tono del sonido si la bola está sobre una rampa
End If
rolling(b) = True
PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), 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
Next
End Sub
'*****************************
' Sonido de las bolas chocando
'*****************************
Sub OnBallBallCollision(ball1, ball2, velocity)
PlaySound "fx_collide", 0, Csng(velocity) ^2 / 2000, Pan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
End Sub
'***************************************
' Sonidos de las colecciones de objetos
' como metales, gomas, plásticos, etc
'***************************************
Sub aMetals_Hit(idx):PlaySoundAtBall "fx_MetalHit":End Sub
Sub aRubber_Bands_Hit(idx):PlaySoundAtBall "fx_rubber_band":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 aPlastics_Hit(idx):PlaySoundAtBall "fx_PlasticHit":End Sub
Sub aGates_Hit(idx):PlaySoundAtBall "fx_Gate":End Sub
Sub aWoods_Hit(idx):PlaySoundAtBall "fx_Woodhit":End Sub
'************************************************************************************************************************
' Solo para VPX 10.2 y posteriores.
' FlashForMs hará parpadear una luz o un flash por unos milisegundos "TotalPeriod" cada tantos milisegundos "BlinkPeriod"
' Cuando el "TotalPeriod" haya terminado, la luz o el flasher se pondrá en el estado especificado por el valor "FinalState"
' El valor de "FinalState" puede ser: 0=apagado, 1=encendido, 2=regreso al estado anterior
'************************************************************************************************************************
Sub FlashForMs(MyLight, TotalPeriod, BlinkPeriod, FinalState)
If TypeName(MyLight) = "Light" Then ' la luz es del tipo "light"
If FinalState = 2 Then
FinalState = MyLight.State 'guarda el estado actual de la luz
End If
MyLight.BlinkInterval = BlinkPeriod
MyLight.Duration 2, TotalPeriod, FinalState
ElseIf TypeName(MyLight) = "Flasher" Then ' la luz es del tipo "flash"
Dim steps
' Store all blink information
steps = Int(TotalPeriod / BlinkPeriod + .5) 'número de encendidos y apagados que hay que ejecutar
If FinalState = 2 Then 'guarda el estado actual del flash
FinalState = ABS(MyLight.Visible)
End If
MyLight.UserValue = steps * 10 + FinalState 'guarda el número de parpadeos
' empieza los parpadeos y crea la rutina que se va a ejecutar como un timer que se va a ejecutar los parpadeos
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
'****************************************
' Inicializa la mesa para un juego nuevo
'****************************************
Sub ResetForNewGame()
'debug.print "ResetForNewGame"
Dim i
bGameInPLay = True
bBallSaverActive = False
'pone a cero los marcadores y apaga las luces de espera.
StopAttractMode
If B2SOn then
Controller.B2SSetGameOver 0
end if
' enciende las luces GI si estuvieran apagadas
GiOn
MatchWheel.enabled=true
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
BallsRemaining(i) = BallsPerGame
Next
DoubleBonus = 1
Bonus = 0
UpdateBallInPlay
Match = INT(RND(1) * 8) * 10 + 10 'empieza con un número aleatorio de 10 a 90 para la loteria
Clear_Match
' inicializa otras variables
Tilt = 0
' inicializa las variables del juego
Game_Init()
' ahora puedes empezar una música si quieres
' empieza la rutina "Firstball" despues de una pequeña pausa
vpmtimer.addtimer 2000, "FirstBall '"
End Sub
' esta pausa es para que la mesa tenga tiempo de poner los marcadores a cero y actualizar las luces
Sub FirstBall
'debug.print "FirstBall"
' ajusta la mesa para una bola nueva, sube las dianas abatibles, etc
ResetForNewPlayerBall()
' crea una bola nueva en la zona del plunger
CreateNewBall()
End Sub
' (Re-)inicializa la mesa para una bola nueva, tanto si has perdido la bola, oe le toca el turno al otro jugador
Sub ResetForNewPlayerBall()
'debug.print "ResetForNewPlayerBall"
' Se asegura que los marcadores están activados para el jugador de turno
AddScore 0
' ajusta el multiplicador del bonus multiplier a 1X (si hubiese multiplicador en la mesa)
' enciende las luces, reinicializa las variables del juego, etc
bExtraBallWonThisBall = False
ResetNewBallLights
ResetNewBallVariables
End Sub
' Crea una bola nueva en la mesa
Sub CreateNewBall()
' crea una bola nueva basada en el tamaño y la masa de la bola especificados al principio del script
BallRelease.CreateSizedBallWithMass BallSize, BallMass
' incrementa el número de bolas en el tablero, ya que hay que contarlas
BallsOnPlayfield = BallsOnPlayfield + 1
' actualiza las luces del backdrop
UpdateBallInPlay
' y expulsa la bola
PlaySoundAt "fx_Ballrel", BallRelease
BallRelease.Kick 90, 4
End Sub
' El jugador ha perdido su bola, y ya no hay más bolas en juego
' Empieza a contar los bonos
Sub EndOfBall()
'debug.print "EndOfBall"
Dim AwardPoints, TotalBonus, ii
AwardPoints = 0
TotalBonus = 0
' La primera se ha perdido. Desde aquí ya no se puede aceptar más jugadores
bOnTheFirstBall = False
' solo recoge los bonos si no hay falta
' el sistema del la falta se encargará de nuevas bolas o del fin de la partida
If NOT Tilted Then
If DoubleBonus = 2 Then
BonusCountTimer.Interval = 400
CreditLight.BlinkInterval = 200
Else
BonusCountTimer.Interval = 250
CreditLight.BlinkInterval = 125
End If
CreditLight.State = 2
BonusCountTimer.Enabled = 1
Else 'Si hay falta simplemente espera un momento y va directo a la segunta parte después de perder la bola
vpmtimer.addtimer 400, "EndOfBall2 '"
End If
End Sub
Sub BonusCountTimer_Timer 'añade los bonos y actualiza las luces
'debug.print "BonusCount_Timer"
If Bonus > 0 Then
Bonus = Bonus -1
AddScore 1000 * DoubleBonus
UpdateBonusLights
Else
' termina la cuenta de los bonos y continúa con el fin de bola
BonusCountTimer.Enabled = 0
CreditLight.State = 0
vpmtimer.addtimer 1000, "EndOfBall2 '"
End If
End Sub
Sub UpdateBonusLights
For each x in aBonusLights
If x.State = 1 Then
x.State = 0
Exit Sub
End If
Next
If BankLDown Then
BankLDown = BankLDown - 1
For each x in aLeftDropLights
x.State = 1
Next
aLeftDropLights(0).State = 0
Exit Sub
End If
If BankRDown Then
BankRDown = BankRDown -1
For each x in aRightDropLights
x.State = 1
Next
aRightDropLights(0).State = 0
End If
End Sub
' La cuenta de los bonos ha terminado. Mira si el jugador ha ganado bolas extras
' y si no mira si es el último jugador o la última bola
'
Sub EndOfBall2()
'debug.print "EndOfBall2"
' si hubiese falta, quítala, y pon la cuenta a cero de la falta para el próximo jugador, ó bola
Tilted = False
Tilt = 0
TiltReel.SetValue 0
If B2SOn then
Controller.B2SSetTilt 0
end if
DisableTable False 'activa de nuevo los bumpers y los slingshots
' ¿ha ganado el jugador una bola extra?
If(ExtraBallsAwards(CurrentPlayer) > 0)Then
'debug.print "Extra Ball"
' sí? entonces se la das al jugador
ExtraBallsAwards(CurrentPlayer) = ExtraBallsAwards(CurrentPlayer)- 1
' si no hay más bolas apaga la luz de jugar de nuevo
If(ExtraBallsAwards(CurrentPlayer) = 0)Then
LightShootAgain.State = 0
If B2SOn then
Controller.B2SSetShootAgain 0
end if
End If
' aquí se podría poner algún sonido de bola extra o alguna luz que parpadee
' En esta mesa hacemos la bola extra igual como si fuese la siguente bola, haciendo un reset de las variables y dianas
ResetForNewPlayerBall()
' creamos una bola nueva en el pasillo de disparo
CreateNewBall()
Else ' no hay bolas extras
BallsRemaining(CurrentPlayer) = BallsRemaining(CurrentPlayer)- 1
' ¿Es ésta la última bola?
If(BallsRemaining(CurrentPlayer) <= 0)Then
' miramos si la puntuación clasifica como el Highscore
CheckHighScore()
End If
' ésta no es la última bola para éste jugador
' y si hay más de un jugador continúa con el siguente
EndOfBallComplete()
End If
End Sub
' Esta rutina se llama al final de la cuenta del bonus
' y pasa a la siguente bola o al siguente jugador
'
Sub EndOfBallComplete()
'debug.print "EndOfBallComplete"
Dim NextPlayer
'debug.print "EndOfBall - Complete"
' ¿hay otros jugadores?
If(PlayersPlayingGame > 1)Then
' entonces pasa al siguente jugador
NextPlayer = CurrentPlayer + 1
' ¿vamos a pasar del último jugador al primero?
' (por ejemplo del jugador 4 al no. 1)
If(NextPlayer > PlayersPlayingGame)Then
NextPlayer = 1
End If
Else
NextPlayer = CurrentPlayer
End If
'debug.print "Next Player = " & NextPlayer
' ¿Hemos llegado al final del juego? (todas las bolas se han jugado de todos los jugadores)
If((BallsRemaining(CurrentPlayer) <= 0)AND(BallsRemaining(NextPlayer) <= 0))Then
' aquí se empieza la lotería, normalmente cuando se juega con monedas
If bFreePlay = False Then
Verification_Match
End If
' ahora se pone la mesa en el modo de final de juego
EndOfGame()
Else
' pasamos al siguente jugador
CurrentPlayer = NextPlayer
' nos aseguramos de que el backdrop muestra el jugador actual
AddScore 0
' hacemos un reset del la mesa para el siguente jugador (ó bola)
ResetForNewPlayerBall()
' y sacamos una bola
CreateNewBall()
End If
End Sub
' Esta función se llama al final del juego
Sub EndOfGame()
'debug.print "EndOfGame"
MatchWheel.enabled=false
bGameInPLay = False
bJustStarted = False
If B2SOn then
Controller.B2SSetGameOver 1
Controller.B2SSetBallInPlay 0
Controller.B2SSetPlayerUp 0
Controller.B2SSetCanPlay 0
end if
' asegúrate de que los flippers están en modo de reposo
SolLFlipper 0
SolRFlipper 0
' pon las luces en el modo de fin de juego
StartAttractMode
End Sub
' Esta función calcula el no de bolas que quedan
Function Balls
Dim tmp
tmp = BallsPerGame - BallsRemaining(CurrentPlayer) + 1
If tmp > BallsPerGame Then
Balls = BallsPerGame
Else
Balls = tmp
End If
End Function
' Esta función calcula el Highscore y te da una partida gratis si has conseguido el Highscore
Sub CheckHighscore
For x = 1 to PlayersPlayingGame
If Score(x) > Highscore Then
Highscore = Score(x)
PlaySound "fx_knocker"
'HighscoreReel.SetValue Highscore
AddCredits 1
End If
Next
End Sub
'******************
' Match - Loteria
'******************
sub MatchWheel_timer
IncreaseMatch
If B2SOn then
If Match = 0 then
Controller.B2SSetMatch 100
else
Controller.B2SSetMatch Match
end if
end if
end sub
Sub IncreaseMatch
Match = (Match + 10)MOD 100
End Sub
Sub Verification_Match()
PlaySound "fx_match"
Display_Match
If(Score(CurrentPlayer)MOD 100) = Match Then
PlaySound "fx_knocker"
AddCredits 1
End If
End Sub
Sub Clear_Match()
For each x in aMatchLights
x.State = 2
Next
If B2SOn then
Controller.B2SSetMatch 0
end if
End Sub
Sub Display_Match()
For each x in aMatchLights
x.State = 0
Next
aMatchLights(Match \ 10).state = 1
' If B2SOn then
' If Match = 0 then
' Controller.B2SSetMatch 100
' else
' Controller.B2SSetMatch Match
' end if
' end if
End Sub
' *********************************************************************
' Drain / Plunger Functions
' *********************************************************************
' has perdido la bola ;-( mira cuantas bolas hay en el tablero.
' si solamente hay una entonces reduce el número de bola y mira si es la última para finalizar el juego
' si hay más de una, significa que hay multiball, entonces continua con la partida
'
Sub Drain_Hit()
' destruye la bola
Drain.DestroyBall
BallsOnPlayfield = BallsOnPlayfield - 1
' haz sonar el ruido de la bola
PlaySoundAt "fx_drain", Drain
'si hay falta ve directo al final de la bola
If Tilted Then
vpmtimer.addtimer 500, "EndOfBall '" 'hacemos una pequeña pausa anter de continuar con el fin de bola
Exit Sub
End If
' si estás jugando y no hay falta
If(bGameInPLay = True)AND(Tilted = False)Then
' ¿está el salva bolas activado?
If(bBallSaverActive = True)Then
' ¿sí?, pues creamos una bola
CreateNewBall()
Else
' ¿es ésta la última bola en juego?
If(BallsOnPlayfield = 0)Then
vpmtimer.addtimer 500, "EndOfBall '" 'hacemos una pequeña pausa anter de continuar con el fin de bola
Exit Sub
End If
End If
End If
End Sub
Sub swPlungerRest_Hit()
bBallInPlungerLane = True
End Sub
' La bola ha sido disparada, así que cambiamos la variable, que en esta mesa se usa solo para que el sonido del disparador cambie según hay allí una bola o no
' En otras mesas podrá usarse para poner en marcha un contador para salvar la bola
Sub swPlungerRest_UnHit()
bBallInPlungerLane = False
End Sub
' *********************************************************************
' Funciones para la cuenta de los puntos
' *********************************************************************
' Añade puntos al jugador, hace sonar las campanas y actualiza el backdrop
Sub AddScore(Points)
If Tilted Then Exit Sub
Select Case Points
Case 10, 100, 1000
' añade los puntos a la variable del actual jugador
Score(CurrentPlayer) = Score(CurrentPlayer) + points
' actualiza los contadores
UpdateScore points
' hace sonar las campanillas de acuerdo a los puntos obtenidos
If Points = 100 AND(Score(CurrentPlayer)MOD 1000) \ 100 = 0 Then 'nuevo reel de 1000
PlaySound "1000"
ElseIf Points = 10 AND(Score(CurrentPlayer)MOD 100) \ 10 = 0 Then 'nuevo reel de 100
PlaySound "100"
Else
PlaySound "10"
End If
Case 50
Add10 = Add10 + 5
AddScore10Timer.Enabled = TRUE
Case 300
Add100 = Add100 + 3
AddScore100Timer.Enabled = TRUE
Case 500
Add100 = Add100 + 5
AddScore100Timer.Enabled = TRUE
Case 2000, 3000, 4000, 5000
Add1000 = Add1000 + Points \ 1000
AddScore1000Timer.Enabled = TRUE
End Select
' ' aquí se puede hacer un chequeo si el jugador ha ganado alguna puntuación alta y darle un crédito ó bola extra
If Score(CurrentPlayer) >= Special1 AND Special1Awarded(CurrentPlayer) = False Then
AwardSpecial
Special1Awarded(CurrentPlayer) = True
End If
If Score(CurrentPlayer) >= Special2 AND Special2Awarded(CurrentPlayer) = False Then
AwardSpecial
Special2Awarded(CurrentPlayer) = True
End If
If Score(CurrentPlayer) >= Special3 AND Special3Awarded(CurrentPlayer) = False Then
AwardSpecial
Special3Awarded(CurrentPlayer) = True
End If
End Sub
'******************************
'TIMER DE 10, 100 y 1000 PUNTOS
'******************************
' hace sonar las campanillas según los puntos
Sub AddScore10Timer_Timer()
if Add10 > 0 then
AddScore 10
Add10 = Add10 - 1
Else
Me.Enabled = FALSE
End If
End Sub
Sub AddScore100Timer_Timer()
if Add100 > 0 then
AddScore 100
Add100 = Add100 - 1
Else
Me.Enabled = FALSE
End If
End Sub
Sub AddScore1000Timer_Timer()
if Add1000 > 0 then
AddScore 1000
Add1000 = Add1000 - 1
Else
Me.Enabled = FALSE
End If
End Sub
'*******************
' BONOS
'*******************
' avanza el bono y actualiza las luces
' Los bonos están limitados a 1500 puntos