-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.vbs
12178 lines (10709 loc) · 411 KB
/
main.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
' Allknowing2012 - Please dont redistribute at this time...
' 2021 - Stay Safe Everyone
' v0.01 Alpha
' My Channel: https://www.youtube.com/channel/UCi9jCs_DmgtHWqLVPf5_7rA
' BallSaver
' highscores
' skillshot and super Skillshotplayer
' special and extraball show the awards
' danger and tilt
' TESTING
' PuPlayer.playlistplayex 5,"PupVideos","ARS107-Scene-99.mp4",0,1
' pOverVid 13
' Pup5 15
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
' X X X X X X X X X X X X X X X X X X X X X X X
' MODES
' Toys - ..seems to be the toy box multiball
' Love -
' Rats - Center Ramp (f), Toys and L/R Card-Orbit - Super Spinner
' Dude - Center, Elevator - Super Lanes
' Back - Right Orbit (f) - Super Pops 50 hits 275K each
' Sweet - Jester,Elevator,L (f) /R Lock Balls - Super Scoring
' Walk - Center (f)/Right Ramp (f) - Super Ramps
' Same - Elevator (f) (then both L/R Target banks) - Super Targets
' Last - Center/ Left (f) & Right Orbit (f) - Super Orbits
'
' 1 hit flashes the toy box light, then If you sink it changes solid .. -- Done
' -- gets harder in later levels -
' shoot box to light lock (green) then it can be thrown in to box - Done
' Shoot any shot to light crank it up, then score it to add 20s & 500K -- Done
' shoot left & right of toybox to light VIP Pass (ball Save) - done
' can abort 3 ball multiball - 3 second countdown BEFORE you throw the ball -- done
' spell aer-os-mith to get PF multiplier
' 3 dude lights increases bonus multiplier - done
' After Mode show Mode Total, light up all shots - get a shot to give the award
' Super pops max 30 pops at 275K each
' jester icons on dmd - count down to 0 to light extra ball - award the jester at random at NON lit Shot - Done
' number below coins is the number of pop bumper hits needed to increase to next level - starts at 25
' number below that is total score from last pop bumper hit - quite small
' number below jester is spins needed to increase spinner value starts at 50?
' number below is total score from last spinner shot made - quite small - starts at 50?
' ramp sounds -- todo
' aerosmith targets -- once lit, next hits should just 1 time blink the lights
' toybox - each hit lights a blinking green light, in the box turns it green, -- done
' 2nd mb takes multiple hits to get light to blink, If there is eon flashing then light LOCK on the kicker
' get the 2nd elevator light .. show elevator clipo with ELEVATOR LIT, lights the door in front of eleator - done
' verify the elevator stacks -- nope
' BALL 1 LOCKED 0 to 1 clip -- done
' when mode is done (or perhaps timed out) .. you see Shots are lit animation, Xs on pf are blinking..
' then next shot that is hit it shows 2x for that show animation and the correspnding X on pf is solid
' getting that shot awards the SUPER award for that mode, shots are OFF during this..
' choose song is flashing at CIU
' SAME is a long 50s to start .. when ball save ended..? -- done
' when you get AEROSMITH .. you see Shots are lit animation, Xs on pf are blinking.. , next shot awrds that X 2x shot value
' dude each ramp is 500k and inmation of a dancer
' Sweet Emotion - Rules - https://youtu.be/cngJExYCD6U?t=6330
'
' Notes:
'PUPOverlays you put 32bit pngs in there and when you play them it will set them as current overlay frame.
'PUPFrames you put 32bit pngs in there and when you play them it will set the background png (good for performance)
'PUPAlphas you put 32bit pngs in there and when you play them it will set them as current overlay frame with alpha blending (performance, v1.4.5+)
'PuPShapes you put 24bit bmps files in there and the pixel color (0,0) will be used as a mask to make a see=through shape. See twister puppack for example.
Option Explicit
Randomize
Const bUsePlungerForSternKey = False ' Defaults to Right Magna Button but you can use Plunger button also
Const kBallSearchTimeout = 15000 ' Start ball search after 15 seconds of no activity
Const DMDMode = 2 ' 0=None, 1 = Flex/Ultra, 2=PUP (make sure you set PuPDMDDriverType below)
Const doCallouts = False ' Play random callouts during the game
Const bFlipperSkipEnabled = True ' Skip scenes
Const FontScale = 1 ' Scales the PupFonts up/down for different sized DMDs [Desktop 0.75]
Const FontScaleDmd = 0.5 ' Scales the SlimDMDFonts up/down for different sized DMDs [Desktop 0.5]
Const osbactive = 0 ' Orbital Scoreboard: Set to 0 for off, 1 for only player 1 to be sent, 2 for all scores to be sent.
' See link to create obs.vbs: https://docs.orbitalpin.com/vpx-user-settings
Dim AutoQA:AutoQa=False 'Main QA Testing FLAG setting to false will disable all this stuff.
Dim AutoAI:AutoAI=True :debugWall2.IsDropped=False:DebugWall1.IsDropped=False
'Dim AutoAI:AutoAI=True :debugWall2.IsDropped=True:debugWall1.IsDropped=True
'Dim AutoAI:AutoAI=False
'AutoQA=True
If AutoAI then TurnOnAI
Dim shotval
Dim shotvalRight
Const bHardMode=False ' Hard Same -- Same Old Song and Dance - Aerosmith lights come in after CIU
' -- mode is 30s with CIU of another 20s
Const DigitFont="DIGIT LCD"
Const DMDScrFont="Donnie Solid Narrow" ' "Impact"
Const DMDMainFont="Donnie Solid Narrow"
'**************************
' UltraDMD USER Config
'**************************
Const UseFullColor = "True" ' ULTRA: Enable full Color on UltraDMD "True" / "False"
Const UltraDMDVideos = True ' ULTRA: Works on my DMDv3 but seems it causes issues on others
'**************************
' PinUp Player USER Config
'**************************
dim PuPDMDDriverType: PuPDMDDriverType=0 ' 0=LCD DMD, 1=RealDMD (For FULLDMD use the batch scripts in the pup pack)
dim useRealDMDScale : useRealDMDScale=0 ' 0 or 1 for RealDMD scaling. Choose which one you prefer.
dim useDMDVideos : useDMDVideos=True ' true or false to use DMD splash videos.
Dim pGameName : pGameName="aerosmith" ' pupvideos foldername, probably set to cGameName in realworld
'***********TABLE VOLUME LEVELS *********
' [Value is from 0 to 1 where 1 is full volume.
' NOTE: you can go past 1 to amplify sounds]
Const VolBGMusic = 0.9 ' Volume for Video Clips
Const VolDef = 0.8 ' Default volume for callouts
Const VolSfx = 0.6 ' Volume for table Sound effects
' VolumeDial:
' VolumeDial is the actual global volume multiplier for the mechanical sounds.
' Values smaller than 1 will decrease mechanical sounds volume.
' Recommended values should be no greater than 1.
Const VolumeDial = 0.8
Const BallSize = 50 ' 50 is the normal size
Const BallMass = 1.0 ' 1 is normal ball
'********* UltraDMD **************
Dim UltraDMD:UltraDMD=0
Const UltraDMD_VideoMode_Stretch = 0
Const UltraDMD_VideoMode_Top = 1
Const UltraDMD_VideoMode_Middle = 2
Const UltraDMD_VideoMode_Bottom = 3
Const UltraDMD_Animation_FadeIn = 0
Const UltraDMD_Animation_FadeOut = 1
Const UltraDMD_Animation_ZoomIn = 2
Const UltraDMD_Animation_ZoomOut = 3
Const UltraDMD_Animation_ScrollOffLeft = 4
Const UltraDMD_Animation_ScrollOffRight = 5
Const UltraDMD_Animation_ScrollOnLeft = 6
Const UltraDMD_Animation_ScrollOnRight = 7
Const UltraDMD_Animation_ScrollOffUp = 8
Const UltraDMD_Animation_ScrollOffDown = 9
Const UltraDMD_Animation_ScrollOnUp = 10
Const UltraDMD_Animation_ScrollOnDown = 11
Const UltraDMD_Animation_None = 14
Const UltraDMD_deOn = 1500
'********* End UltraDMD **************
Const BlinkIntFast = 70
Const BlinkIntDef = 125
Const BlinkIntSlow = 500
Const BlinkPatternDef = 10
Const BlinkPatternSlow = 100
Dim luts, lutpos
luts = array("ColorGradeLUT256x16_1to1", "ColorGradeLUT_Bright2", "ColorGradeLUT_Bright", "ColorGradeLUT256x16_ConSat", "ColorGradeLUT256x16_HalfSat" )
lutpos = 0
' Main Code
Dim bDebugMode:bDebugMode = False ' Magna buttons perform debug functions
' Define any Constants
Const cGameName = "aerosmith" ' Match DOF Config Tool
Const TableName = "aerosmith"
Const myVersion = "1.0.0"
Const MaxPlayers = 4
Dim MusicDir
'*****************************************
' Structure to save/restore all player data before moving to a new ones
' ***************************************
Const kStack_Pri0 = 0 ' base mode
Const kStack_Pri1 = 1 ' toybox, elevator mb
Const kStack_Pri2 = 2 ' wizard
Const kStack_Pri3 = 3 ' Skillshot
Class cArrowState
Public ArrowColor
Public ArrowState
Public MultipState
Public NameState
End Class
' Define Global Variables
Dim PlayersPlayingGame
Dim CurrentPlayer
Dim Credits
Dim BonusPoints(4)
Dim BonusHeldPoints(4)
Dim BonusMultiplier
Dim PlayMultiplier
Dim ModePoints
Dim ModePointsSave
Dim WizardModePoints
Dim WizardBonusPoints
Dim bBonusHeld
Dim BallsRemaining(4)
Dim ExtraBallsAwards(4)
Dim Score(4)
Dim HighScore(5) ' GC, 1,2,3, Med-GC
Dim HighScoreName(5)
Dim TiltCount(4)
Dim Jackpot
Dim VipValue
Dim Tilt
Dim TiltSensitivity
Dim Tilted
Dim TotalGamesPlayed
Dim mBalls2Eject
Dim SkillshotValue
Dim bCreatedBall ' we just created a ball
Dim bAutoPlunger ' Auto fire
Dim bAutoPlunged ' Did AutoPlunger Fire
Dim bInstantInfo
Dim BumperMultiplier
dim bLaneSaverEnabled
Dim FlipperSkipCmd ' Command to when you FlipperSkip
Dim VolMusic
Dim BallSearchCnt
Dim bResetCurrentGame
Dim SongNum
Dim ModeCountdown
Dim modeRampColor
Dim bDebounce
Dim bPauseTimer
Dim Multiplier3x
Dim baLightsSaved
Dim baSaveLightsSaved
Dim baRampLightsSaved
Dim bShotMultiplierSelect
Dim modesStarted
Dim ModesCompleted
Dim bFinalTourDone
Dim bFinalTourReady
Dim bFinalTourCount
Dim bMedleyTourProgress(8) '
Dim bMedleyTourDone
Dim bMedleyTourReady ' ready to start - progressed thru the prior modes
Dim bMedleyTourCount ' how many tour modes completed
Dim Coins
Dim HiddenJesters
Dim Dice
Dim SpinHits
Dim SpinScore
Dim SpinScoreCurrent
Dim SpinValue
Dim SpinnerBonus
Dim TargetBonus
Dim BumperBonus
Dim LoopBonus
Dim RampBonus
Dim LaneBonus
Dim PopHits
Dim PopScore
Dim PopScoreCurrent
Dim PopValue
Dim PopLevel
Dim SwitchHitCount
Dim BonusModeTotal(8) ' Holds the total bonus during gameplay
Dim BonusModeValue(8) ' Holds the bonus value that will get added to the next mode bonus
Dim ModeNames(8)
Dim ModeNamesShort(8)
Dim Shots(8)
Dim ModeProgress(8)
Dim ModeOrder(8) ' retain what order they were attempted in as this is used in the Medely/Final Tour
Dim ModePercent(8)
dim Mode2Percent(8)
dim Mode2Progress(8)
Dim Mode2Value(8)
Dim Mode2Total(8)
Dim bModeProgressUpgraded
Dim ToyBoxMBFinished ' Did we complete ToyBoxMB
Dim ToyBoxMultiBallCount ' How many times have we completed ToyBox MB
Dim ToyBoxMBLocks ' How many ToyBox Locks we have done during this toybox MB. We can only lock it a total of 3 times in MB
Dim ToyBoxMultiBallToggle
Dim ToyBoxMBJackpotHits
Dim ToyBoxMBJackpot
Dim ToyBoxMBJackpotBase
Dim ToyBoxMBJackpotTotal
Dim ToyBoxMBAttempts
Dim bToyBoxBonus3x
Dim EndToyBoxMB
Dim ElevTarget1Toggle
Dim ElevMultiBallCount ' How many times have we completed elevator MB
Dim ElevMBJackpotHits
Dim ElevMBJackpot
Dim ElevMBJackpotTotal
Dim bElevMultiBall
' Define Game Control Variables
Dim LastSwitchHit
Dim BallsOnPlayfield
Dim RealBallsInLock
Dim SpellAerosmith
Dim MultiplierShot
Dim bShotMultiplier
Dim bSecondMode
Dim bBonusMode
Dim PlayerMode2
Dim bWizardMode
' Define Game Flags
Dim bFreePlay
Dim bGameInPlay
Dim bOnTheFirstBall
Dim bBallInPlungerLane
Dim bBallSaverActive
Dim BallSaverActiveBuffer ' Allows lanes to kick in ball saver
Dim bBallSaverReady
Dim bMultiBallMode
Dim bMusicOn
dim SuperSkillShotIndex
Dim bSkillshotsReady(2)
Dim bPlayerModeSelect
Dim PlayerMode
Dim SaveMode
Dim bRndModeShot
Dim bExtraBallWonThisBall
Dim bJustStarted
Dim bSkipWaitVideo
Dim plungerIM 'used mostly as an autofire plunger
Dim SmartButtonCount
Dim bTableReady
Dim bUseUltraDMD
Dim bUsePUPDMD
Dim bPupStarted
Dim sndGeneralHit
Dim PlayerState(5)
Dim RampLightsSaveColor()
Dim LightsSaveColor()
Dim saveColor()
Const defBallSaverTime = 8 ' In seconds
Dim BallSaverTime
BallSaverTime = defBallSaverTime
Const BallsPerGame = 3 ' 3 or 5
Const MaxMultiballs = 5 ' max number of balls during multiballs
Const MaxMultiplier=9
'***************************************************************************
' Structure to save/restore all player data before moving to a new ones
' **************************************************************************
Const StackSize = 4 ' How Many Modes can be stacked - Higher priority wins base, mb, wizard, skillshot
Class cStack
Public bStackActive ' Is there a mode here actually stacked?
Public ModeIndex ' What is the index of this mode?
Public ArrowStates(9) ' What are the arrow states for this mode
Private Sub Class_Initialize( )
dim i
For i = 0 to 9
set ArrowStates(i) = New cArrowState
Next
End Sub
Public Sub Reset()
dim i
bStackActive = False
ModeIndex = -1
For i = 0 to 9
ArrowStates(i).ArrowColor = ""
ArrowStates(i).ArrowState = 0
ArrowStates(i).MultipState = 0 '
ArrowStates(i).NameState = 0 ' Color is always name color
Next
End Sub
Public Function GetArrowState(light)
dim lIndex
lIndex = GetModeIndex(light.name)
GetArrowState = ArrowStates(lIndex).ArrowState
End Function
Public Function GetArrowColor(light)
dim lIndex
lIndex = GetModeIndex(light.name)
GetArrowColor = ArrowStates(lIndex).ArrowColor
End Function
Public Sub SetArrowState(light, state)
dim lIndex
lIndex = GetModeIndex(light.name)
ArrowStates(lIndex).ArrowState = state
End Sub
Public Sub Enable (NewModeIndex)
bStackActive = True
ModeIndex = NewModeIndex
End Sub
Public Sub Disable()
Reset
End Sub
End Class
Public StackState(4) ' Stores which modes are actually in play (stacked)
Class TableState
' These should hold state of the current mode
Public sBumperMultiplier
Public bFirstBall
Public ArrowColor
Public lArrowStates(9)
Public lToyBoxMBState '
Public bExtraball_1 ' Triggered - Toy or Elev MB Extra Ball
Public bExtraball_2 ' Triggered 3 Modes are started
Public bExtraball_3 ' Triggered 6 Modes are complete
Public sPopValue
Public sPopLevel
' Holds global info
Public SModeProgress(9) '
Public SModeOrder(9)
Public SModePercent(9)
Public SMode2Progress(9) '
Public SMode2Percent(9)
Public SMode2Value(9)
Public AerosmithCount
Public bSFinalTourDone
Public bSFinalTourReady
Public bSFinalTourCount
' partial
Public Sub Reset()
bFirstBall = True
AerosmithCount = 0
PopValue=2000
SpinHits=25
SpinValue=200
PopLevel=0
PopHits=25
End Sub
Public Sub Save()
sBumperMultiplier = BumperMultiplier
AerosmithCount = SpellAerosmith
sPopValue = PopValue
sPopLevel = PopLevel
bSFinalTourDone = bFinalTourDone
bSFinalTourReady= bFinalTourReady
bSFinalTourCount = bFinalTourCount
' save the uservalue of the LockLights
End Sub
Public Sub Restore()
If PlayersPlayingGame = 1 then exit sub
BumperMultiplier = sBumperMultiplier
SpellAerosmith = AerosmithCount
PopValue = sPopValue
PopLevel = sPopLevel
bFinalTourDone = bSFinalTourDone
bFinalTourReady= bSFinalTourReady
bFinalTourCount = bSFinalTourCount
End Sub
End Class
Sub TableState_Init(Index)
Set PlayerState(Index) = New TableState
PlayerState(Index).Reset
End Sub
Sub StackState_Init(Index)
Set StackState(Index) = New cStack
StackState(Index).Reset
End Sub
'************************
' nFozzy Flipper Physics
'************************
dim LF:Set LF = New FlipperPolarity
dim RF:Set RF = New FlipperPolarity
LoadCoreFiles
InitPolarity
Dim mHMagnet
Set mHMagnet = New cvpmMagnet : With mHMagnet
.InitMagnet HMagnet, 100
.GrabCenter = False
.MagnetOn = False
End With
mHMagnet.MagnetOn = True
'====================== Routines
Sub LoadCoreFiles
On Error Resume Next
ExecuteGlobal GetTextFile("core.vbs")
If Err Then MsgBox "Can't open core.vbs"
ExecuteGlobal GetTextFile("controller.vbs")
If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
On Error Goto 0
'============================' Orbital Scoreboard'============================
If osbactive = 1 or osbactive = 2 Then
On Error Resume Next
ExecuteGlobal GetTextFile("osb.vbs")
On Error Goto 0
End if
End Sub
'===================== Common Routines
Sub InitPolarity()
dim x, a : a = Array(LF, RF)
for each x in a
'safety coefficient (diminishes polarity correction only)
x.AddPoint "Ycoef", 0, RightFlipper.Y-65, 1 'disabled
x.AddPoint "Ycoef", 1, RightFlipper.Y-11, 1
x.enabled = True
x.TimeDelay = 44
Next
rf.report "Velocity"
addpt "Velocity", 0, 0, 1
addpt "Velocity", 1, 0.2, 1.07
addpt "Velocity", 2, 0.41, 1.05
addpt "Velocity", 3, 0.44, 1
addpt "Velocity", 4, 0.65, 1.0'0.982
addpt "Velocity", 5, 0.702, 0.968
addpt "Velocity", 6, 0.95, 0.968
addpt "Velocity", 7, 1.03, 0.945
rf.report "Polarity"
AddPt "Polarity", 0, 0, 0
AddPt "Polarity", 1, 0.16, -4.7
AddPt "Polarity", 2, 0.33, -4.7
AddPt "Polarity", 3, 0.37, -4.7 '4.2
AddPt "Polarity", 4, 0.41, -4.7
AddPt "Polarity", 5, 0.45, -4.7 '4.2
AddPt "Polarity", 6, 0.576,-4.7
AddPt "Polarity", 7, 0.66, -2.8'-2.1896
AddPt "Polarity", 8, 0.743, -1.5
AddPt "Polarity", 9, 0.81, -1.5
AddPt "Polarity", 10, 0.88, 0
LF.Object = LeftFlipper
LF.EndPoint = EndPointLp 'you can use just a coordinate, or an object with a .x property. Using a couple of simple primitive objects
RF.Object = RightFlipper
RF.EndPoint = EndPointRp
End Sub
'Methods:
'.TimeDelay - Delay before trigger shuts off automatically. Default = 80 (ms)
'.AddPoint - "Polarity", "Velocity", "Ycoef" coordinate points. Use one of these 3 strings, keep coordinates sequential. x = %position on the flipper, y = output
'.Object - set to flipper reference. Optional.
'.StartPoint - set start point coord. Unnecessary, If .object is used.
'Called with flipper -
'ProcessBalls - catches ball data.
' - OR -
'.Fire - fires flipper.rotatetoend automatically + processballs. Requires .Object to be set to the flipper.
'******************************************************
'******************************************************
'******************************************************
'******************************************************
'******************************************************
' FLIPPER CORRECTION SUPPORTING FUNCTIONS
'******************************************************
RightFlipper.timerinterval=1
rightflipper.timerenabled=True
sub RightFlipper_timer()
If leftflipper.currentangle = leftflipper.endangle and LFPress = 1 then
leftflipper.eostorqueangle = EOSAnew
leftflipper.eostorque = EOSTnew
LeftFlipper.rampup = EOSRampup
If LFCount = 0 Then LFCount = GameTime
If GameTime - LFCount < LiveCatch Then
leftflipper.Elasticity = 0.1
If LeftFlipper.endangle <> LFEndAngle Then leftflipper.endangle = LFEndAngle
Else
leftflipper.Elasticity = FElasticity
end if
elseIf leftflipper.currentangle > leftflipper.startangle - 0.05 Then
leftflipper.rampup = SOSRampup
leftflipper.endangle = LFEndAngle - 3
leftflipper.Elasticity = FElasticity
LFCount = 0
elseIf leftflipper.currentangle > leftflipper.endangle + 0.01 Then
leftflipper.eostorque = EOST
leftflipper.eostorqueangle = EOSA
LeftFlipper.rampup = Frampup
leftflipper.Elasticity = FElasticity
end if
If rightflipper.currentangle = rightflipper.endangle and RFPress = 1 then
rightflipper.eostorqueangle = EOSAnew
rightflipper.eostorque = EOSTnew
RightFlipper.rampup = EOSRampup
If RFCount = 0 Then RFCount = GameTime
If GameTime - RFCount < LiveCatch Then
rightflipper.Elasticity = 0.1
If RightFlipper.endangle <> RFEndAngle Then rightflipper.endangle = RFEndAngle
Else
rightflipper.Elasticity = FElasticity
end if
elseIf rightflipper.currentangle < rightflipper.startangle + 0.05 Then
rightflipper.rampup = SOSRampup
rightflipper.endangle = RFEndAngle + 3
rightflipper.Elasticity = FElasticity
RFCount = 0
elseIf rightflipper.currentangle < rightflipper.endangle - 0.01 Then
rightflipper.eostorque = EOST
rightflipper.eostorqueangle = EOSA
RightFlipper.rampup = Frampup
rightflipper.Elasticity = FElasticity
end if
end sub
dim LFPress, RFPress, EOST, EOSA, EOSTnew, EOSAnew
dim FStrength, Frampup, FElasticity, EOSRampup, SOSRampup
dim RFEndAngle, LFEndAngle, LFCount, RFCount, LiveCatch
EOST = leftflipper.eostorque
EOSA = leftflipper.eostorqueangle
FStrength = LeftFlipper.strength
Frampup = LeftFlipper.rampup
FElasticity = LeftFlipper.elasticity
EOSTnew = 1.0 'FEOST
EOSAnew = 0.2
EOSRampup = 1.5
SOSRampup = 8.5
LiveCatch = 8
LFEndAngle = Leftflipper.endangle
RFEndAngle = RightFlipper.endangle
Sub AddPt(aStr, idx, aX, aY) 'debugger wrapper for adjusting flipper script in-game
dim a : a = Array(LF, RF)
dim x : for each x in a
x.addpoint aStr, idx, aX, aY
Next
End Sub
Class FlipperPolarity
Public DebugOn, Enabled
Private FlipAt 'Timer variable (IE 'flip at 723,530ms...)
Public TimeDelay 'delay before trigger turns off and polarity is disabled TODO set time!
private Flipper, FlipperStart, FlipperEnd, LR, PartialFlipCoef
Private Balls(20), balldata(20)
dim PolarityIn, PolarityOut
dim VelocityIn, VelocityOut
dim YcoefIn, YcoefOut
Public Sub Class_Initialize
redim PolarityIn(0) : redim PolarityOut(0) : redim VelocityIn(0) : redim VelocityOut(0) : redim YcoefIn(0) : redim YcoefOut(0)
Enabled = True : TimeDelay = 50 : LR = 1: dim x : for x = 0 to uBound(balls) : balls(x) = Empty : set Balldata(x) = new SpoofBall : next
End Sub
Public Property let Object(aInput) : Set Flipper = aInput : StartPoint = Flipper.x : End Property
Public Property Let StartPoint(aInput) : If IsObject(aInput) then FlipperStart = aInput.x else FlipperStart = aInput : end If : End Property
Public Property Get StartPoint : StartPoint = FlipperStart : End Property
Public Property Let EndPoint(aInput) : If IsObject(aInput) then FlipperEnd = aInput.x else FlipperEnd = aInput : end If : End Property
Public Property Get EndPoint : EndPoint = FlipperEnd : End Property
Public Sub AddPoint(aChooseArray, aIDX, aX, aY) 'Index #, X position, (in) y Position (out)
Select Case aChooseArray
Case "Polarity" : ShuffleArrays PolarityIn, PolarityOut, 1 : PolarityIn(aIDX) = aX : PolarityOut(aIDX) = aY : ShuffleArrays PolarityIn, PolarityOut, 0
Case "Velocity" : ShuffleArrays VelocityIn, VelocityOut, 1 :VelocityIn(aIDX) = aX : VelocityOut(aIDX) = aY : ShuffleArrays VelocityIn, VelocityOut, 0
Case "Ycoef" : ShuffleArrays YcoefIn, YcoefOut, 1 :YcoefIn(aIDX) = aX : YcoefOut(aIDX) = aY : ShuffleArrays YcoefIn, YcoefOut, 0
End Select
If gametime > 100 then Report aChooseArray
End Sub
Public Sub Report(aChooseArray) 'debug, reports all coords in tbPL.text
If not DebugOn then exit sub
dim a1, a2 : Select Case aChooseArray
Case "Polarity" : a1 = PolarityIn : a2 = PolarityOut
Case "Velocity" : a1 = VelocityIn : a2 = VelocityOut
Case "Ycoef" : a1 = YcoefIn : a2 = YcoefOut
Case else :tbpl.text = "wrong string" : exit sub
End Select
dim str, x : for x = 0 to uBound(a1) : str = str & aChooseArray & " x: " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
tbpl.text = str
End Sub
Public Sub AddBall(aBall) : dim x : for x = 0 to uBound(balls) : If IsEmpty(balls(x)) then set balls(x) = aBall : exit sub :end If : Next : End Sub
Private Sub RemoveBall(aBall)
dim x : for x = 0 to uBound(balls)
If TypeName(balls(x) ) = "IBall" then
If aBall.ID = Balls(x).ID Then
balls(x) = Empty
Balldata(x).Reset
End If
End If
Next
End Sub
Public Sub Fire()
Flipper.RotateToEnd
processballs
End Sub
Public Property Get Pos 'returns % position a ball. For debug stuff.
dim x : for x = 0 to uBound(balls)
If not IsEmpty(balls(x) ) then
pos = pSlope(Balls(x).x, FlipperStart, 0, FlipperEnd, 1)
End If
Next
End Property
Public Sub ProcessBalls() 'save data of balls in flipper range
FlipAt = GameTime
dim x : for x = 0 to uBound(balls)
If not IsEmpty(balls(x) ) then
balldata(x).Data = balls(x)
If DebugOn then StickL.visible = True : StickL.x = balldata(x).x 'debug TODO
End If
Next
PartialFlipCoef = ((Flipper.StartAngle - Flipper.CurrentAngle) / (Flipper.StartAngle - Flipper.EndAngle))
PartialFlipCoef = abs(PartialFlipCoef-1)
If abs(Flipper.currentAngle - Flipper.EndAngle) < 30 Then
PartialFlipCoef = 0
End If
End Sub
Private Function FlipperOn() : If gameTime < FlipAt+TimeDelay then FlipperOn = True : End If : End Function 'Timer shutoff for polaritycorrect
Public Sub PolarityCorrect(aBall)
If FlipperOn() then
dim tmp, BallPos, x, IDX, Ycoef : Ycoef = 1
dim teststr : teststr = "Cutoff"
tmp = PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1)
If tmp < 0.1 then 'If real ball position is behind flipper, exit Sub to prevent stucks 'Disabled 1.03, I think it's the Mesh that's causing stucks, not this
If DebugOn then TestStr = "real pos < 0.1 ( " & round(tmp,2) & ")" : tbpl.text = Teststr
'RemoveBall aBall
'Exit Sub
end if
'y safety Exit
If aBall.VelY > -8 then 'ball going down
If DebugOn then teststr = "y velocity: " & round(aBall.vely, 3) & "exit sub" : tbpl.text = teststr
RemoveBall aBall
exit Sub
end if
'Find balldata. BallPos = % on Flipper
for x = 0 to uBound(Balls)
If aBall.id = BallData(x).id AND not isempty(BallData(x).id) then
idx = x
BallPos = PSlope(BallData(x).x, FlipperStart, 0, FlipperEnd, 1)
'TB.TEXT = balldata(x).id & " " & BALLDATA(X).X & VBNEWLINE & FLIPPERSTART & " " & FLIPPEREND
If ballpos > 0.65 then Ycoef = LinearEnvelope(BallData(x).Y, YcoefIn, YcoefOut) 'find safety coefficient 'ycoef' data
end if
Next
'Velocity correction
If not IsEmpty(VelocityIn(0) ) then
Dim VelCoef
If DebugOn then set tmp = new spoofball : tmp.data = aBall : End If
If IsEmpty(BallData(idx).id) and aBall.VelY < -12 then 'If tip hit with no collected data, do vel correction anyway
If PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1) > 1.1 then 'adjust plz
VelCoef = LinearEnvelope(5, VelocityIn, VelocityOut)
If partialflipcoef < 1 then VelCoef = PSlope(partialflipcoef, 0, 1, 1, VelCoef)
If Enabled then aBall.Velx = aBall.Velx*VelCoef'VelCoef
If Enabled then aBall.Vely = aBall.Vely*VelCoef'VelCoef
If DebugOn then teststr = "tip protection" & vbnewline & "velcoef: " & round(velcoef,3) & vbnewline & round(PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1),3) & vbnewline
'debug.print teststr
end if
Else
: VelCoef = LinearEnvelope(BallPos, VelocityIn, VelocityOut)
If Enabled then aBall.Velx = aBall.Velx*VelCoef
If Enabled then aBall.Vely = aBall.Vely*VelCoef
end if
End If
'Polarity Correction (optional now)
If not IsEmpty(PolarityIn(0) ) then
If StartPoint > EndPoint then LR = -1 'Reverse polarity If left flipper
dim AddX : AddX = LinearEnvelope(BallPos, PolarityIn, PolarityOut) * LR
If Enabled then aBall.VelX = aBall.VelX + 1 * (AddX*ycoef*PartialFlipcoef)
End If
'debug
If DebugOn then
TestStr = teststr & "%pos:" & round(BallPos,2)
If IsEmpty(PolarityOut(0) ) then
teststr = teststr & vbnewline & "(Polarity Disabled)" & vbnewline
else
teststr = teststr & "+" & round(1 *(AddX*ycoef*PartialFlipcoef),3)
If BallPos >= PolarityOut(uBound(PolarityOut) ) then teststr = teststr & "(MAX)" & vbnewline else teststr = teststr & vbnewline end if
If Ycoef < 1 then teststr = teststr & "ycoef: " & ycoef & vbnewline
If PartialFlipcoef < 1 then teststr = teststr & "PartialFlipcoef: " & round(PartialFlipcoef,4) & vbnewline
end if
teststr = teststr & vbnewline & "Vel: " & round(BallSpeed(tmp),2) & " -> " & round(ballspeed(aBall),2) & vbnewline
teststr = teststr & "%" & round(ballspeed(aBall) / BallSpeed(tmp),2)
tbpl.text = TestSTR
end if
Else
'If DebugOn then tbpl.text = "td" & timedelay
End If
RemoveBall aBall
End Sub
End Class
'================================
'Helper Functions
Sub ShuffleArray(ByRef aArray, byVal offset) 'shuffle 1d array
dim x, aCount : aCount = 0
redim a(uBound(aArray) )
for x = 0 to uBound(aArray) 'Shuffle objects in a temp array
If not IsEmpty(aArray(x) ) Then
If IsObject(aArray(x)) then
Set a(aCount) = aArray(x)
Else
a(aCount) = aArray(x)
End If
aCount = aCount + 1
End If
Next
If offset < 0 then offset = 0
redim aArray(aCount-1+offset) 'Resize original array
for x = 0 to aCount-1 'set objects back into original array
If IsObject(a(x)) then
Set aArray(x) = a(x)
Else
aArray(x) = a(x)
End If
Next
End Sub
Sub ShuffleArrays(aArray1, aArray2, offset)
ShuffleArray aArray1, offset
ShuffleArray aArray2, offset
End Sub
Function BallSpeed(ball) 'Calculates the ball speed
BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
End Function
Function PSlope(Input, X1, Y1, X2, Y2) 'Set up line via two points, no clamping. Input X, output Y
dim x, y, b, m : x = input : m = (Y2 - Y1) / (X2 - X1) : b = Y2 - m*X2
Y = M*x+b
PSlope = Y
End Function
Function NullFunctionZ(aEnabled):End Function '1 argument null function placeholder TODO move me or replac eme
Class spoofball
Public X, Y, Z, VelX, VelY, VelZ, ID, Mass, Radius
Public Property Let Data(aBall)
With aBall
x = .x : y = .y : z = .z : velx = .velx : vely = .vely : velz = .velz
id = .ID : mass = .mass : radius = .radius
end with
End Property
Public Sub Reset()
x = Empty : y = Empty : z = Empty : velx = Empty : vely = Empty : velz = Empty
id = Empty : mass = Empty : radius = Empty
End Sub
End Class
Function LinearEnvelope(xInput, xKeyFrame, yLvl)
dim y 'Y output
dim L 'Line
dim ii : for ii = 1 to uBound(xKeyFrame) 'find active line
If xInput <= xKeyFrame(ii) then L = ii : exit for : end if
Next
If xInput > xKeyFrame(uBound(xKeyFrame) ) then L = uBound(xKeyFrame) 'catch line overrun
Y = pSlope(xInput, xKeyFrame(L-1), yLvl(L-1), xKeyFrame(L), yLvl(L) )
'Clamp If on the boundry lines
'If L=1 and Y < yLvl(LBound(yLvl) ) then Y = yLvl(lBound(yLvl) )
'If L=uBound(xKeyFrame) and Y > yLvl(uBound(yLvl) ) then Y = yLvl(uBound(yLvl) )
'clamp 2.0
If xInput <= xKeyFrame(lBound(xKeyFrame) ) then Y = yLvl(lBound(xKeyFrame) ) 'Clamp lower
If xInput >= xKeyFrame(uBound(xKeyFrame) ) then Y = yLvl(uBound(xKeyFrame) ) 'Clamp upper
LinearEnvelope = Y
End Function
' DONT FORGET TO CLEAR FlipperSkipCmd when you are past this stage.
' What this means is once you move on to the next command (without skipping) you need to clear this otherwise
' when you hit both flippers during gameplay it will call the command you put
Sub SetFlipperSkipCmd(Cmd)
If FlipperSkipCmd="" then
FlipperSkipCmd=Cmd
End If
End Sub
Sub StartInstantInfo(keycode)
D2 "Start Instant " & keycode & " " & bInstantInfo
If bInstantInfo = False and tmrSkillshot.Enabled=False Then ' I am already in instantinfo
InstantInfoTimer.Interval = 8000
InstantInfoTimer.Enabled = True
InstantInfoTimer.UserValue=keycode
End If
End Sub
Sub InstantInfoTimer_Timer
InstantInfoTimer.Enabled = False
bInstantInfo = True
D "InstantInfotimer Expired"
PuPlayer.LabelShowPage pOverVid, 1,0,""
pCurAttractPos=0
pInAttract=true
pAttractNext
End Sub
Sub EndFlipperStatus(keycode)
If bInstantInfo Then
D "EndInstantInfo check" & keycode & " " & InstantInfoTimer.UserValue
If (keycode=InstantInfoTimer.UserValue) then ' They let go of the key
D "EndInstantInfo"
InstantInfoTimer.Enabled = False
bInstantInfo=False
PuPlayer.LabelShowPage pBackglass,1,0,""
pInAttract=false
playclear pOverVid
PuPlayer.LabelSet pOverVid,"OverMessage1"," ",1,""
PuPlayer.LabelSet pOverVid,"OverMessage2"," ",1,""
PuPlayer.LabelSet pOverVid,"OverMessage3"," ",1,""
RefreshPlayerMode
If bPlayerModeSelect Then
If modecountdowntimer.enabled Then
pDMDEvent(kDMD_PlayerMode+(CurrentPlayer)+(PlayersPlayingGame*(PlayersPlayingGame-1))+1)
Else
pDMDEvent(kDMD_PlayerMode+(CurrentPlayer)+(PlayersPlayingGame*(PlayersPlayingGame-1)))
End If
End If
Else ' They pressed the other flipper so cycle faster
PriorityReset=2000
pAttractNext
End If
Else
D2 "Stop Instant " & keycode
InstantInfoTimer.Enabled = False
End If
End Sub
'a1a1
Sub UpdatePlayerMode() 'Updates the DMD & lights with the chosen skillshots
D "UpdatePlayerMode " & PlayerMode
LightSeqSkillshot.Play SeqAllOff
'turn off various mode lights
BumperLight001.State = 0
BumperLight002.State = 0
BumperLight003.State = 0
I15.State = 0:I15.BlinkInterval=BlinkIntDef:I15.BlinkPattern=BlinkPatternDef 'MODE LIGHTS ON PF
I16.State = 0:I16.BlinkInterval=BlinkIntDef:I16.BlinkPattern=BlinkPatternDef
I17.State = 0:I17.BlinkInterval=BlinkIntDef:I17.BlinkPattern=BlinkPatternDef
I18.State = 0:I18.BlinkInterval=BlinkIntDef:I18.BlinkPattern=BlinkPatternDef
I19.State = 0:I19.BlinkInterval=BlinkIntDef:I19.BlinkPattern=BlinkPatternDef
I20.State = 0:I20.BlinkInterval=BlinkIntDef:I20.BlinkPattern=BlinkPatternDef
I21.State = 0:I21.BlinkInterval=BlinkIntDef:I21.BlinkPattern=BlinkPatternDef
'PuPlayer.playlistplayex pMusic,"audioclear","clear.mp3",100, 1
SaveMode=PlayerMode
PlaySong "Song-" & PlayerMode & ".mp3"