forked from LegendsUnchained/vpx-standalone-alp4k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Senna Prototype Edition (Culik Pinball 2020) VPX8.vbs
executable file
·2644 lines (2311 loc) · 85 KB
/
Senna Prototype Edition (Culik Pinball 2020) VPX8.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
' ****************************************************
' Senna - Prototype by Luiz Culik, 2020
'
' VPX8 Table by jpsalas, 2024, Version 1.0.0
' For more information about the table, please read the senna_tribute.pdf.
' Special thanks to:
' Carlos Guizzo for collecting all the graphics and sounds.
' Luis Culik for providing his images and sounds used in the original table.
' Ivo Vagner Simas for providing the backglass and cabinet illustrations he created.
' DanielZ for providing the playfield and plastics illustrations he created.
' Zé Americo for providing his voiceovers, including a special recording exclusive to this version.
' Halen for his work on the graphics and directb2s.
' ****************************************************
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 = 50 ' el diametro 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
'***** PLAYER OPTIONS ***********************************************
' color leds only for desktop view, the db2s must be changed manually
' Const Colorled = "red"
Const Colorled = "blue"
'**********************************************************************
' Valores Constants
Const TableName = "senna"
Const cGameName = "senna"
Const MaxPlayers = 4 ' de 1 a 4
Const BallsPerGame = 5 ' normalmente 3 ó 5
Const MaxBonusMultiplier = 5
Const MaxMultiballs = 3 ' max number of balls during multiballs
Const SongVolume = 1
Const Special1 = 620000 ' puntuación a obtener para partida extra
Const Special2 = 790000 ' puntuación a obtener para partida extra
Const Special3 = 960000 ' puntuación a obtener para partida extra
' Variables Globales
Dim PlayersPlayingGame
Dim CurrentPlayer
Dim Credits
Dim BallSaverTime ' in seconds of the first ball
Dim Bonus
Dim BonusMultiplier
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
Dim Add10000
Dim mBalls2Eject
' 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 bBallSaverReady
Dim bMultiBallMode
Dim bMultiBallStarted(4)
Dim bMultiBallReady
Dim bAutoPlunger
Dim x
' core.vbs variables, como imanes, impulse plunger
Dim plungerIM 'used mostly as an autofire plunger during multiballs
' *********************************************************************
' Rutinas comunes para todas las mesas
' *********************************************************************
Sub Table1_Init()
' Inicializar diversos objetos de la mesa, como droptargets, animations...
VPObjects_Init
LoadEM
'Impulse Plunger as autoplunger
Const IMPowerSetting = 45 ' Plunger Power
Const IMTime = 0.5 ' Time in seconds for Full Plunge
Set plungerIM = New cvpmImpulseP
With plungerIM
.InitImpulseP swplunger, IMPowerSetting, IMTime
.Random 1.5
.InitExitSnd SoundFXDOF("fx_kicker", 141, DOFPulse, DOFContactors), SoundFXDOF("fx_solenoid", 141, DOFPulse, DOFContactors)
.CreateEvents "plungerIM"
End With
' 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
BallSaverTime = 10 'at the start and multiball
bBallSaverActive = False
bBallSaverReady = False
bGameInPlay = False
bMultiBallMode = False
bMultiBallReady = False
bBallInPlungerLane = False
bAutoPlunger = False
BallsOnPlayfield = 0
Tilt = 0
TiltSensitivity = 6
Tilted = False
bJustStarted = True
Add10 = 0
Add100 = 0
Add1000 = 0
mBalls2Eject = 0
'Enciende las luces GI despues de un segundo
vpmtimer.addtimer 2500, "GiOn '"
' Handle color led options
If Colorled = "blue" Then
scorereel1.image = "leds2_taito_blue"
scorereel2.image = "leds2_taito_blue"
scorereel3.image = "leds2_taito_blue"
scorereel4.image = "leds2_taito_blue"
CreditsReel.image = "leds2_taito_blue"
BipReel.image = "leds2_taito_blue"
Else 'red
scorereel1.image = "leds2_taito"
scorereel2.image = "leds2_taito"
scorereel3.image = "leds2_taito"
scorereel4.image = "leds2_taito"
CreditsReel.image = "leds2_taito"
BipReel.image = "leds2_taito"
End If
' quita reels
If Table1.ShowDT = true then
For each x in aReels
x.Visible = 1
Next
else
For each x in aReels
x.Visible = 0
Next
end if
LoadLUT
PlaySound "vo_Machine_Startup"
StartAttractMode
End Sub
'******
' Keys
'******
Sub Table1_KeyDown(ByVal Keycode)
' añade monedas
If Keycode = AddCreditKey Then
If(Tilted = False) Then
AddCredits 1
If Credits < 9 then
PlaySound "fx_coin"
PlaySound "sfx_F1_Radio_Notification"
Else
PlaySound "fx_coin2"
End If
End If
End If
' el plunger
If keycode = PlungerKey Then
Plunger.Pullback
PlaySoundAt "fx_plungerpull", plunger
End If
' iluminación
If keycode = LeftMagnaSave Then bLutActive = True:SetLUTLine "Color LUT image " & table1.ColorGradeImage
If keycode = RightMagnaSave AND bLutActive Then NextLUT: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 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
Else
If(Credits> 0) then
PlayersPlayingGame = PlayersPlayingGame + 1
Credits = Credits - 1
UpdateCredits
UpdateBallInPlay
Else
' no hay suficientes créditos para empezar el juego.
'PlaySound "sfx_nocredits"
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()
End If
Else
If(Credits> 0) Then
If(BallsOnPlayfield = 0) Then
Credits = Credits - 1
UpdateCredits
ResetScores
ResetForNewGame()
End If
Else
' Not Enough Credits to start a game.
'PlaySound "sfx_nocredits"
End If
End If
End If
End If ' If (GameInPlay)
End Sub
Sub Table1_KeyUp(ByVal keycode)
If keycode = LeftMagnaSave Then bLutActive = False:HideLUT
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
'************************************
' LUT - Darkness control
' 10 normal level & 10 warmer levels
'************************************
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 22:UpdateLUT:SaveLUT:SetLUTLine "Color LUT image " & table1.ColorGradeImage:End Sub
Sub UpdateLUT
Select Case LutImage
Case 0:table1.ColorGradeImage = "LUT0"
Case 1:table1.ColorGradeImage = "LUT1"
Case 2:table1.ColorGradeImage = "LUT2"
Case 3:table1.ColorGradeImage = "LUT3"
Case 4:table1.ColorGradeImage = "LUT4"
Case 5:table1.ColorGradeImage = "LUT5"
Case 6:table1.ColorGradeImage = "LUT6"
Case 7:table1.ColorGradeImage = "LUT7"
Case 8:table1.ColorGradeImage = "LUT8"
Case 9:table1.ColorGradeImage = "LUT9"
Case 10:table1.ColorGradeImage = "LUT10"
Case 11:table1.ColorGradeImage = "LUT Warm 0"
Case 12:table1.ColorGradeImage = "LUT Warm 1"
Case 13:table1.ColorGradeImage = "LUT Warm 2"
Case 14:table1.ColorGradeImage = "LUT Warm 3"
Case 15:table1.ColorGradeImage = "LUT Warm 4"
Case 16:table1.ColorGradeImage = "LUT Warm 5"
Case 17:table1.ColorGradeImage = "LUT Warm 6"
Case 18:table1.ColorGradeImage = "LUT Warm 7"
Case 19:table1.ColorGradeImage = "LUT Warm 8"
Case 20:table1.ColorGradeImage = "LUT Warm 9"
Case 21:table1.ColorGradeImage = "LUT Warm 10"
End Select
End Sub
Dim GiIntensity
GiIntensity = 1 'can be 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
' New LUT postit
Function GetHSChar(String, Index)
Dim ThisChar
Dim FileName
ThisChar = Mid(String, Index, 1)
FileName = "PostIt"
If ThisChar = " " or ThisChar = "" then
FileName = FileName & "BL"
ElseIf ThisChar = "<" then
FileName = FileName & "LT"
ElseIf ThisChar = "_" then
FileName = FileName & "SP"
Else
FileName = FileName & ThisChar
End If
GetHSChar = FileName
End Function
Sub SetLUTLine(String)
Dim Index
Dim xFor
Index = 1
LUBack.imagea = "PostItNote"
For xFor = 1 to 40
Eval("LU" &xFor).imageA = GetHSChar(String, Index)
Index = Index + 1
Next
End Sub
Sub HideLUT
SetLUTLine ""
LUBack.imagea = "PostitBL"
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 SoundFXDOF("fx_flipperup", 101, DOFOn, DOFFlippers), LeftFlipper
LeftFlipper.RotateToEnd
LeftFlipperOn = 1
RotateTopLightsLeft
Else
PlaySoundAt SoundFXDOF("fx_flipperdown", 101, DOFOff, DOFFlippers), LeftFlipper
LeftFlipper.RotateToStart
LeftFlipperOn = 0
End If
End Sub
Sub SolRFlipper(Enabled)
If Enabled Then
PlaySoundAt SoundFXDOF("fx_flipperup", 102, DOFOn, DOFFlippers), RightFlipper
RightFlipper.RotateToEnd
RightFlipper1.RotateToEnd
RightFlipperOn = 1
RotateTopLightsRight
Else
PlaySoundAt SoundFXDOF("fx_flipperdown", 102, DOFOff, DOFFlippers), RightFlipper
RightFlipper.RotateToStart
RightFlipper1.RotateToStart
RightFlipperOn = 0
End If
End Sub
' flippers top animations
Sub LeftFlipper_Animate:LeftFlipperTop.RotZ = LeftFlipper.CurrentAngle:End Sub
Sub RightFlipper_Animate:RightFlipperTop.RotZ = RightFlipper.CurrentAngle:End Sub
Sub RightFlipper1_Animate:RightFlipperTop1.RotZ = RightFlipper1.CurrentAngle:End Sub
' flippers hit Sound
Sub LeftFlipper_Collide(parm)
PlaySound "fx_rubber_flipper", 0, Vol(ActiveBall), pan(ActiveBall), 0.1, 0, 0, 0, AudioFade(ActiveBall)
End Sub
Sub RightFlipper_Collide(parm)
PlaySound "fx_rubber_flipper", 0, Vol(ActiveBall), pan(ActiveBall), 0.1, 0, 0, 0, AudioFade(ActiveBall)
End Sub
Sub RightFlipper1_Collide(parm)
PlaySound "fx_rubber_flipper", 0, Vol(ActiveBall), pan(ActiveBall), 0.1, 0, 0, 0, AudioFade(ActiveBall)
End Sub
'*********************************************************
' Real Time Flipper adjustments - by JLouLouLou & JPSalas
' (to enable flipper tricks)
'*********************************************************
Dim FlipperPower
Dim FlipperElasticity
Dim SOSTorque, SOSAngle
Dim FullStrokeEOS_Torque, LiveStrokeEOS_Torque
Dim LeftFlipperOn
Dim RightFlipperOn
Dim LLiveCatchTimer
Dim RLiveCatchTimer
Dim LiveCatchSensivity
FlipperPower = 5000
FlipperElasticity = 0.8
FullStrokeEOS_Torque = 0.3 ' EOS Torque when flipper hold up ( EOS Coil is fully charged. Ampere increase due to flipper can't move or when it pushed back when "On". EOS Coil have more power )
LiveStrokeEOS_Torque = 0.2 ' EOS Torque when flipper rotate to end ( When flipper move, EOS coil have less Ampere due to flipper can freely move. EOS Coil have less power )
LeftFlipper.EOSTorqueAngle = 10
RightFlipper.EOSTorqueAngle = 10
SOSTorque = 0.1
SOSAngle = 6
LiveCatchSensivity = 10
LLiveCatchTimer = 0
RLiveCatchTimer = 0
LeftFlipper.TimerInterval = 1
LeftFlipper.TimerEnabled = 1
Sub LeftFlipper_Timer 'flipper's tricks timer
'Start Of Stroke Flipper Stroke Routine : Start of Stroke for Tap pass and Tap shoot
If LeftFlipper.CurrentAngle >= LeftFlipper.StartAngle - SOSAngle Then LeftFlipper.Strength = FlipperPower * SOSTorque else LeftFlipper.Strength = FlipperPower:End If
'End Of Stroke Routine : Livecatch and Emply/Full-Charged EOS
If LeftFlipperOn = 1 Then
If LeftFlipper.CurrentAngle = LeftFlipper.EndAngle then
LeftFlipper.EOSTorque = FullStrokeEOS_Torque
LLiveCatchTimer = LLiveCatchTimer + 1
If LLiveCatchTimer < LiveCatchSensivity Then
LeftFlipper.Elasticity = 0
Else
LeftFlipper.Elasticity = FlipperElasticity
LLiveCatchTimer = LiveCatchSensivity
End If
End If
Else
LeftFlipper.Elasticity = FlipperElasticity
LeftFlipper.EOSTorque = LiveStrokeEOS_Torque
LLiveCatchTimer = 0
End If
'Start Of Stroke Flipper Stroke Routine : Start of Stroke for Tap pass and Tap shoot
If RightFlipper.CurrentAngle <= RightFlipper.StartAngle + SOSAngle Then RightFlipper.Strength = FlipperPower * SOSTorque else RightFlipper.Strength = FlipperPower:End If
'End Of Stroke Routine : Livecatch and Emply/Full-Charged EOS
If RightFlipperOn = 1 Then
If RightFlipper.CurrentAngle = RightFlipper.EndAngle Then
RightFlipper.EOSTorque = FullStrokeEOS_Torque
RLiveCatchTimer = RLiveCatchTimer + 1
If RLiveCatchTimer < LiveCatchSensivity Then
RightFlipper.Elasticity = 0
Else
RightFlipper.Elasticity = FlipperElasticity
RLiveCatchTimer = LiveCatchSensivity
End If
End If
Else
RightFlipper.Elasticity = FlipperElasticity
RightFlipper.EOSTorque = LiveStrokeEOS_Torque
RLiveCatchTimer = 0
End If
End Sub
'*******************
' Luces GI
'*******************
Sub GiOn 'enciende las luces GI
Dim bulb
For each bulb in aGiLights
bulb.State = 1
Next
PlaySound "fx_gion"
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
PlaySound "fx_gioff"
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
StopSong
PlaySound "vo_Tilt"
Tilted = True
l150.State = 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
bMultiBallMode = False
StopMBmodes
BallSaverTimerExpired_Timer
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
RightFlipper1.RotateToStart
Bumper1.Threshold = 100
Bumper2.Threshold = 100
Bumper3.Threshold = 100
LeftSlingshot.Disabled = 1
RightSlingshot.Disabled = 1
Else
'enciende de nuevo todas las luces GI
GiOn
Bumper1.Threshold = 1
Bumper2.Threshold = 1
Bumper3.Threshold = 1
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
bMultiBallMode = False
'... 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
' GI, light & flashers sequence effects
Sub GiEffect(n)
Dim ii
Select Case n
Case 0 'all off
LightSeqGi.Play SeqAlloff
Case 1 'all blink
LightSeqGi.UpdateInterval = 50
LightSeqGi.Play SeqBlinking, , 8, 25
Case 2 'random
LightSeqGi.UpdateInterval = 25
LightSeqGi.Play SeqRandom, 50, , 1000
Case 3 'all blink fast
LightSeqGi.UpdateInterval = 40
LightSeqGi.Play SeqBlinking, , 10, 20
End Select
End Sub
Sub LightEffect(n)
Select Case n
Case 0 ' all off
LightSeqInserts.Play SeqAlloff
Case 1 'all blink
LightSeqInserts.UpdateInterval = 50
LightSeqInserts.Play SeqBlinking, , 5, 10
Case 2 'random
LightSeqInserts.UpdateInterval = 40
LightSeqInserts.Play SeqRandom, 25, , 1000
Case 3 'all blink fast
LightSeqInserts.UpdateInterval = 25
LightSeqInserts.Play SeqBlinking, , 10, 10
Case 4 'center - used in the bonus count
LightSeqInserts.UpdateInterval = 10
LightSeqInserts.Play SeqCircleOutOn, 15, 1
Case 5 'top down
LightSeqInserts.UpdateInterval = 4
LightSeqInserts.Play SeqDownOn, 15, 2
Case 6 'down to top
LightSeqInserts.UpdateInterval = 4
LightSeqInserts.Play SeqUpOn, 15, 1
End Select
End Sub
'*****************************************
' Internal Music
'*****************************************
Dim Song
Song = ""
Sub PlaySong(name)
If Song <> name Then
StopSound Song
Song = name
PlaySound Song, -1, SongVolume
End If
End Sub
Sub ChangeSong
End Sub
Sub StopSong
StopSound Song
Song = ""
End Sub
'***************************************************************
' Supporting Ball & Sound Functions v4.0
' includes random pitch in PlaySoundAt and PlaySoundAtBall
'***************************************************************
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 PlaySoundAt2(soundname, tableobj) 'play sound at X and Y position of an object with less random, like flippers
PlaySound soundname, 0, 1, Pan(tableobj), 0.05, 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 = 32 'max ball velocity
ReDim rolling(tnob)
InitRolling
Sub InitRolling
Dim i
For i = 0 to tnob
rolling(i) = False
Next
RollingTimer.Enabled = 1
End Sub
Sub RollingTimer_Timer()
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 = 1930
Next
' exit the sub if no balls on the table
If UBound(BOT) = lob - 1 Then Exit Sub 'there are no more balls on the playfield
' 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) ) * 5
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 & spin control
If BOT(b).VelX AND BOT(b).VelY <> 0 Then
BOT(b).AngMomZ = BOT(b).AngMomZ * 0.95
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
'*****************************
' 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 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 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
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
Bonus = 0
BonusMultiplier = 1
UpdateBallInPlay
' 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)
BonusMultiplier = 1
UpdateBonusXLights
' enciende las luces, reinicializa las variables del juego, etc
bExtraBallWonThisBall = False
ResetNewBallLights
ResetNewBallVariables
'This is a new ball, so activate the ballsaver
bBallSaverReady = True
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 / 2, 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 SoundFXDOF("fx_Ballrel", 104, DOFPulse, DOFContactors), BallRelease
'PlaySound"sfx_NewBall"
BallRelease.Kick 90, 4
' if there is 2 or more balls Then set the multibal flag (remember to check for locked balls and other balls used for animations)
' set the bAutoPlunger flag to kick the ball in play automatically
If BallsOnPlayfield> 1 Then
bMultiBallMode = True
bAutoPlunger = True
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
'and eject the first ball
CreateMultiballTimer_Timer
End Sub
' Eject the ball after the delay, AddMultiballDelay
Sub CreateMultiballTimer_Timer()
' wait if there is a ball in the plunger lane