forked from LegendsUnchained/vpx-standalone-alp4k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEvil Ded2 2022 verB.vbs
1186 lines (1002 loc) · 33.9 KB
/
Evil Ded2 2022 verB.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
'Iron Maiden by Stern 1981
'VPX table by JPSalas version 1.0.2
'Lights, solenoids & switch numbers and vpinmame parts of the script based on Destruk's script.
'Dip Switches by Inkochnito
'Iron Maiden / IPD No. 1270 / January, 1982 / 4 Players
Option Explicit
Randomize
' Flupper LUT code...
Dim luts, lutpos
' ****** LUT overall contrast & brightness setting **************************************************************************************
luts = array("Fleep Natural Dark 1", "Fleep Natural Dark 2", "Fleep Warm Dark", "Fleep Warm Bright", "Fleep Warm Vivid Soft", "Fleep Warm Vivid Hard", "Skitso Natural and Balanced", "Skitso Natural High Contrast", "3rdaxis Referenced THX Standard", "CalleV Punchy Brightness&Contrast", "HauntFreaks Desaturated", "Tomate Washed Out", "VPW Original 1 to 1", "Bassgeige", "Blacklight", "B&W Comic Book", "Evil Dead 2 Original")
Const EnableMagnasave = 1 ' 1 - on; 0 - off; if on then the magnasave button let's you rotate all LUT's
'*********************************************************************************************************************************
' end Flupper LUT code...
On Error Resume Next
ExecuteGlobal GetTextFile("controller.vbs")
If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
On Error Goto 0
LoadVPM "01210000", "STERN.VBS", 3.1
Dim bsTrough, dtL, dtT, dtC, bsSaucer, bsSaucer2, x
Const cGameName = "ironmaid"
Const UseSolenoids = 2
Const UseLamps = 0
Const UseGI = 0
Const UseSync = 0 'set it to 1 if the table runs too fast
Const HandleMech = 0
Dim VarHidden
If Table1.ShowDT = true then
VarHidden = 1
For each x in aReels
x.Visible = 1
Next
lrail.Visible = 1
rrail.Visible = 1
else
VarHidden = 0
For each x in aReels
x.Visible = 0
Next
lrail.Visible = 0
rrail.Visible = 0
end if
if B2SOn = true then VarHidden = 1
' Standard Sounds
Const SSolenoidOn = "fx_SolenoidOn"
Const SSolenoidOff = "fx_SolenoidOff"
Const SCoin = "fx_Coin"
'************
' Table init.
'************
Sub table1_Init
vpmInit me
With Controller
.GameName = cGameName
If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description:Exit Sub
.SplashInfoLine = "Evil Dead 2 (TBA 2019)" & vbNewLine & "VPX table by IVANTBA"
.HandleKeyboard = 0
.ShowTitle = 0
.ShowDMDOnly = 1
.ShowFrame = 0
.HandleMechanics = 0
.Hidden = 0
.Games(cGameName).Settings.Value("sound") = 0
'.SetDisplayPosition 0,0,GetPlayerHWnd 'uncomment if you can't see the dmd
On Error Resume Next
'Controller.SolMask(0) = 0
'vpmTimer.AddTimer 2000, "Controller.SolMask(0)=&Hffffffff'" 'ignore all solenoids - then add the Timer to renable all the solenoids after 2 seconds
Controller.Run GetPlayerHWnd
On Error Goto 0
End With
PlaySound "Intro",-0
Set bsTrough=New cvpmBallstack
bsTrough.InitSw 5,33,34,35,0,0,0,0
bsTrough.InitKick BallRelease,90,6
bsTrough.InitExitSnd SoundFX("fx_ballrel", DOFContactors), SoundFX("fx_Solenoid", DOFContactors)
bsTrough.Balls=3
Set dtL=New cvpmDropTarget
dtL.InitDrop Array(sw22,sw23,sw24),Array(22,23,24)
dtL.InitSnd SoundFX("", DOFDropTargets), SoundFX("fx_resetdrop", DOFContactors)
dtL.CreateEvents "dtL"
Set dtT=New cvpmDropTarget
dtT.InitDrop Array(sw21,sw20,sw19,sw18,sw17),Array(21,20,19,18,17)
dtT.InitSnd SoundFX("", DOFDropTargets), SoundFX("fx_resetdrop", DOFContactors)
dtT.CreateEvents "dtT"
Set dtC=New cvpmDropTarget
dtC.InitDrop Array(sw29,sw28,sw27,sw26,sw25),Array(29,28,27,26,25)
dtC.InitSnd SoundFX("", DOFDropTargets), SoundFX("fx_resetdrop", DOFContactors)
dtC.CreateEvents "dtC"
Set bsSaucer=New cvpmBallStack
bsSaucer.InitSaucer Kicker1, 36, 0, 40
bsSaucer.InitExitSnd SoundFX("fx_kicker", DOFContactors), SoundFX("fx_Solenoid", DOFContactors)
Set bsSaucer2=New cvpmBallStack
bsSaucer2.InitSaucer Kicker2, 37, 0, 40
bsSaucer2.InitExitSnd SoundFX("fx_kicker", DOFContactors), SoundFX("fx_Solenoid", DOFContactors)
vpmNudge.TiltSwitch=7
vpmNudge.Sensitivity=5
vpmNudge.TiltObj=Array(LeftSlingshot,RightSlingshot,RightSlingshot2)
' Main Timer init
PinMAMETimer.Interval = PinMAMEInterval
PinMAMETimer.Enabled = 1
' Turn on Gi
vpmtimer.addtimer 1500, "GiOn '"
' Flupper lut code..
table1.ColorGradeImage = luts(lutpos)
LoadLUT
SetLUT
End Sub
Sub table1_Paused:Controller.Pause = 1:End Sub
Sub table1_unPaused:Controller.Pause = 0:End Sub
Sub table1_exit:Controller.stop:End Sub
'**********
' Keys
'**********
Sub table1_KeyDown(ByVal Keycode)
If keycode = LeftTiltKey Then Nudge 90, 5:PlaySound SoundFX("fx_nudge", 0), 0, 1, -0.1, 0.25
If keycode = RightTiltKey Then Nudge 270, 5:PlaySound SoundFX("fx_nudge", 0), 0, 1, 0.1, 0.25
If keycode = CenterTiltKey Then Nudge 0, 6:PlaySound SoundFX("fx_nudge", 0), 0, 1, 0, 0.25
If keycode = RightMagnaSave and EnableMagnasave = 1 then
ResetRollingTextTimer
lutpos = lutpos + 1 : If lutpos > ubound(luts) Then lutpos = 0 : end if
call myChangeLut
playsound "LutChange"
End if
If keycode = LeftMagnaSave and EnableMagnasave = 1 then
ResetRollingTextTimer
lutpos = lutpos - 1 : If lutpos < 0 Then lutpos = ubound(luts) : end if
call myChangeLut
playsound "LutChange2"
end if
If vpmKeyDown(keycode)Then Exit Sub
If keycode = PlungerKey Then PlaySoundat "fx_PlungerPull",Plunger:Plunger.Pullback
'If keycode = KeyRules Then Rules
End Sub
Sub table1_KeyUp(ByVal Keycode)
If vpmKeyUp(keycode)Then Exit Sub
If keycode = PlungerKey Then PlaySoundAt "fx_plunger", Plunger:Plunger.Fire
End Sub
'*********
' Switches
'*********
' Slings
Dim LStep, RStep, RStep2
Sub LeftSlingShot_Slingshot
PlaySoundAt SoundFX("fx_slingshot", DOFContactors), Lemk
DOF 101, DOFPulse
LeftSling4.Visible = 1
Lemk.RotX = 26
LStep = 0
vpmTimer.PulseSw 9
LeftSlingShot.TimerEnabled = 1
End Sub
Sub LeftSlingShot_Timer
Select Case LStep
Case 1:LeftSLing4.Visible = 0:LeftSLing3.Visible = 1:Lemk.RotX = 14
Case 2:LeftSLing3.Visible = 0:LeftSLing2.Visible = 1:Lemk.RotX = 2
Case 3:LeftSLing2.Visible = 0:Lemk.RotX = -10:LeftSlingShot.TimerEnabled = 0
End Select
LStep = LStep + 1
End Sub
Sub RightSlingShot_Slingshot
PlaySoundAt SoundFX("fx_slingshot2", DOFContactors), Remk
DOF 102, DOFPulse
RightSling4.Visible = 1
Remk.RotX = 26
RStep = 0
vpmTimer.PulseSw 19
RightSlingShot.TimerEnabled = 1
End Sub
Sub RightSlingShot_Timer
Select Case RStep
Case 1:RightSLing4.Visible = 0:RightSLing3.Visible = 1:Remk.RotX = 14
Case 2:RightSLing3.Visible = 0:RightSLing2.Visible = 1:Remk.RotX = 2
Case 3:RightSLing2.Visible = 0:Remk.RotX = -10:RightSlingShot.TimerEnabled = 0
End Select
RStep = RStep + 1
End Sub
Sub RightSlingShot2_Slingshot
PlaySoundAt SoundFX("fx_slingshot3", DOFContactors), Remk
DOF 102, DOFPulse
r011.Visible = 1
Remk001.RotX = 26
RStep2 = 0
vpmTimer.PulseSw 11
RightSlingShot2.TimerEnabled = 1
End Sub
Sub RightSlingShot2_Timer
Select Case RStep2
Case 1:r011.Visible = 0:r010.Visible = 1:Remk001.RotX = 14
Case 2:r010.Visible = 0:r009.Visible = 1:Remk001.RotX = 2
Case 3:r009.Visible = 0:Remk001.RotX = -10:RightSlingShot.TimerEnabled = 0
End Select
RStep2 = RStep2 + 1
End Sub
'**********
' Music
'**********
'Start the music
DIM music
music = "Evil Dead 2 Soundtrack.mp3"
PlayMusic "Evil Dead 2 Soundtrack.mp3"
Sub Table1_MusicDone()
PlayMusic "Evil Dead 2 Soundtrack.mp3"
End Sub
' Bumpers
' Scoring rubbers
' Drain & holes
Sub Drain_Hit:PlaysoundAt "fx_drain",Drain:bsTrough.AddBall Me:End Sub
Sub kicker1_Hit:PlaysoundAt "fx_kicker_enter", kicker1:bsSaucer.AddBall 0:End Sub
Sub kicker2_Hit:PlaysoundAt "fx_kicker_enter2", kicker2:bsSaucer2.AddBall 0:End Sub
' Rollovers
Sub sw38_Hit:Controller.Switch(38) = 1:PlaySoundAt "fx_sensor",sw38:End Sub
Sub sw38_UnHit:Controller.Switch(38) = 0:End Sub
Sub sw39_Hit:Controller.Switch(39) = 1:PlaySoundAt "fx_sensor2",sw39:End Sub
Sub sw39_UnHit:Controller.Switch(39) = 0:End Sub
Sub sw40_Hit:Controller.Switch(40) = 1:PlaySoundAt "fx_sensor3",sw40:End Sub
Sub sw40_UnHit:Controller.Switch(40) = 0:End Sub
Sub sw38a_Hit:Controller.Switch(38) = 1:PlaySoundAt "fx_sensor4",sw38:End Sub
Sub sw38a_UnHit:Controller.Switch(38) = 0:End Sub
Sub sw39a_Hit:Controller.Switch(39) = 1:PlaySoundAt "fx_sensor5",sw39:End Sub
Sub sw39a_UnHit:Controller.Switch(39) = 0:End Sub
Sub sw40a_Hit:Controller.Switch(40) = 1:PlaySoundAt "fx_sensor6",sw40:End Sub
Sub sw40a_UnHit:Controller.Switch(40) = 0:End Sub
'Spinners
Sub Spinner1_Spin():vpmTimer.PulseSw 4:PlaySoundAt "fx_spinner", Spinner1:End Sub
' Droptargets
Sub sw17_Hit:PlaySoundAt SoundFX("fx_droptarget", DOFDropTargets),sw17:End Sub
Sub sw18_Hit:PlaySoundAt SoundFX("fx_droptarget2", DOFDropTargets),sw18:End Sub
Sub sw19_Hit:PlaySoundAt SoundFX("fx_droptarget3", DOFDropTargets),sw19:End Sub
Sub sw20_Hit:PlaySoundAt SoundFX("fx_droptarget4", DOFDropTargets),sw20:End Sub
Sub sw21_Hit:PlaySoundAt SoundFX("fx_droptarget5", DOFDropTargets),sw21:End Sub
Sub sw22_Hit:PlaySoundAt SoundFX("fx_droptarget6", DOFDropTargets),sw22:End Sub
Sub sw23_Hit:PlaySoundAt SoundFX("fx_droptarget7", DOFDropTargets),sw23:End Sub
Sub sw24_Hit:PlaySoundAt SoundFX("fx_droptarget8", DOFDropTargets),sw24:End Sub
Sub sw25_Hit:PlaySoundAt SoundFX("fx_droptarget9", DOFDropTargets),sw25:End Sub
Sub sw26_Hit:PlaySoundAt SoundFX("fx_droptarget10", DOFDropTargets),sw26:End Sub
Sub sw27_Hit:PlaySoundAt SoundFX("fx_droptarget11", DOFDropTargets),sw27:End Sub
Sub sw28_Hit:PlaySoundAt SoundFX("fx_droptarget12", DOFDropTargets),sw28:End Sub
Sub sw29_Hit:PlaySoundAt SoundFX("fx_droptarget13", DOFDropTargets),sw29:End Sub
'Targets
Sub sw12_Hit:vpmTimer.PulseSw 12:PlaySoundAtBall SoundFX("fx_target", DOFDropTargets):End Sub
Sub sw13_Hit:vpmTimer.PulseSw 13:PlaySoundAtBall SoundFX("fx_target2", DOFDropTargets):End Sub
Sub sw14_Hit:vpmTimer.PulseSw 14:PlaySoundAtBall SoundFX("fx_target3", DOFDropTargets):End Sub
Sub sw15_Hit:vpmTimer.PulseSw 15:PlaySoundAtBall SoundFX("fx_target4", DOFDropTargets):End Sub
Sub sw16_Hit:vpmTimer.PulseSw 16:PlaySoundAtBall SoundFX("fx_target5", DOFDropTargets):End Sub
Sub sw30_Hit:vpmTimer.PulseSw 30:PlaySoundAtBall SoundFX("fx_target6", DOFDropTargets):End Sub
Sub sw31_Hit:vpmTimer.PulseSw 31:PlaySoundAtBall SoundFX("fx_target7", DOFDropTargets):End Sub
Sub sw32_Hit:vpmTimer.PulseSw 32:PlaySoundAtBall SoundFX("fx_target8", DOFDropTargets):End Sub
'*********
'Solenoids
'*********
SolCallback(4)="Sol4"
SolCallback(5)="Sol5"
SolCallback(6)="vpmSolSound SoundFX(""fx_Knocker"",DOFKnocker),"
SolCallback(8)="SolOutHole"
SolCallback(9)="dtT.SolDropUp"
SolCallback(10)="dtC.SolDropUp"
SolCallback(11)="dtL.SolDropUp"
SolCallback(12)="SolBallRelease"
SolCallback(17)="SolBallMem"
SolCallback(18)="SolLock"
SolCallback(19)="vpmNudge.SolGameOn"
SolCallback(20)="vpmSolDiverter Diverter3,True,"
Sub Sol4(Enabled) 'bsSaucer
If Enabled Then
bsSaucer.ExitSol_On
Remk002F.RotateToEnd
vpmtimer.Addtimer 200, "Remk002F.RotateToStart '"
End If
End Sub
Sub Sol5(Enabled) 'bsSaucer2
If Enabled Then
bsSaucer2.ExitSol_On
Remk003F.RotateToEnd
vpmtimer.Addtimer 200, "Remk003F.RotateToStart '"
End If
End Sub
Sub SolOutHole(Enabled)
If Enabled Then
bsTrough.EntrySol_On
End If
End Sub
Sub SolBallRelease(Enabled)
If Enabled Then
RightLockTimer.Enabled=0 'used for workaround routines at end of script
If LockBalls+bsTrough.Balls=3 Then bsTrough.ExitSol_On
Controller.Switch(8)=0 'used for workaround routines at end of script
End If
End Sub
'lock
Dim LockBalls
LockBalls=0
Sub lock3_Hit:Controller.Switch(8)=1:LockBalls=LockBalls+1:End Sub
Sub lock3_unHit:Controller.Switch(8)=0:End Sub
Sub lock2_Hit:Controller.Switch(8)=1:End Sub
Sub lock2_unHit:Controller.Switch(8)=0:End Sub
Sub lock1_Hit:Controller.Switch(8)=1:End Sub
Sub lock1_unHit:Controller.Switch(8)=0:End Sub
Sub lockexit_Hit
LockBalls=LockBalls-1
If LockBalls=0 Then
lock1k.Enabled=1
lock2k.Enabled=0
lock3k.Enabled=0
End If
End Sub
Sub SolBallMem(Enabled)
If Enabled Then
If LockBalls=3 Then
RightLockTimer.Enabled=1 'Delay Check
End If
Controller.Switch(8)=0
End If
End Sub
Sub RightLockTimer_Timer
Me.Enabled=0
lock1k.Kick 225,2
lock2k.Kick 225,2
lock3k.Kick 225,2
End Sub
Sub lock1k_Hit:Me.Enabled=0:lock2k.Enabled=1:End Sub
Sub lock2k_Hit:Me.Enabled=0:lock3k.Enabled=1:End Sub
Sub lock3k_Hit
Dim LockLights
LockLights=0
If Li5.State>0 Then LockLights=LockLights+1
If Li37.State>0 Then LockLights=LockLights+1
If Li21.State>0 Then LockLights=LockLights+1
If Li53.State>0 Then LockLights=LockLights+1
If Li26.State>0 Then LockLights=LockLights+1
If Li10.State>0 Then LockLights=LockLights+1
If Li9.State>0 Then LockLights=LockLights+1
If Li41.State>0 Then LockLights=LockLights+1
If Li25.State>0 Then LockLights=LockLights+1
If Li57.State>0 Then LockLights=LockLights+1
If LockLights=10 Then
lock3k.Enabled=0
lock2k.Enabled=0
lock1k.Enabled=0
Else
lock1k.Enabled=1
lock2k.Enabled=0
lock3k.Enabled=0
End If
Me.Enabled=0
End Sub
' Upperpf diverters
Sub SolLock(Enabled)
If Enabled Then
Diverter1.RotateToEnd
Diverter2.RotateToEnd
Else
Diverter1.RotateToStart
Diverter2.RotateToStart
End If
End Sub
'**************
' Flipper Subs
'**************
SolCallback(sLRFlipper) = "SolRFlipper"
SolCallback(sLLFlipper) = "SolLFlipper"
Sub SolLFlipper(Enabled)
If Enabled Then
PlaySoundAt SoundFX("fx_flipperup", DOFFlippers), LeftFlipper
LeftFlipper.RotateToEnd
LeftFlipper1.RotateToEnd
Else
PlaySoundAt SoundFX("fx_flipperdown", DOFFlippers), LeftFlipper
LeftFlipper.RotateToStart
LeftFlipper1.RotateToStart
End If
End Sub
Sub SolRFlipper(Enabled)
If Enabled Then
PlaySoundAt SoundFX("fx_flipperup", DOFFlippers), RightFlipper
RightFlipper.RotateToEnd
RightFlipper1.RotateToEnd
Else
PlaySoundAt SoundFX("fx_flipperdown", DOFFlippers), RightFlipper
RightFlipper.RotateToStart
RightFlipper1.RotateToStart
End If
End Sub
Sub LeftFlipper_Collide(parm)
PlaySound "fx_rubber_flipper", 0, parm / 10, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
End Sub
Sub RightFlipper_Collide(parm)
PlaySound "fx_rubber_flipper", 0, parm / 10, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
End Sub
'*****************
' Gi Effects
'*****************
Dim OldGiState
OldGiState = -1 'start witht he Gi off
Sub SolGi(enabled)
If enabled Then
GiOff
Else
GiOn
End If
End Sub
Sub GiON
For each x in aGiLights
x.State = 1
Next
End Sub
Sub GiOFF
For each x in aGiLights
x.State = 0
Next
End Sub
Sub GiEffect(enabled)
If enabled Then
For each x in aGiLights
x.Duration 2, 1000, 1
Next
End If
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
'************************************
' Game timer for real time updates
'(some tables may use it's own timer)
'************************************
Set MotorCallback = GetRef("RealTimeUpdates")
Sub RealTimeUpdates
RollingUpdate
Remk002.Rotx = Remk002F.CurrentAngle
Remk003.Rotx = Remk003F.CurrentAngle
End Sub
'**********************************************************
' JP's Flasher Fading for VPX and Vpinmame
' (Based on Pacdude's Fading Light System)
' This is a fast fading for the Flashers in vpinmame tables
' just 4 steps, like in Pacdude's original script.
' Included the new Modulated flashers & Lights for WPC
'**********************************************************
Dim LampState(200), FadingState(200), FlashLevel(200)
InitLamps() ' turn off the lights and flashers and reset them to the default parameters
' vpinmame Lamp & Flasher Timers
Sub LampTimer_Timer()
Dim chgLamp, num, chg, ii
chgLamp = Controller.ChangedLamps
If Not IsEmpty(chgLamp)Then
For ii = 0 To UBound(chgLamp)
LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
FadingState(chgLamp(ii, 0)) = chgLamp(ii, 1) + 3 'fading step
Next
End If
UpdateLeds
UpdateLamps
End Sub
Sub UpdateLamps()
Lamp 1, li1
Lamp 2, li2
Lamp 3, li3
Lamp 4, li4
Lampm 5, li29
Lamp 5, li5
Lamp 6, li6
Lamp 7, li7
Lamp 8, li8
Lampm 9, li47
Lamp 9, li9
Lampm 10, li48
Lamp 10, li10
'Textm 11, li11a, "Shoot Again"
Lamp 11, li11
Lamp 12, li12
'Text 13, li13, "High Score to date" '"Ball in Play"
Lamp 14, li14
Lamp 15, li15
Lamp 17, li17
Lamp 18, li18
Lamp 19, li19
Lamp 20, li20
Lampm 21, li67
Lamp 21, li21
Lamp 22, li22
Lamp 23, li23
Lamp 24, li24
Lampm 25, li65
Lamp 25, li25
Lampm 26, li66
Lamp 26, li26
Lamp 27, li27
Lamp 28, li28
Lamp 30, li30
Lamp 31, li31
Lamp 33, li33
Lamp 34, li34
Lamp 35, li35
Lamp 36, li36
Lampm 37, li68
Lamp 37, li37
Lamp 38, li38
Lamp 39, li39
Lamp 40, li40
Lampm 41, li64
Lamp 41, li41
Lampm 42, li42a
Lamp 42, li42
Lamp 43, li43
Lamp 44, li44
'Text 45, li45, "Game Over"
Lamp 46, li46
Lamp 49, li49
Lamp 50, li50
Lamp 51, li51
Lamp 52, li52
Lampm 53, li16
Lamp 53, li53
Lamp 54, li54
Lamp 55, li55
Lamp 56, li56
Lampm 57, li32
Lamp 57, li57
Lamp 58, li58
Lamp 59, li59
Lamp 60, li60
'Text 61, li61, "TILT"
Lamp 62, li62
'Text 63, li63, "Match"
End Sub
' div lamp subs
' Normal Lamp & Flasher subs
Sub InitLamps()
Dim x
LampTimer.Interval = 25 ' flasher fading speed
LampTimer.Enabled = 1
For x = 0 to 200
FadingState(x) = 3 ' used to track the fading state
FlashLevel(x) = 0
Next
End Sub
Sub SetLamp(nr, value) ' 0 is off, 1 is on
FadingState(nr) = abs(value) + 3
End Sub
' Lights: used for VPX standard lights, the fading is handled by VPX itself, they are here to be able to make them work together with the flashers
Sub Lamp(nr, object)
Select Case FadingState(nr)
Case 4:object.state = 1:FadingState(nr) = 0
Case 3:object.state = 0:FadingState(nr) = 0
End Select
End Sub
Sub Lampm(nr, object) ' used for multiple lights, it doesn't change the fading state
Select Case FadingState(nr)
Case 4:object.state = 1
Case 3:object.state = 0
End Select
End Sub
' Flashers: 4 is on,3,2,1 fade steps. 0 is off
Sub Flash(nr, object)
Select Case FadingState(nr)
Case 4:Object.IntensityScale = 1:FadingState(nr) = 0
Case 3:Object.IntensityScale = 0.66:FadingState(nr) = 2
Case 2:Object.IntensityScale = 0.33:FadingState(nr) = 1
Case 1:Object.IntensityScale = 0:FadingState(nr) = 0
End Select
End Sub
Sub Flashm(nr, object) 'multiple flashers, it doesn't change the fading state
Select Case FadingState(nr)
Case 4:Object.IntensityScale = 1
Case 3:Object.IntensityScale = 0.66
Case 2:Object.IntensityScale = 0.33
Case 1:Object.IntensityScale = 0
End Select
End Sub
' Desktop Objects: Reels & texts (you may also use lights on the desktop)
' Reels
Sub Reel(nr, object)
Select Case FadingState(nr)
Case 4:object.SetValue 1:FadingState(nr) = 0
Case 3:object.SetValue 2:FadingState(nr) = 2
Case 2:object.SetValue 3:FadingState(nr) = 1
Case 1:object.SetValue 0:FadingState(nr) = 0
End Select
End Sub
Sub Reelm(nr, object)
Select Case FadingState(nr)
Case 4:object.SetValue 1
Case 3:object.SetValue 2
Case 2:object.SetValue 3
Case 1:object.SetValue 0
End Select
End Sub
'Texts
Sub Text(nr, object, message)
Select Case FadingState(nr)
Case 4:object.Text = message:FadingState(nr) = 0
Case 3:object.Text = "":FadingState(nr) = 0
End Select
End Sub
Sub Textm(nr, object, message)
Select Case FadingState(nr)
Case 4:object.Text = message
Case 3:object.Text = ""
End Select
End Sub
' Modulated Subs for the WPC tables
Sub SetModLamp(nr, level)
FlashLevel(nr) = level / 150 'lights & flashers
End Sub
Sub LampMod(nr, object) ' modulated lights used as flashers
Object.IntensityScale = FlashLevel(nr)
Object.State = 1 'in case it was off
End Sub
Sub FlashMod(nr, object) 'sets the flashlevel from the SolModCallback
Object.IntensityScale = FlashLevel(nr)
End Sub
'Walls and mostly Primitives used as 4 step fading lights
'a,b,c,d are the images used from on to off
Sub FadeObj(nr, object, a, b, c, d)
Select Case FadingState(nr)
Case 4:object.image = a:FadingState(nr) = 0 'fading to off...
Case 3:object.image = b:FadingState(nr) = 2
Case 2:object.image = c:FadingState(nr) = 1
Case 1:object.image = d:FadingState(nr) = 0
End Select
End Sub
Sub FadeObjm(nr, object, a, b, c, d)
Select Case FadingState(nr)
Case 4:object.image = a
Case 3:object.image = b
Case 2:object.image = c
Case 1:object.image = d
End Select
End Sub
Sub NFadeObj(nr, object, a, b)
Select Case FadingState(nr)
Case 4:object.image = a:FadingState(nr) = 0 'off
Case 3:object.image = b:FadingState(nr) = 0 'on
End Select
End Sub
Sub NFadeObjm(nr, object, a, b)
Select Case FadingState(nr)
Case 4:object.image = a
Case 3:object.image = b
End Select
End Sub
'Modulated lights & Flashers
Sub SetModLamp(nr, level)
FlashLevel(nr) = level /150 'lights & flashers
End Sub
Sub LightMod(nr, object) ' modulated lights used as flashers
Object.IntensityScale = FlashLevel(nr)
Object.State = 1
End Sub
Sub FlashMod(nr, object) 'sets the flashlevel from the SolModCallback
Object.IntensityScale = FlashLevel(nr)
End Sub
'************************************
' LEDs Display
' Based on Scapino's LEDs
'************************************
Dim Digits(32)
Dim Patterns(11)
Dim Patterns2(11)
Patterns(0) = 0 'empty
Patterns(1) = 63 '0
Patterns(2) = 6 '1
Patterns(3) = 91 '2
Patterns(4) = 79 '3
Patterns(5) = 102 '4
Patterns(6) = 109 '5
Patterns(7) = 125 '6
Patterns(8) = 7 '7
Patterns(9) = 127 '8
Patterns(10) = 111 '9
Patterns2(0) = 128 'empty
Patterns2(1) = 191 '0
Patterns2(2) = 134 '1
Patterns2(3) = 219 '2
Patterns2(4) = 207 '3
Patterns2(5) = 230 '4
Patterns2(6) = 237 '5
Patterns2(7) = 253 '6
Patterns2(8) = 135 '7
Patterns2(9) = 255 '8
Patterns2(10) = 239 '9
'Assign 7-digit output to reels
'Set Digits(0) = a0
'Set Digits(1) = a1
'Set Digits(2) = a2
'Set Digits(3) = a3
'Set Digits(4) = a4
'Set Digits(5) = a5
'Set Digits(6) = a6
'Set Digits(7) = b0
'Set Digits(8) = b1
'Set Digits(9) = b2
'Set Digits(10) = b3
'Set Digits(11) = b4
'Set Digits(12) = b5
'Set Digits(13) = b6
'Set Digits(14) = c0
'Set Digits(15) = c1
'Set Digits(16) = c2
'Set Digits(17) = c3
'Set Digits(18) = c4
'Set Digits(19) = c5
'Set Digits(20) = c6
'Set Digits(21) = d0
'Set Digits(22) = d1
'Set Digits(23) = d2
'Set Digits(24) = d3
'Set Digits(25) = d4
'Set Digits(26) = d5
'Set Digits(27) = d6
'Set Digits(28) = e0
'Set Digits(29) = e1
'Set Digits(30) = e2
'Set Digits(31) = e3
Sub UpdateLeds
On Error Resume Next
Dim ChgLED, ii, jj, chg, stat
ChgLED = Controller.ChangedLEDs(&HFF, &HFFFF)
If Not IsEmpty(ChgLED)Then
For ii = 0 To UBound(ChgLED)
chg = chgLED(ii, 1):stat = chgLED(ii, 2)
For jj = 0 to 10
If stat = Patterns(jj)OR stat = Patterns2(jj)then Digits(chgLED(ii, 0)).SetValue jj
Next
Next
End IF
End Sub
'******************************
' Diverse Collection Hit Sounds
'******************************
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
' *********************************************************************
' Supporting Ball & Sound Functions
' *********************************************************************
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, 0, 0, 0, AudioFade(tableobj)
End Sub
Sub PlaySoundAtBall(soundname) ' play a sound at the ball position, like rubbers, targets
PlaySound soundname, 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
End Sub
'*****************************************
' JP's VP10 Rolling Sounds
'*****************************************
'********************************************
' JP's VP10 Rolling Sounds + Ballshadow
' uses a collection of shadows, aBallShadow
'********************************************
Const tnob = 20 ' total number of balls
Const lob = 0 'number of locked balls
ReDim rolling(tnob)
InitRolling
Sub InitRolling
Dim i
For i = 0 to tnob
rolling(i) = False
Next
End Sub
Sub RollingUpdate()
Dim BOT, b, ballpitch, ballvol
BOT = GetBalls
' stop the sound of deleted balls
For b = UBound(BOT) + 1 to tnob
rolling(b) = False
StopSound("fx_ballrolling" & b)
Next
' exit the sub if no balls on the table
If UBound(BOT) = lob - 1 Then Exit Sub 'there no extra balls on this table
' play the rolling sound for each ball and draw the shadow
For b = lob to UBound(BOT)
aBallShadow(b).X = BOT(b).X
aBallShadow(b).Y = BOT(b).Y
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) ) + 25000 '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
Next
End Sub
'**********************