forked from LegendsUnchained/vpx-standalone-alp4k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHarley Davidson (Sega 1999) v1.12.vbs
4548 lines (3739 loc) · 156 KB
/
Harley Davidson (Sega 1999) v1.12.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
' _ _ _ ____ _ _
' | | | | __ _ _ __| | ___ _ _ | _ \ __ ___ _(_) __| |___ ___ _ __
' | |_| |/ _` | '__| |/ _ \ | | | | | | |/ _` \ \ / / |/ _` / __|/ _ \| '_ \
' | _ | (_| | | | | __/ |_| | | |_| | (_| |\ V /| | (_| \__ \ (_) | | | |
' |_| |_|\__,_|_| |_|\___|\__, | |____/ \__,_| \_/ |_|\__,_|___/\___/|_| |_|
' |___/
'
' Harley-Davidson® (1st Edition) / IPD No. 4455 / 1999 / 6 Players
'
' Harley Davidson (Sega 1999) NestorGian
' V1.07
' - material Corrections
' - Phisics Corrections
' - Ball lost corrections
' V1.12
' VR implementation TastyWasps
Option Explicit
Randomize
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
Const UsingROM = True
Const BallSize = 50
Const BallMass = 1
LoadVPM "01200000","SEGA.VBS",3.1
'********************
'Standard definitions
'********************
Const cGameName="harl_a30"
Const UseSolenoids=2
Const UseLamps=0
Const UseSync=1
Const UseGI=0
'Standard Sounds
Const SSolenoidOn = "Solenoid"
Const SSolenoidOff = ""
Const sCoin="coin3"
Dim VarHidden, UseVPMDMD, x
If Table1.ShowDT = true then
' UseVPMDMD = True
' VarHidden = 1
For each x in aReels
x.Visible = 1
Next
else
' UseVPMDMD = False
' VarHidden = 0
For each x in aReels
x.Visible = 0
Next
end if
'-----RampRoll Sound Amplification -----/////////////////////
Const RampRollAmpFactor = 4 ' 0 = no amplification, 1 = 2.5db amplification, 2 = 5db amplification, 3 = 7.5db amplification, 4 = 9db amplification (aka: Tie Fighter)
'----- Phsyics Mods -----
Const RubberizerEnabled = 1 '0 = normal flip rubber, 1 = more lively rubber for flips, 2 = a different rubberizer
Const FlipperCoilRampupMode = 0 '0 = fast, 1 = medium, 2 = slow (tap passes should work)
Const TargetBouncerEnabled = 1 '0 = normal standup targets, 1 = bouncy targets, 2 = orig TargetBouncer
Const TargetBouncerFactor = 0.7 'Level of bounces. Recommmended value of 0.7 when TargetBouncerEnabled=1, and 1.1 when TargetBouncerEnabled=2
'----- Shadow Options -----
Const DynamicBallShadowsOn = 1 '0 = no dynamic ball shadow ("triangles" near slings and such), 1 = enable dynamic ball shadow
Const AmbientBallShadowOn = 1 '0 = Static shadow under ball ("flasher" image, like JP's)
'1 = Moving ball shadow ("primitive" object, like ninuzzu's)
'2 = flasher image shadow, but it moves like ninuzzu's
'----- General Sound Options -----
Const VolumeDial = 0.8 'Overall Mechanical sound effect volume. Recommended values should be no greater than 1.
Const BallRollVolume = 1 'Level of ball rolling volume. Value between 0 and 1
Const RampRollVolume = 1 'Level of ramp rolling volume. Value between 0 and 1
'*******************************************
' Constants and Global Variables
'*******************************************
Const tnob = 5 'Total number of balls
Dim tablewidth: tablewidth = Table1.width
Dim tableheight: tableheight = Table1.height
Const lob = 0 'Locked balls
'//////////////---- LUT (Colour Look Up Table) ----//////////////
'0 = Fleep Natural Dark 1
'1 = Fleep Natural Dark 2
'2 = Fleep Warm Dark
'3 = Fleep Warm Bright
'4 = Fleep Warm Vivid Soft
'5 = Fleep Warm Vivid Hard
'6 = Skitso Natural and Balanced
'7 = Skitso Natural High Contrast
'8 = 3rdaxis Referenced THX Standard
'9 = CalleV Punchy Brightness and Contrast
'10 = HauntFreaks Desaturated
'11 = Tomate Washed Out
'12 = VPW Original 1 to 1
'13 = Bassgeige
'14 = Blacklight
'15 = B&W Comic Book
'16 = SWcolorGradeLUT
Dim LUTset, DisableLUTSelector, LutToggleSound
LutToggleSound = True
LoadLUT
'LUTset = 11 ' Override saved LUT for debug
SetLUT
DisableLUTSelector = 0 ' Disables the ability to change LUT option with magna saves in game when set to 1
' VR Room Auto-Detect - LUT 00 or 06 suggested for Pool Hall VR Room for darker lighting.
Dim VR_Obj, VR_Room
If RenderingMode = 2 Then
VR_Room = 1
rrail.Visible = False
lrail.Visible = False
Ramp003.Visible = False
Ramp002.Visible = False
Flasher6.Visible = False
Flasher7.Visible = False
For Each VR_Obj in VRCabinet : VR_Obj.Visible = 1 : Next
For Each VR_Obj in VRPoolHall : VR_Obj.Visible = 1 : Next
Pincab_Backglass.BlendDisableLighting = 3
Else
VR_Room = 0
For Each VR_Obj in VRCabinet : VR_Obj.Visible = 0 : Next
For Each VR_Obj in VRPoolHall : VR_Obj.Visible = 0 : Next
End If
'********************
'Solenoids Call backs
'********************
SolCallback(1)="bsTrough.SolOut"
SolCallback(2)="bsLaunch.SolOut"
SolCallback(3)="bsSVUK.SolOut"
SolCallback(4)="bsScoop.SolOut"
SolCallback(5)="bsCycle.SolOut"
SolCallback(6)="SolLDTBank"
SolCallback(7)="SolRDTBank"
'SolCallback(9)="vpmSolSound ""jet3"","
'SolCallback(10)="vpmSolSound ""jet3"","
'SolCallback(11)="vpmSolSound ""jet3"","
'SolCallback(12)="vpmSolSound ""jet3"","
SolCallback(13)="SolShake"
'SolCallback(14)=magnet
'SolCallback(17)="vpmSolSound ""Sling"","
'SolCallback(18)="vpmSolSound ""Sling"","
'SolCallback(19)="SolCycle" 'Shake Bike
SolCallback(20)="SetLamp 120," 'Flash Scoop x1
SolCallback(23)="SolPost"
SolCallBack(25)="SetLamp 101," 'Left drop target X2
'SolCallBack(26)="SetLamp 102," 'Ramp Left X2 Flashers
SolCallback(26)="Flash2"
SolCallBack(27)="SetLamp 103," 'Turbo Bumper X4
'SolCallBack(28)="SetLamp 104," 'Ramp Top X2 Flashers
SolCallback(28)="Flash1"
'SolModCallback(29) = "SetLampMod 29,"
SolCallBack(29)="SetLamp 105," '"MotoFlash" 'Motorcycle X4
SolCallBack(30)="SetLamp 106," 'Super VUK X2
SolCallBack(31)="SetLamp 107," 'Right Drop Target X2
SolCallBack(32)="SetLamp 108," 'Speedometer X2
SolCallback(sLRFlipper) = "SolRFlipper"
SolCallback(sLLFlipper) = "SolLFlipper"
Dim Status
Status=0
'**********************************************************************************************************
'Solenoid Controlled toys
'**********************************************************************************************************
Sub SolTrough(Enabled)
If Enabled Then
If bsTrough.Balls Then
bsTrough.ExitSol_On
vpmTimer.PulseSw 15
End If
End If
End Sub
Sub SolShake(Enabled)
If enabled Then
'ShakeTimer.Enabled = 1
Else
'ShakeTimer.Enabled = 0
End If
End Sub
Sub ShakeTimer_Timer()
Nudge 0,1
Nudge 90,1
Nudge 180,1
Nudge 270,1
End Sub
Sub SolPost(Enabled)
If Enabled Then
Postup
Playsound SoundFX("Centerpost_Up",DOFContactors)
Else
Postdown
Playsound SoundFX("Centerpost_Down",DOFContactors)
End If
End Sub
Sub Postup
PostPrim.Image="HDpopup_post_on"
PostPrim.Z=-30
PostPrim.collidable=True
end Sub
Sub Postdown
PostPrim.Image="HDpopup_post"
PostPrim.Z=-61
PostPrim.collidable=False
end Sub
'*******************************************
' Timers
'*******************************************
' The game timer interval is 10 ms
Sub GameTimer_Timer()
Cor.Update 'update ball tracking
RollingUpdate 'update rolling sounds
DoDTAnim 'handle drop target animations
End Sub
' The frame timer interval is -1, so executes at the display frame rate
Sub FrameTimer_Timer()
FlipperVisualUpdate 'update flipper shadows and primitives
If DynamicBallShadowsOn Or AmbientBallShadowOn Then DynamicBSUpdate 'update ball shadows
End Sub
' Hack to return Narnia ball back in play
Sub Narnia_Timer
Dim BOT, b
BOT = GetBalls
For b = 0 to UBound(BOT)
if BOT(b).z < -300 Then
'msgbox "Ball " &b& " in Narnia X: " & gBOT(b).x &" Y: "&gBOT(b).y & " Z: "&gBOT(b).z
'debug.print "Move narnia ball ("& gBOT(b).x &" Y: "&gBOT(b).y & " Z: "&gBOT(b).z&") to middle subway"
BOT(b).x = 500
BOT(b).y = 746
BOT(b).z = -60
end if
next
end sub
'**********************************************************************************************************
'Initiate Table
'**********************************************************************************************************
Dim bsTrough, bsCycle, bsScoop, mMagnet, bsVUK, mcycle, bsLaunch, bsSVUK, dtL, dtR
Sub Table1_Init
vpmInit Me
On Error Resume Next
With Controller
.GameName = cGameName
If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
.SplashInfoLine = "harley-Davidson 1999"
.HandleMechanics = 0
.HandleKeyboard = 0
.ShowDMDOnly = 1
.ShowFrame = 0
.ShowTitle = 0
.hidden = UseVPMDMD
.Games(cGameName).Settings.Value("sound") = 1
'.PuPHide = 1
On Error Resume Next
.Run GetPlayerHWnd
If Err Then MsgBox Err.Description
On Error Goto 0
End With
On Error Goto 0
PinMAMETimer.Interval = PinMAMEInterval
PinMAMETimer.Enabled = 1
vpmNudge.TiltSwitch=56
vpmNudge.Sensitivity=2
vpmNudge.TiltObj=Array(LeftSlingshot,RightSlingshot,Bumper1b,Bumper2b,Bumper3b,Bumper4b)
Set bsTrough=New cvpmBallStack
bsTrough.InitSw 0,14,13,12,11,0,0,0
bsTrough.InitKick BallRelease,110,5
bsTrough.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors)
bsTrough.Balls=4
Set bsCycle=New cvpmBallStack
bsCycle.InitSw 0,44,43,42,41,0,0,0
bsCycle.InitKick Kicker1,170,20
bsCycle.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors)
Set bsScoop=New cvpmBallStack
bsScoop.InitSw 0,46,0,0,0,0,0,0
bsScoop.InitKick sw46,166,25
bsScoop.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
Set bsLaunch=New cvpmBallStack
bsLaunch.InitSaucer Kicker2,16,0,44
bsLaunch.InitExitSnd SoundFX("solenoid",DOFContactors), SoundFX("Solenoid",DOFContactors)
Set bsSVUK=New cvpmBallStack
bsSVUK.InitSw 0,45,0,0,0,0,0,0
bsSVUK.InitKick sw45a,105,30
bsSVUK.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("scoopexit",DOFContactors)
' Set dtL=New cvpmDropTarget
' dtL.InitDrop Array(sw17,sw18,sw19,sw20),Array(17,18,19,20)
' dtL.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors)
' Set dtR=New cvpmDropTarget
' dtR.InitDrop Array(sw21,sw22,sw23,sw24),Array(21,22,23,24)
' dtR.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors)
Set mMagnet=New cvpmMagnet
mMagnet.InitMagnet MagTrig,75
mMagnet.Solenoid=14
mMagnet.GrabCenter=True
mMagnet.CreateEvents "mMagnet"
Playsound SoundFX("fx_magnet",DOFGear)
Set mCycle=New cvpmMech
mCycle.Sol1=19
mCycle.Length=100
mCycle.Steps=25
mCycle.mType=vpmMechOneSol+vpmMechReverse+vpmMechLinear
mCycle.AddSw 35,24,24
mCycle.AddSw 36,0,0
mCycle.Callback=GetRef("UpdateCycle")
mCycle.Start
Postdown
' Turn on the GI lights
' dim xx
' For Each xx in GI
' xx.state = 1
' Next
End Sub
'*******************************************
' Flippers
'*******************************************
Const ReflipAngle = 20
' Flipper Solenoid Callbacks (these subs mimics how you would handle flippers in ROM based tables)
Sub SolLFlipper(Enabled)
If Enabled Then
LF.Fire 'leftflipper.rotatetoend
If leftflipper.currentangle < leftflipper.endangle + ReflipAngle Then
RandomSoundReflipUpLeft LeftFlipper
Else
SoundFlipperUpAttackLeft LeftFlipper
RandomSoundFlipperUpLeft LeftFlipper
End If
Else
LeftFlipper.RotateToStart
If LeftFlipper.currentangle < LeftFlipper.startAngle - 5 Then
RandomSoundFlipperDownLeft LeftFlipper
End If
FlipperLeftHitParm = FlipperUpSoundLevel
End If
End Sub
Sub SolRFlipper(Enabled)
If Enabled Then
RF.Fire 'rightflipper.rotatetoend
If rightflipper.currentangle > rightflipper.endangle - ReflipAngle Then
RandomSoundReflipUpRight RightFlipper
Else
SoundFlipperUpAttackRight RightFlipper
RandomSoundFlipperUpRight RightFlipper
End If
Else
RightFlipper.RotateToStart
If RightFlipper.currentangle > RightFlipper.startAngle + 5 Then
RandomSoundFlipperDownRight RightFlipper
End If
FlipperRightHitParm = FlipperUpSoundLevel
End If
End Sub
' Flipper collide subs
Sub LeftFlipper_Collide(parm)
CheckLiveCatch Activeball, LeftFlipper, LFCount, parm
LeftFlipperCollide parm
if RubberizerEnabled = 1 then Rubberizer(parm)
if RubberizerEnabled = 2 then Rubberizer2(parm)
End Sub
Sub RightFlipper_Collide(parm)
CheckLiveCatch Activeball, RightFlipper, RFCount, parm
RightFlipperCollide parm
if RubberizerEnabled = 1 then Rubberizer(parm)
if RubberizerEnabled = 2 then Rubberizer2(parm)
End Sub
' This subroutine updates the flipper shadows and visual primitives
Sub FlipperVisualUpdate
FlipperLSh.RotZ = LeftFlipper.CurrentAngle
FlipperRSh.RotZ = RightFlipper.CurrentAngle
LFLogo.RotY = LeftFlipper.CurrentAngle
RFlogo.RotY = RightFlipper.CurrentAngle
End Sub
'**********************************************************************************************************
' CONTROLS
'**********************************************************************************************************
Sub Table1_Paused:Controller.Pause=1:End Sub
Sub Table1_unPaused:Controller.Pause=0:End Sub
Sub Table1_exit:SaveLUT:Controller.Stop:End Sub
Sub Table1_KeyDown(ByVal KeyCode)
If keycode = StartGameKey Then
SoundStartButton
DisableLUTSelector = 1
End If
If keycode = LeftFlipperKey Then
FlipperActivate LeftFlipper, LFPress
End If
If keycode = RightFlipperKey Then
FlipperActivate RightFlipper, RFPress
End If
If KeyCode=PlungerKey Then Controller.Switch(53)=1
If KeyCode=LeftMagnaSave Then
Controller.Switch(8)=1
if DisableLUTSelector = 0 then
LUTSet = LUTSet - 1
if LutSet < 0 then LUTSet = 16
If LutToggleSound then
If LutSet <> 16 Then
Playsound "fx_relay"
Else
Playsound "hyperdrive", 0, 1 * VolumeDial, 0, 0.2, 0, 0, 0, -1
End If
end if
SetLUT
ShowLUT
end if
End If
If KeyCode=RightMagnaSave Then
Controller.Switch(8)=1
if DisableLUTSelector = 0 then
LUTSet = LUTSet + 1
if LutSet > 16 then LUTSet = 0
If LutToggleSound then
If LutSet <> 16 Then
Playsound "fx_relay"
Else
Playsound "hyperdrive", 0, 1 * VolumeDial, 0, 0.2, 0, 0, 0, -1
End If
end if
SetLUT
ShowLUT
end if
End If
If KeyCode=KeyUpperRight Then Controller.Switch(8)=1
If KeyCode=KeyUpperLeft Then Controller.Switch(8)=1
If vpmKeyDown(KeyCode) Then Exit Sub
End Sub
Sub Table1_KeyUp(ByVal KeyCode)
If keycode = LeftFlipperKey Then
FlipperDeActivate LeftFlipper, LFPress
' SolLFlipper False 'This would be called by the solenoid callbacks if using a ROM
End If
If keycode = RightFlipperKey Then
FlipperDeActivate RightFlipper, RFPress
' SolRFlipper False 'This would be called by the solenoid callbacks if using a ROM
End If
If KeyCode=PlungerKey Then Controller.Switch(53)=0
If KeyCode=LeftMagnaSave Then
Controller.Switch(8)=0
End If
If KeyCode=RightMagnaSave Then Controller.Switch(8)=0
If KeyCode=KeyUpperRight Then Controller.Switch(8)=0
If KeyCode=KeyUpperLeft Then Controller.Switch(8)=0
If vpmKeyUp(KeyCode) Then Exit Sub
End Sub
'**********************************************************************************************************
' Drain hole and kickers
Sub Drain_Hit:bsTrough.AddBall Me: RandomSoundDrain Drain : End Sub
Sub Kicker2_Hit:bsLaunch.AddBall 0:End Sub
Sub Kicker1_Hit:bsCycle.AddBall Me:playsound "scoopenter":End Sub
'Sub sw46_Hit:bsScoop.AddBall Me:playsound "scoopenter":End Sub
Sub Sw45_Hit:bsSVUK.AddBall Me:playsound "kicker_enter left":End Sub
'Arcade Scoop
Dim aBall, aZpos
Dim bBall, bZpos
Sub sw46_Hit
Set bBall = ActiveBall
PlaySoundAt "scoopenter",sw46
bZpos = 45
Me.TimerInterval = 2
Me.TimerEnabled = 1
End Sub
Sub sw46_Timer
bBall.Z = bZpos
bZpos = bZpos-4
If bZpos <-30 Then
Me.TimerEnabled = 0
Me.DestroyBall
bsScoop.AddBall Me
End If
End Sub
Sub SolVUK(Enabled)
If Enabled And bsSVUK.Balls > 0 Then
Sw45.DestroyBall
bsSVUK.ExitSol_On
End If
end sub
'******************************************************
' Drop Targets
'******************************************************
'Drop Targets
' Sub Sw17_Dropped:dtL.Hit 1 :End Sub
' Sub Sw18_Dropped:dtL.Hit 2 :End Sub
' Sub Sw19_Dropped:dtL.Hit 3 :End Sub
' Sub Sw20_Dropped:dtL.Hit 4 :End Sub
' Sub Sw21_Dropped:dtR.Hit 1 :End Sub
' Sub Sw22_Dropped:dtR.Hit 2 :End Sub
' Sub Sw23_Dropped:dtR.Hit 3 :End Sub
' Sub Sw24_Dropped:dtR.Hit 4 :End Sub
Sub Sw17_Hit : DTHit 17 : End Sub
Sub Sw18_Hit : DTHit 18 : End Sub
Sub Sw19_Hit : DTHit 19 : End Sub
Sub Sw20_Hit : DTHit 20 : End Sub
Sub Sw21_Hit : DTHit 21 : End Sub
Sub Sw22_Hit : DTHit 22 : End Sub
Sub Sw23_Hit : DTHit 23 : End Sub
Sub Sw24_Hit : DTHit 24 : End Sub
Sub SolRDTBank(enabled)
if enabled then
PlaySound SoundFX(DTResetSound,DOFDropTargets)
DTRaise 21
DTRaise 22
DTRaise 23
DTRaise 24
end if
End Sub
Sub SolLDTBank(enabled)
if enabled then
PlaySound SoundFX(DTResetSound,DOFDropTargets)
DTRaise 17
DTRaise 18
DTRaise 19
DTRaise 20
end if
End Sub
'******************************************************
' DROP TARGETS INITIALIZATION
'******************************************************
Class DropTarget
Private m_primary, m_secondary, m_prim, m_sw, m_animate, m_isDropped
Public Property Get Primary(): Set Primary = m_primary: End Property
Public Property Let Primary(input): Set m_primary = input: End Property
Public Property Get Secondary(): Set Secondary = m_secondary: End Property
Public Property Let Secondary(input): Set m_secondary = input: End Property
Public Property Get Prim(): Set Prim = m_prim: End Property
Public Property Let Prim(input): Set m_prim = input: End Property
Public Property Get Sw(): Sw = m_sw: End Property
Public Property Let Sw(input): m_sw = input: End Property
Public Property Get Animate(): Animate = m_animate: End Property
Public Property Let Animate(input): m_animate = input: End Property
Public Property Get IsDropped(): IsDropped = m_isDropped: End Property
Public Property Let IsDropped(input): m_isDropped = input: End Property
Public default Function init(primary, secondary, prim, sw, animate, isDropped)
Set m_primary = primary
Set m_secondary = secondary
Set m_prim = prim
m_sw = sw
m_animate = animate
m_isDropped = isDropped
Set Init = Me
End Function
End Class
'Define a variable for each drop target
Dim DT21, DT22, DT23, DT24, DT17, DT18, DT19, DT20 ', DT21, DT33, DT34, DT35, DT36
'Set array with drop target objects
'
'DropTargetvar = Array(primary, secondary, prim, swtich, animate)
' primary: primary target wall to determine drop
' secondary: wall used to simulate the ball striking a bent or offset target after the initial Hit
' prim: primitive target used for visuals and animation
' IMPORTANT!!!
' rotz must be used for orientation
' rotx to bend the target back
' transz to move it up and down
' the pivot point should be in the center of the target on the x, y and at or below the playfield (0) on z
' switch: ROM switch number
' animate: Arrary slot for handling the animation instrucitons, set to 0
'
' Values for annimate: 1 - bend target (hit to primary), 2 - drop target (hit to secondary), 3 - brick target (high velocity hit to secondary), -1 - raise target
' Top Bank
Set DT21 = (new DropTarget)(sw21, sw21offset, primsw21, 21, 0, false)
Set DT22 = (new DropTarget)(sw22, sw22offset, primsw22, 22, 0, false)
Set DT23 = (new DropTarget)(sw23, sw23offset, primsw23, 23, 0, false)
Set DT24 = (new DropTarget)(sw24, sw24offset, primsw24, 24, 0, false)
Set DT17 = (new DropTarget)(sw17, sw17offset, primsw17, 17, 0, false)
Set DT18 = (new DropTarget)(sw18, sw18offset, primsw18, 18, 0, false)
Set DT19 = (new DropTarget)(sw19, sw19offset, primsw19, 19, 0, false)
Set DT20 = (new DropTarget)(sw20, sw20offset, primsw20, 20, 0, false)
'Set DT33 = (new DropTarget)(sw33, sw33offset, primsw33, 33, 0, false)
'Set DT34 = (new DropTarget)(sw34, sw34offset, primsw34, 34, 0, false)
'Set DT35 = (new DropTarget)(sw35, sw35offset, primsw35, 35, 0, false)
'Set DT36 = (new DropTarget)(sw36, sw36offset, primsw36, 36, 0, false)
'Add all the Drop Target Arrays to Drop Target Animation Array
' DTAnimationArray = Array(DT1, DT2, ....)
Dim DTArray
DTArray = Array(DT21, DT22, DT23, DT24, DT17, DT18, DT19, DT20)
'Configure the behavior of Drop Targets.
Const DTDropSpeed = 110 'in milliseconds
Const DTDropUpSpeed = 40 'in milliseconds
Const DTDropUnits = 44 'VP units primitive drops
Const DTDropUpUnits = 10 'VP units primitive raises above the up position on drops up
Const DTMaxBend = 8 'max degrees primitive rotates when hit
Const DTDropDelay = 20 'time in milliseconds before target drops (due to friction/impact of the ball)
Const DTRaiseDelay = 40 'time in milliseconds before target drops back to normal up position after the solendoid fires to raise the target
Const DTBrickVel = 0 'velocity at which the target will brick, set to '0' to disable brick
Const DTEnableBrick = 0 'Set to 0 to disable bricking, 1 to enable bricking
'Const DTHitSound = "target" 'Drop Target Hit sound
Const DTDropSound = "DTDrop" 'Drop Target Drop sound
Const DTResetSound = "DTReset" 'Drop Target reset sound
Const DTMass = 0.2 'Mass of the Drop Target (between 0 and 1), higher values provide more resistance
'******************************************************
' DROP TARGETS FUNCTIONS
'******************************************************
Sub DTHit(switch)
Dim i
i = DTArrayID(switch)
PlayTargetSound
DTArray(i).animate = DTCheckBrick(Activeball,DTArray(i).prim)
If DTArray(i).animate = 1 or DTArray(i).animate = 3 or DTArray(i).animate = 4 Then
DTBallPhysics Activeball, DTArray(i).prim.rotz, DTMass
End If
DoDTAnim
End Sub
Sub DTRaise(switch)
Dim i
i = DTArrayID(switch)
DTArray(i).animate = -1
DoDTAnim
End Sub
Sub DTDrop(switch)
Dim i
i = DTArrayID(switch)
DTArray(i).animate = 1
DoDTAnim
End Sub
Function DTArrayID(switch)
Dim i
For i = 0 to uBound(DTArray)
If DTArray(i).sw = switch Then DTArrayID = i:Exit Function
Next
End Function
sub DTBallPhysics(aBall, angle, mass)
dim rangle,bangle,calc1, calc2, calc3
rangle = (angle - 90) * 3.1416 / 180
bangle = atn2(cor.ballvely(aball.id),cor.ballvelx(aball.id))
calc1 = cor.BallVel(aball.id) * cos(bangle - rangle) * (aball.mass - mass) / (aball.mass + mass)
calc2 = cor.BallVel(aball.id) * sin(bangle - rangle) * cos(rangle + 4*Atn(1)/2)
calc3 = cor.BallVel(aball.id) * sin(bangle - rangle) * sin(rangle + 4*Atn(1)/2)
aBall.velx = calc1 * cos(rangle) + calc2
aBall.vely = calc1 * sin(rangle) + calc3
End Sub
'Check if target is hit on it's face or sides and whether a 'brick' occurred
Function DTCheckBrick(aBall, dtprim)
dim bangle, bangleafter, rangle, rangle2, Xintersect, Yintersect, cdist, perpvel, perpvelafter, paravel, paravelafter
rangle = (dtprim.rotz - 90) * 3.1416 / 180
rangle2 = dtprim.rotz * 3.1416 / 180
bangle = atn2(cor.ballvely(aball.id),cor.ballvelx(aball.id))
bangleafter = Atn2(aBall.vely,aball.velx)
Xintersect = (aBall.y - dtprim.y - tan(bangle) * aball.x + tan(rangle2) * dtprim.x) / (tan(rangle2) - tan(bangle))
Yintersect = tan(rangle2) * Xintersect + (dtprim.y - tan(rangle2) * dtprim.x)
cdist = Distance(dtprim.x, dtprim.y, Xintersect, Yintersect)
perpvel = cor.BallVel(aball.id) * cos(bangle-rangle)
paravel = cor.BallVel(aball.id) * sin(bangle-rangle)
perpvelafter = BallSpeed(aBall) * cos(bangleafter - rangle)
paravelafter = BallSpeed(aBall) * sin(bangleafter - rangle)
If perpvel > 0 and perpvelafter <= 0 Then
If DTEnableBrick = 1 and perpvel > DTBrickVel and DTBrickVel <> 0 and cdist < 8 Then
DTCheckBrick = 3
Else
DTCheckBrick = 1
End If
ElseIf perpvel > 0 and ((paravel > 0 and paravelafter > 0) or (paravel < 0 and paravelafter < 0)) Then
DTCheckBrick = 4
Else
DTCheckBrick = 0
End If
End Function
Sub DoDTAnim()
Dim i
For i=0 to Ubound(DTArray)
DTArray(i).animate = DTAnimate(DTArray(i).primary,DTArray(i).secondary,DTArray(i).prim,DTArray(i).sw,DTArray(i).animate)
Next
End Sub
Function DTAnimate(primary, secondary, prim, switch, animate)
dim transz, switchid
Dim animtime, rangle
switchid = switch
rangle = prim.rotz * PI / 180
DTAnimate = animate
if animate = 0 Then
primary.uservalue = 0
DTAnimate = 0
Exit Function
Elseif primary.uservalue = 0 then
primary.uservalue = gametime
end if
animtime = gametime - primary.uservalue
If (animate = 1 or animate = 4) and animtime < DTDropDelay Then
primary.collidable = 0
If animate = 1 then secondary.collidable = 1 else secondary.collidable= 0
prim.rotx = DTMaxBend * cos(rangle)
prim.roty = DTMaxBend * sin(rangle)
DTAnimate = animate
Exit Function
elseif (animate = 1 or animate = 4) and animtime > DTDropDelay Then
primary.collidable = 0
If animate = 1 then secondary.collidable = 1 else secondary.collidable= 0
prim.rotx = DTMaxBend * cos(rangle)
prim.roty = DTMaxBend * sin(rangle)
animate = 2
SoundDropTargetDrop prim
End If
if animate = 2 Then
transz = (animtime - DTDropDelay)/DTDropSpeed * DTDropUnits * -1
if prim.transz > -DTDropUnits Then
prim.transz = transz
end if
prim.rotx = DTMaxBend * cos(rangle)/2
prim.roty = DTMaxBend * sin(rangle)/2
if prim.transz <= -DTDropUnits Then
prim.transz = -DTDropUnits
secondary.collidable = 0
if UsingROM then
controller.Switch(Switchid) = 1
else
DTAction switchid
end if
primary.uservalue = 0
DTAnimate = 0
Exit Function
Else
DTAnimate = 2
Exit Function
end If
End If
If animate = 3 and animtime < DTDropDelay Then
primary.collidable = 0
secondary.collidable = 1
prim.rotx = DTMaxBend * cos(rangle)
prim.roty = DTMaxBend * sin(rangle)
elseif animate = 3 and animtime > DTDropDelay Then
primary.collidable = 1
secondary.collidable = 0
prim.rotx = 0
prim.roty = 0
primary.uservalue = 0
DTAnimate = 0
Exit Function
End If
if animate = -1 Then
transz = (1 - (animtime)/DTDropUpSpeed) * DTDropUnits * -1
If prim.transz = -DTDropUnits Then
Dim BOT, b
BOT = GetBalls
For b = 0 to UBound(BOT)
If InRotRect(BOT(b).x,BOT(b).y,prim.x, prim.y, prim.rotz, -25,-10,25,-10,25,25,-25,25) and BOT(b).z < prim.z+DTDropUnits+25 Then
BOT(b).velz = 20
End If
Next
End If
if prim.transz < 0 Then
prim.transz = transz
elseif transz > 0 then
prim.transz = transz
end if
if prim.transz > DTDropUpUnits then
DTAnimate = -2
prim.transz = DTDropUpUnits
prim.rotx = 0
prim.roty = 0
primary.uservalue = gametime
end if
primary.collidable = 0
secondary.collidable = 1
if UsingROM then controller.Switch(Switchid) = 0
End If
if animate = -2 and animtime > DTRaiseDelay Then
prim.transz = (animtime - DTRaiseDelay)/DTDropSpeed * DTDropUnits * -1 + DTDropUpUnits
if prim.transz < 0 then
prim.transz = 0
primary.uservalue = 0
DTAnimate = 0
primary.collidable = 1
secondary.collidable = 0
end If
End If
End Function
Sub DTAction(switchid)
Select Case switchid
Case 1:
ShadowDT(0).visible=False
Case 2:
ShadowDT(1).visible=False
Case 3:
ShadowDT(2).visible=False
End Select
End Sub
'******************************************************
' DROP TARGET
' SUPPORTING FUNCTIONS
'******************************************************
' Used for drop targets
'*** Determines if a Points (px,py) is inside a 4 point polygon A-D in Clockwise/CCW order
Function InRect(px,py,ax,ay,bx,by,cx,cy,dx,dy)
Dim AB, BC, CD, DA
AB = (bx*py) - (by*px) - (ax*py) + (ay*px) + (ax*by) - (ay*bx)
BC = (cx*py) - (cy*px) - (bx*py) + (by*px) + (bx*cy) - (by*cx)
CD = (dx*py) - (dy*px) - (cx*py) + (cy*px) + (cx*dy) - (cy*dx)
DA = (ax*py) - (ay*px) - (dx*py) + (dy*px) + (dx*ay) - (dy*ax)
If (AB <= 0 AND BC <=0 AND CD <= 0 AND DA <= 0) Or (AB >= 0 AND BC >=0 AND CD >= 0 AND DA >= 0) Then
InRect = True
Else
InRect = False
End If
End Function
Function InRotRect(ballx,bally,px,py,angle,ax,ay,bx,by,cx,cy,dx,dy)
Dim rax,ray,rbx,rby,rcx,rcy,rdx,rdy
Dim rotxy
rotxy = RotPoint(ax,ay,angle)
rax = rotxy(0)+px : ray = rotxy(1)+py
rotxy = RotPoint(bx,by,angle)
rbx = rotxy(0)+px : rby = rotxy(1)+py
rotxy = RotPoint(cx,cy,angle)
rcx = rotxy(0)+px : rcy = rotxy(1)+py
rotxy = RotPoint(dx,dy,angle)
rdx = rotxy(0)+px : rdy = rotxy(1)+py
InRotRect = InRect(ballx,bally,rax,ray,rbx,rby,rcx,rcy,rdx,rdy)
End Function
Function RotPoint(x,y,angle)
dim rx, ry
rx = x*dCos(angle) - y*dSin(angle)
ry = x*dSin(angle) + y*dCos(angle)
RotPoint = Array(rx,ry)
End Function
'******************************************************
'**** END DROP TARGETS
'******************************************************
'******************************************************
' STAND-UP TARGET INITIALIZATION
'******************************************************
Class StandupTarget
Private m_primary, m_prim, m_sw, m_animate
Public Property Get Primary(): Set Primary = m_primary: End Property
Public Property Let Primary(input): Set m_primary = input: End Property