forked from LegendsUnchained/vpx-standalone-alp4k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenie (Gottlieb 1979).vbs
3333 lines (2798 loc) · 119 KB
/
Genie (Gottlieb 1979).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
'************************************************************
'************************************************************
'
' Genie / IPD No. 997 / October, 1979 / 4 Players
'
' Credits:
'
' VPX by bord, rothbauerw
'
' VR Rooms - TOTAN by Flupper, 360 added by Rajo Joey, Minimal added by Rajo Joey
' VR Cabinet - Rajo Joey, rothbauerw
' VR/Backglass - Backglass by blacksad, converted by rothbauerw
'
'
'************************************************************
'************************************************************
Option Explicit
Randomize
'******************************************************
' OPTIONS
'******************************************************
' Use Magnasave to select between Totan, 360, and Minimal Rooms
Const VRRoom = 0 '1 - VR, '0 - Desktop, Fullscreen, FSS
Const CabinetMode = 0 '1 - hides backbox, rails, and lockdown bar
' Enable Drop Target Bricking
Const DTEnableBrick = 0 '0 - disable, 1 - enable
' Enhance micro bounces on flippers
Const Rubberizer = 1 '0 - disable, 1 - rothbauerw version, 2 - iaakki version
Const LibOrCons = 2 '1 for Liberal, 2 for Conservative (liberal also needs pf image set to pf_lib)
Const ChimesOn = 0 '1 to use Chimes, 0 to turn them off
'///////////////////////-----General Sound Options-----///////////////////////
'// 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
'******************************************************
' STANDARD DEFINITIONS
'******************************************************
Dim BallMass ,BallSize
Ballsize = 50
Ballmass = 1.0
Const UseSolenoids=2
Const UseLamps=1
Const UseSync=1
Const UseGI=0
' Standard Sounds
Const SSolenoidOn = ""
Const SSolenoidOff = ""
Const SFlipperOn = ""
Const SFlipperOff = ""
'******************************************************
' TABLE INIT
'******************************************************
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"01120100","GTS1.VBS",3.02
Const cGameName="genie"
Dim DesktopMode: DesktopMode = Table1.ShowDT
' using table width and height in script slows down the performance
dim tablewidth: tablewidth = Table1.width
dim tableheight: tableheight = Table1.height
'*********** Desktop/Cabinet settings ************************
Dim GenieBall, xx
Sub Table1_Init
vpmInit Me
With Controller
.GameName=cGameName
If Err Then MsgBox "Can't start Game " & cGameName & vbNewLine & Err.Description:Exit Sub
.SplashInfoLine="Genie (Gottlieb 1979)"
.HandleKeyboard=0
.ShowTitle=0
.ShowDMDOnly=1
.ShowFrame=0
.Hidden = 1
On Error Resume Next
.SolMask(0) = 0
vpmTimer.AddTimer 1000, "Controller.SolMask(0)=&Hffffffff'" 'ignore all solenoids - then add the timer to renable all the solenoids after 1 seconds
.Run GetPlayerHWnd
If Err Then MsgBox Err.Description
On Error Goto 0
End With
' Nudging
PinMAMETimer.Interval=PinMAMEInterval
PinMAMETimer.Enabled = 1
vpmNudge.TiltSwitch = 4
vpmNudge.Sensitivity = 3
vpmNudge.TiltObj = Array(LeftSlingshot, Bumper1, Bumper2, Bumper3)
Set GenieBall = Drain.CreateSizedballWithMass(Ballsize/2,Ballmass)
Controller.Switch(66) = 1
If LibOrCons = 1 Then
For each xx in physics_lib
xx.collidable = True
Next
For each xx in visible_lib
xx.visible = True
Next
For each xx in physics_cons
xx.collidable = false
Next
For each xx in visible_cons
xx.visible = False
Next
Else
For each xx in physics_lib
xx.collidable = False
Next
For each xx in visible_lib
xx.visible = False
Next
For each xx in physics_cons
xx.collidable = True
Next
For each xx in visible_cons
xx.visible = True
Next
End If
If VRRoom = 1 then
VRRoomSel = LoadValue("Genie", "V1.0.0")
If VRRoomSel = "" Then VRRoomSel = 2
VRChangeRoom
End If
If CabinetMode = 1 Then
VR_Backbox.visible=False
VR_SideRails.visible=False
VR_Lockdownbar.visible=False
End If
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
'******************************************************
dim plungerpress
Sub Table1_KeyDown(ByVal keycode)
If keycode = PlungerKey Then Plunger.Pullback : SoundPlungerPull(): plungerpress = 1
If keycode = LeftFlipperKey Then
FlipperActivate LeftFlipper, LFPress
FlipperActivate LeftFlipper1, LFPress1
VR_CabFlipperLeft.transx = 10
End If
If keycode = RightFlipperKey Then
FlipperActivate RightFlipper, RFPress
FlipperActivate RightFlipper1, RFPress1
FlipperActivate RightFlipper2, RFPress2
VR_CabFlipperRight.transx = -10
End If
If keycode = StartGameKey Then
SoundStartButton
VR_Cab_StartButton.transx = -5
End If
' Change VR-Room with magna-save buttons
If VRRoom = 1 Then
If keycode = leftmagnasave then
vrroomsel = vrroomsel - 1
if vrroomsel < 0 then vrroomsel = 2
VRChangeRoom
End If
If keycode = rightmagnasave then
vrroomsel = vrroomsel + 1
if vrroomsel > 2 then vrroomsel = 0
VRChangeRoom
End If
End If
If keycode = LeftTiltKey Then Nudge 90, 4 : SoundNudgeLeft()
If keycode = RightTiltKey Then Nudge 270, 4 : SoundNudgeRight()
If keycode = CenterTiltKey Then Nudge 0, 5 : SoundNudgeCenter()
If keycode = keyInsertCoin1 or keycode = keyInsertCoin2 or keycode = keyInsertCoin3 or keycode = keyInsertCoin4 or keycode = AddCreditKey Then
Select Case Int(rnd*3)
Case 0: PlaySoundAtLevelStatic ("Coin_In_1"), CoinSoundLevel, Drain
Case 1: PlaySoundAtLevelStatic ("Coin_In_2"), CoinSoundLevel, Drain
Case 2: PlaySoundAtLevelStatic ("Coin_In_3"), CoinSoundLevel, Drain
End Select
End If
If vpmKeyDown(KeyCode) Then Exit Sub
End Sub
Sub Table1_KeyUp(ByVal keycode)
If keycode = PlungerKey Then
Plunger.Fire
If GenieBall.x > 1175 and GenieBall.y > 1910 Then 'If true then ball in shooter lane, else no ball is shooter lane
SoundPlungerReleaseBall() 'Plunger release sound when there is a ball in shooter lane
Else
SoundPlungerReleaseNoBall() 'Plunger release sound when there is no ball in shooter lane
End If
plungerpress = 0
End If
If keycode = LeftFlipperKey Then
FlipperDeActivate LeftFlipper, LFPress
FlipperDeActivate LeftFlipper1, LFPress1
VR_CabFlipperLeft.transx = 0
End If
If keycode = RightFlipperKey Then
FlipperDeActivate RightFlipper, RFPress
FlipperDeActivate RightFlipper1, RFPress1
FlipperDeActivate RightFlipper2, RFPress2
VR_CabFlipperRight.transx = 0
End If
If keycode = StartGameKey Then
VR_Cab_StartButton.transx = 0
End If
If vpmKeyUp(KeyCode) Then Exit Sub
End Sub
'******************************************************
' SOLENOIDS
'******************************************************
SolCallback(1) = "SolRelease"
SolCallback(2) = "SolKnocker"
SolCallback(3) = "SolChime1"
SolCallback(4) = "SolChime2"
SolCallback(5) = "SolChime3"
SolCallback(6) = "SollSaucer"
SolCallback(7) = "SolRightDrop"
SolCallback(8) = "SolLeftDrop"
SolCallback(17) = "vpmNudge.SolGameOn"
'******************************************************
' Chimes (Optional)
'******************************************************
Sub solchime1(Enable)
If Enable then
If ChimesOn=1 Then
PlaySound SoundFX("sj_chime_10a",DOFChimes), 1, 1
DOF 125, 2
End If
End If
End Sub
Sub solchime2(Enable)
If Enable then
If ChimesOn=1 Then
PlaySound SoundFX("sj_chime_100a",DOFChimes), 1, 1
DOF 126, 2
End If
End If
End Sub
Sub solchime3(Enable)
If Enable then
If ChimesOn=1 Then
PlaySound SoundFX("sj_chime_1000a",DOFChimes), 1, 1
DOF 127, 2
End If
End If
End Sub
'******************************************************
' KNOCKER
'******************************************************
Sub SolKnocker(Enabled)
If enabled Then
KnockerSolenoid
End If
End Sub
'******************************************************
' FLIPPERS
'******************************************************
Const ReflipAngle = 20
SolCallback(sLRFlipper) = "SolRFlipper"
SolCallback(sLLFlipper) = "SolLFlipper"
Sub SolLFlipper(Enabled)
If Enabled Then
LF.Fire
LeftFlipper1.RotateToEnd
If leftflipper.currentangle < leftflipper.endangle + ReflipAngle Then
RandomSoundReflipUpLeft LeftFlipper
Else
SoundFlipperUpAttackLeft LeftFlipper
RandomSoundFlipperUpLeft LeftFlipper
End If
If leftflipper1.currentangle < leftflipper1.endangle + ReflipAngle Then
RandomSoundReflipUpLeft LeftFlipper1
Else
SoundFlipperUpAttackLeft LeftFlipper1
RandomSoundFlipperUpLeft LeftFlipper1
End If
PlaySoundAtVolLoops "buzzL",LeftFlipper,0.05,-1
Else
LeftFlipper.RotateToStart
LeftFlipper1.RotateToStart
If LeftFlipper.currentangle < LeftFlipper.startAngle - 5 Then
RandomSoundFlipperDownLeft LeftFlipper
End If
If LeftFlipper1.currentangle < LeftFlipper1.startAngle - 5 Then
RandomSoundFlipperDownLeft LeftFlipper1
End If
FlipperLeftHitParm = FlipperUpSoundLevel
Stopsound "buzzL"
End If
End Sub
Sub SolRFlipper(Enabled)
If Enabled Then
RF.Fire
RightFlipper2.RotateToEnd
RF1.fire
If rightflipper.currentangle > rightflipper.endangle - ReflipAngle Then
RandomSoundReflipUpRight RightFlipper
Else
SoundFlipperUpAttackRight RightFlipper
RandomSoundFlipperUpRight RightFlipper
End If
If rightflipper1.currentangle > rightflipper1.endangle - ReflipAngle Then
RandomSoundReflipUpRight RightFlipper1
Else
SoundFlipperUpAttackRight RightFlipper1
RandomSoundFlipperUpRight RightFlipper1
End If
If rightflipper2.currentangle > rightflipper2.endangle - ReflipAngle Then
RandomSoundReflipUpRight RightFlipper2
Else
SoundFlipperUpAttackRight RightFlipper2
RandomSoundFlipperUpRight RightFlipper2
End If
PlaySoundAtVolLoops "buzz",RightFlipper,0.05,-1
Else
RightFlipper.RotateToStart
RightFlipper1.RotateToStart
RightFlipper2.RotateToStart
If RightFlipper.currentangle > RightFlipper.startAngle + 5 Then
RandomSoundFlipperDownRight RightFlipper
End If
If RightFlipper1.currentangle > RightFlipper1.startAngle + 5 Then
RandomSoundFlipperDownRight RightFlipper1
End If
If RightFlipper2.currentangle > RightFlipper2.startAngle + 5 Then
RandomSoundFlipperDownRight RightFlipper2
End If
FlipperRightHitParm = FlipperUpSoundLevel
StopSound "buzz"
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 DT20, DT21, DT23, DT24, DT30, DT70, DT31, DT71, DT60, DT74, DT61
'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
' Left Bank
Set DT20 = (new DropTarget)(sw20, csw20, layer3sw20, 20, 0, false)
Set DT21 = (new DropTarget)(sw21, csw21, layer3sw21, 21, 0, false)
Set DT23 = (new DropTarget)(sw23, csw23, layer3sw23, 23, 0, false)
Set DT24 = (new DropTarget)(sw24, csw24, layer3sw24, 24, 0, false)
Set DT30 = (new DropTarget)(sw30, csw30, layer3sw30, 30, 0, false)
Set DT70 = (new DropTarget)(sw70, csw70, layer3sw70, 70, 0, false)
Set DT31 = (new DropTarget)(sw31, csw31, layer3sw31, 31, 0, false)
Set DT71 = (new DropTarget)(sw71, csw71, layer3sw71, 71, 0, false)
Set DT60 = (new DropTarget)(sw60, csw60, layer3sw60, 60, 0, false)
Set DT74 = (new DropTarget)(sw74, csw74, layer3sw74, 74, 0, false)
Set DT61 = (new DropTarget)(sw61, csw61, layer3sw61, 61, 0, false)
'Add all the Drop Target Arrays to Drop Target Animation Array
' DTAnimationArray = Array(DT1, DT2, ....)
Dim DTArray
DTArray = Array(DT20, DT21, DT23, DT24, DT30, DT70, DT31, DT71, DT60, DT74, DT61)
'Configure the behavior of Drop Targets.
Const DTDropSpeed = 110 'in milliseconds
Const DTDropUpSpeed = 40 'in milliseconds
Const DTDropUnits = 43 'VP units primitive drops
Const DTDropUpUnits = 4 '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 solenoid fires to raise the target
Const DTBrickVel = 30 'velocity at which the target will brick, set to '0' to disable brick
' Moved to Options Const DTEnableBrick = 1 'Set to 0 to disable bricking, 1 to enable bricking
Const DTHitSound = "targethit" '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
'Add Timer name DTAnim to editor to handle drop target animations
DTAnim.interval = 10
DTAnim.enabled = True
Sub DTAnim_Timer()
DoDTAnim
DoSTAnim
If Layer3sw20.transz < -DTDropUnits/2 Then Flasher20.visible = 0 else Flasher20.visible = 1
If Layer3sw21.transz < -DTDropUnits/2 Then Flasher21.visible = 0 else Flasher21.visible = 1
If Layer3sw23.transz < -DTDropUnits/2 Then Flasher23.visible = 0 else Flasher23.visible = 1
If Layer3sw24.transz < -DTDropUnits/2 Then Flasher24.visible = 0 else Flasher24.visible = 1
If Layer3sw30.transz < -DTDropUnits/2 Then Flasher30.visible = 0 else Flasher30.visible = 1
If Layer3sw70.transz < -DTDropUnits/2 Then Flasher70.visible = 0 else Flasher70.visible = 1
If Layer3sw31.transz < -DTDropUnits/2 Then Flasher31.visible = 0 else Flasher31.visible = 1
If Layer3sw71.transz < -DTDropUnits/2 Then Flasher71.visible = 0 else Flasher71.visible = 1
If Layer3sw60.transz < -DTDropUnits/2 Then Flasher60.visible = 0 else Flasher60.visible = 1
If Layer3sw74.transz < -DTDropUnits/2 Then Flasher74.visible = 0 else Flasher74.visible = 1
If Layer3sw61.transz < -DTDropUnits/2 Then Flasher61.visible = 0 else Flasher61.visible = 1
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
Dim animtime, rangle
Dim disablerotx:disablerotx=0
rangle = prim.rotz * 3.1416 / 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
If disablerotx = 0 Then
prim.rotx = DTMaxBend * cos(rangle)
prim.roty = DTMaxBend * sin(rangle)
End If
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
If disablerotx = 0 Then
prim.rotx = DTMaxBend * cos(rangle)
prim.roty = DTMaxBend * sin(rangle)
End If
animate = 2
PlaySoundAt SoundFX(DTDropSound,DOFDropTargets),primary
End If
if animate = 2 Then
transz = (animtime - DTDropDelay)/DTDropSpeed * DTDropUnits * -1
if prim.transz > -DTDropUnits Then
prim.transz = transz
end if
If disablerotx = 0 Then
prim.rotx = DTMaxBend * cos(rangle)/2
prim.roty = DTMaxBend * sin(rangle)/2
End If
if prim.transz <= -DTDropUnits Then
prim.transz = -DTDropUnits
prim.blenddisablelighting = 0.2
secondary.collidable = 0
controller.Switch(Switch) = 1
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
If disablerotx = 0 Then
prim.rotx = DTMaxBend * cos(rangle)
prim.roty = DTMaxBend * sin(rangle)
End If
elseif animate = 3 and animtime > DTDropDelay Then
primary.collidable = 1
secondary.collidable = 0
If disablerotx = 0 Then
prim.rotx = 0
prim.roty = 0
End If
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.blenddisablelighting = 0.35
prim.transz = transz
elseif transz > 0 then
prim.transz = transz
end if
if prim.transz > DTDropUpUnits then
DTAnimate = -2
If disablerotx = 0 Then
prim.rotx = 0
prim.roty = 0
End If
primary.uservalue = gametime
end if
primary.collidable = 0
secondary.collidable = 1
controller.Switch(Switch) = 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
'******************************************************
' DROP TARGETS
'******************************************************
Sub sw20_Hit:DTHit 20:End Sub
Sub sw21_Hit:DTHit 21:End Sub
Sub sw23_Hit:DTHit 23:End Sub
Sub sw24_Hit:DTHit 24:End Sub
Sub sw30_Hit:DTHit 30:End Sub
Sub sw70_Hit:DTHit 70:End Sub
Sub sw31_Hit:DTHit 31:End Sub
Sub sw71_Hit:DTHit 71:End Sub
Sub sw60_Hit:DTHit 60:End Sub
Sub sw74_Hit:DTHit 74:End Sub
Sub sw61_Hit:DTHit 61:End Sub
Sub SolRightDrop(Enabled)
If Enabled Then
PlaySoundAt SoundFX(DTResetSound,DOFContactors), sw23
DTRaise 20
DTRaise 21
DTRaise 23
DTRaise 24
End if
End Sub
Sub SolLeftDrop(Enabled)
If Enabled Then
PlaySoundAt SoundFX(DTResetSound,DOFContactors), sw71
DTRaise 30
DTRaise 70
DTRaise 31
DTRaise 71
DTRaise 60
DTRaise 74
DTRaise 61
End If
End Sub
'******************************************************
' DROP TARGET
' SUPPORTING FUNCTIONS
'******************************************************
' Used for drop targets
Function Atn2(dy, dx)
dim pi
pi = 4*Atn(1)
If dx > 0 Then
Atn2 = Atn(dy / dx)
ElseIf dx < 0 Then
If dy = 0 Then
Atn2 = pi
Else
Atn2 = Sgn(dy) * (pi - Atn(Abs(dy / dx)))
end if
ElseIf dx = 0 Then
if dy = 0 Then
Atn2 = 0
else
Atn2 = Sgn(dy) * pi / 2
end if
End If
End Function
' 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
Function dSin(degrees)
dsin = sin(degrees * Pi/180)
End Function
Function dCos(degrees)
dcos = cos(degrees * Pi/180)
End Function
'******************************************************
' 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
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 default Function init(primary, prim, sw, animate)
Set m_primary = primary
Set m_prim = prim
m_sw = sw
m_animate = animate
Set Init = Me
End Function
End Class
'Define a variable for each stand-up target
Dim ST40, ST44, ST51, ST63
'Set array with stand-up target objects
'
'StandupTargetvar = Array(primary, prim, swtich)
' primary: vp target to determine target hit
' prim: primitive target used for visuals and animation
' IMPORTANT!!!
' transy must be used to offset the target animation
' switch: ROM switch number
' animate: Arrary slot for handling the animation instrucitons, set to 0
Set ST40 = (new StandupTarget)(sw40, Layer3sw40,40, 0)
Set ST44 = (new StandupTarget)(sw44, Layer3sw44,44, 0)
Set ST51 = (new StandupTarget)(sw51, Layer3sw51,51, 0)
Set ST63 = (new StandupTarget)(sw63, Layer3sw63,63, 0)
'Add all the Stand-up Target Arrays to Stand-up Target Animation Array
' STAnimationArray = Array(ST1, ST2, ....)
Dim STArray
STArray = Array(ST40, ST44, ST51, ST63)
'Configure the behavior of Stand-up Targets
Const STAnimStep = 1.5 'vpunits per animation step (control return to Start)
Const STMaxOffset = 9 'max vp units target moves when hit
Const STHitSound = "targethit" 'Stand-up Target Hit sound
Const STMass = 0.2 'Mass of the Stand-up Target (between 0 and 1), higher values provide more resistance
'******************************************************
' STAND-UP TARGETS FUNCTIONS
'******************************************************
Sub STHit(switch)
Dim i
i = STArrayID(switch)
PlayTargetSound
STArray(i).animate = STCheckHit(Activeball,STArray(i).primary)
If STArray(i).animate <> 0 Then
DTBallPhysics Activeball, STArray(i).primary.orientation, STMass
End If
DoSTAnim
End Sub
Function STArrayID(switch)
Dim i
For i = 0 to uBound(STArray)
If STArray(i).sw = switch Then STArrayID = i:Exit Function
Next
End Function
'Check if target is hit on it's face
Function STCheckHit(aBall, target)
dim bangle, bangleafter, rangle, rangle2, perpvel, perpvelafter, paravel, paravelafter
rangle = (target.orientation - 90) * 3.1416 / 180
bangle = atn2(cor.ballvely(aball.id),cor.ballvelx(aball.id))
bangleafter = Atn2(aBall.vely,aball.velx)
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
STCheckHit = 1
ElseIf perpvel > 0 and ((paravel > 0 and paravelafter > 0) or (paravel < 0 and paravelafter < 0)) Then
STCheckHit = 1
Else
STCheckHit = 0
End If
End Function
Sub DoSTAnim()
Dim i
For i=0 to Ubound(STArray)
STArray(i).animate = STAnimate(STArray(i).primary,STArray(i).prim,STArray(i).sw,STArray(i).animate)
Next
End Sub
Function STAnimate(primary, prim, switch, animate)
Dim animtime
STAnimate = animate
if animate = 0 Then
primary.uservalue = 0
STAnimate = 0
Exit Function
Elseif primary.uservalue = 0 then
primary.uservalue = gametime
end if
animtime = gametime - primary.uservalue
If animate = 1 Then
primary.collidable = 0
prim.transy = -STMaxOffset
vpmTimer.PulseSw switch
STAnimate = 2
Exit Function
elseif animate = 2 Then
prim.transy = prim.transy + STAnimStep
If prim.transy >= 0 Then
prim.transy = 0
primary.collidable = 1
STAnimate = 0
Exit Function
Else
STAnimate = 2