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 cGameName="hawkman",UseSolenoids=1,UseLamps=1,UseGI=0,SSolenoidOn="SolOn",SSolenoidOff="SolOff", SCoin="coin" LoadVPM "01200100","Taito.VBS",3.1 Dim DesktopMode: DesktopMode = Table1.ShowDT If DesktopMode = True Then 'Show Desktop components Ramp16.visible=1 Ramp15.visible=1 Primitive13.visible=1 Else Ramp16.visible=0 Ramp15.visible=0 Primitive13.visible=0 End if '************************************************************* 'Solenoid Call backs '********************************************************************************************************** SolCallback(1) = "bsTopEject.SolOut" 'Top Kicker SolCallback(2) = "bsTrough.SolOut" SolCallback(3) = "bsRightEject.SolOut" 'Right Kicker SolCallback(5) = "dtL2.SolDropUp" 'Left top 3 SolCallback(6) = "dtL.SolDropUp" 'Left bottom 3 SolCallback(7) = "dtT.SolDropUp" 'Top DT SolCallback(8) = "dtM.SolDropUp" 'Middle DT SolCallback(9) = "dtR.SolDropUp" 'Right DT SolCallback(18) = "vpmNudge.SolGameOn" SolCallback(sLRFlipper) = "SolRFlipper" SolCallback(sLLFlipper) = "SolLFlipper" Sub SolLFlipper(Enabled) If Enabled Then PlaySound SoundFX("fx_Flipperup",DOFFlippers):LeftFlipper.RotateToEnd Else PlaySound SoundFX("fx_Flipperdown",DOFFlippers):LeftFlipper.RotateToStart End If End Sub Sub SolRFlipper(Enabled) If Enabled Then PlaySound SoundFX("fx_Flipperup",DOFFlippers):RightFlipper.RotateToEnd:RightFlipper1.RotateToEnd Else PlaySound SoundFX("fx_Flipperdown",DOFFlippers):RightFlipper.RotateToStart:RightFlipper1.RotateToStart End If End Sub '********************************************************************************************************** 'Solenoid Controlled toys '********************************************************************************************************** '*****GI Lights On dim xx For each xx in GI:xx.State = 1: Next 'Primitive Gate Sub FlipperTimer_Timer PrimGate2.Rotz = Gate7.Currentangle End Sub '********************************************************************************************************** 'Initiate Table '********************************************************************************************************** Dim bsTrough, bsRightEject, bsTopEject, dtT, dtL, dtL2, dtM, 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 = "Taito Hawkman"&chr(13)&"You Suck" .HandleMechanics=0 .HandleKeyboard=0 .ShowDMDOnly=1 .ShowFrame=0 .ShowTitle=0 .hidden = 1 If Err Then MsgBox Err.Description End With On Error Goto 0 Controller.SolMask(0)=0 vpmTimer.AddTimer 2000,"Controller.SolMask(0)=&Hffffffff'" 'ignore all solenoids - then add the timer to renable all the solenoids after 2 seconds Controller.Run If Err Then MsgBox Err.Description On Error Goto 0 PinMAMETimer.Interval=PinMAMEInterval PinMAMETimer.Enabled=1 vpmNudge.TiltSwitch = 30 vpmNudge.Sensitivity = 5 vpmNudge.Tiltobj = Array(LeftSlingshot,RightSlingshot,Bumper1,Bumper2,Bumper3) ' Trough Set bsTrough=New cvpmBallStack bsTrough.InitSw 0,51,41,31,0,0,0,0 bsTrough.InitKick BallRelease,180,3 bsTrough.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors) bsTrough.Balls=3 ' Top Saucer Set bsTopEject = New cvpmBallStack bsTopEject.InitSaucer sw1, 1, 275, 13 bsTopEject.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors) ' Right Saucer Set bsRightEject = New cvpmBallStack bsRightEject.InitSaucer sw3, 3, 180, 9 bsRightEject.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors) Set dtL=New cvpmDropTarget dtL.InitDrop Array(sw13,sw23,sw33),Array(13,23,33) dtL.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors) Set dtL2=New cvpmDropTarget dtL2.InitDrop Array(sw43,sw53,sw63),Array(43,53,63) dtL2.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors) Set dtM=New cvpmDropTarget dtM.InitDrop Array(sw54,sw64,sw74),Array(54,64,74) dtM.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors) Set dtR=New cvpmDropTarget dtR.InitDrop Array(sw42,sw52,sw62),Array(42,52,62) dtR.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors) Set dtT=New cvpmDropTarget dtT.InitDrop Array(sw2,sw12,sw22),Array(2,12,22) dtT.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors) End Sub '********************************************************************************************************** 'Plunger code '********************************************************************************************************** Sub Table1_KeyDown(ByVal KeyCode) If KeyDownHandler(keycode) Then Exit Sub If keycode = PlungerKey Then Plunger.Pullback:playsound"plungerpull" If keycode = RightFlipperKey Then Controller.Switch(72) = 1 End Sub Sub Table1_KeyUp(ByVal KeyCode) If KeyUpHandler(keycode) Then Exit Sub If keycode = PlungerKey Then Plunger.Fire:PlaySound"plunger" If keycode = RightFlipperKey Then Controller.Switch(72) = 0 End Sub '********************************************************************************************************** 'Drain hole Sub Drain_Hit:playsound"drain":bsTrough.addball me:End Sub Sub sw1_Hit() : bsTopEject.Addball 0 : playsound SoundFX("popper_ball",DOFContactors): End Sub Sub sw3_Hit() : bsRightEject.Addball 0 : playsound SoundFX("popper_ball",DOFContactors): End Sub 'Stand Up Target Sub sw61_Hit : vpmTimer.PulseSw(61) : End Sub 'Spinners Sub sw18_Spin:vpmTimer.PulseSw 32 : playsound"fx_spinner" : End Sub 'Scoring rubber Sub sw11_Hit(): vpmtimer.pulsesw 11 : playsound"rubber_hit_3" : End Sub Sub sw11a_Hit(): vpmtimer.pulsesw 11 : playsound"rubber_hit_3" : End Sub 'Wire Triggers Sub SW25_Hit:Controller.Switch(25)=1 : playsound"rollover" : End Sub Sub SW25_unHit:Controller.Switch(25)=0:End Sub Sub SW35_Hit:Controller.Switch(35)=1 : playsound"rollover" : End Sub Sub SW35_unHit:Controller.Switch(35)=0:End Sub Sub SW45_Hit:Controller.Switch(45)=1 : playsound"rollover" : End Sub Sub SW45_unHit:Controller.Switch(45)=0:End Sub Sub SW21_Hit:Controller.Switch(21)=1 : playsound"rollover" : End Sub Sub SW21_unHit:Controller.Switch(21)=0:End Sub Sub SW55_Hit:Controller.Switch(55)=1 : playsound"rollover" : End Sub Sub SW55_unHit:Controller.Switch(55)=0:End Sub Sub SW65_Hit:Controller.Switch(65)=1 : playsound"rollover" : End Sub Sub SW65_unHit:Controller.Switch(65)=0:End Sub Sub SW75_Hit:Controller.Switch(75)=1 : playsound"rollover" : End Sub Sub SW75_unHit:Controller.Switch(75)=0:End Sub 'Star Triggers Sub SW4_Hit:Controller.Switch(4)=1 : playsound"rollover" : End Sub Sub SW4_unHit:Controller.Switch(4)=0:End Sub Sub SW14_Hit:Controller.Switch(14)=1 : playsound"rollover" : End Sub Sub SW14_unHit:Controller.Switch(14)=0:End Sub Sub SW24_Hit:Controller.Switch(24)=1 : playsound"rollover" : End Sub Sub SW24_unHit:Controller.Switch(24)=0:End Sub Sub SW34_Hit:Controller.Switch(34)=1 : playsound"rollover" : End Sub Sub SW34_unHit:Controller.Switch(34)=0:End Sub 'Bumpers Sub Bumper1_Hit : vpmTimer.PulseSw(44) : playsound SoundFXDOF("fx_bumper1",101,DOFPulse,DOFContactors): End Sub Sub Bumper2_Hit : vpmTimer.PulseSw(44) : playsound SoundFXDOF("fx_bumper1",102,DOFPulse,DOFContactors): End Sub Sub Bumper3_Hit : vpmTimer.PulseSw(44) : playsound SoundFXDOF("fx_bumper1",103,DOFPulse,DOFContactors): End Sub 'Drop Targets Sub sw13_Dropped:dtL.Hit 1:End Sub Sub sw23_Dropped:dtL.Hit 2:End Sub Sub sw33_Dropped:dtL.Hit 3:End Sub Sub sw43_Dropped:dtL2.Hit 1:End Sub Sub sw53_Dropped:dtL2.Hit 2:End Sub Sub sw63_Dropped:dtL2.Hit 3:End Sub Sub sw54_Dropped:dtM.Hit 1:End Sub Sub sw64_Dropped:dtM.Hit 2:End Sub Sub sw74_Dropped:dtM.Hit 3:End Sub Sub sw42_Dropped:dtR.Hit 1:End Sub Sub sw52_Dropped:dtR.Hit 2:End Sub Sub sw62_Dropped:dtR.Hit 3:End Sub Sub sw2_Dropped :dtT.Hit 1:End Sub Sub sw12_Dropped:dtT.Hit 2:End Sub Sub sw22_Dropped:dtT.Hit 3:End Sub Set Lights(0)=L0 Set Lights(1)=L1 Set Lights(2)=L2 Set Lights(10)=L10 Set Lights(11)=L11 Set Lights(12)=L12 Set Lights(20)=L20 Set Lights(21)=L21 Set Lights(22)=L22 Set Lights(30)=L30 Set Lights(31)=L31 Set Lights(32)=L32 Set Lights(40)=L40 Set Lights(41)=L41 Set Lights(42)=L42 Set Lights(50)=L50 Set Lights(51)=L51 Set Lights(52)=L52 Set Lights(60)=L60 Set Lights(61)=L61 Set Lights(62)=L62 Set Lights(70)=L70 Set Lights(71)=L71 Set Lights(72)=L72 Set Lights(79)=L79 Set Lights(80)=L80 Set Lights(81)=L81 Lights(82)=array(L82,L82a) Set Lights(83)=L83 Set Lights(89)=L89 Set Lights(90)=L90 Set Lights(91)=L91 Lights(92)=array(L92,L92a) Set Lights(93)=L93 Set Lights(99)=L99 Set Lights(100)=L100 Set Lights(101)=L101 Set Lights(102)=L102 Set Lights(103)=L103 Set Lights(110)=L110 Set Lights(111)=L111 Set Lights(112)=L112 Set Lights(113)=L113 Set Lights(119)=L119 Set Lights(120)=L120 Set Lights(121)=L121 Set Lights(122)=L122 Set Lights(123)=L123 Set Lights(129)=L129 Set Lights(130)=L130 Set Lights(131)=L131 Set Lights(132)=L132 Set Lights(133)=L133 Set Lights(143)=L143 Lights(151)=array(L151a,L151b,L151c,L151d,L151e,L151f,L151g,L151h,L151i) 'Bumpers Set Lights(153)=L153 'BackGlass 'Set Lights(149)=L149 'Game Over 'Set Lights(150)=L150 'Tilt 'Set Lights(152)=L152 'New Record '********************************************************************************************************** 'Digital Display '********************************************************************************************************** Dim Digits(28) ' 1st Player Digits(0) = Array(LED10,LED11,LED12,LED13,LED14,LED15,LED16) Digits(1) = Array(LED20,LED21,LED22,LED23,LED24,LED25,LED26) Digits(2) = Array(LED30,LED31,LED32,LED33,LED34,LED35,LED36) Digits(3) = Array(LED40,LED41,LED42,LED43,LED44,LED45,LED46) Digits(4) = Array(LED50,LED51,LED52,LED53,LED54,LED55,LED56) Digits(5) = Array(LED60,LED61,LED62,LED63,LED64,LED65,LED66) ' 2nd Player Digits(6) = Array(LED80,LED81,LED82,LED83,LED84,LED85,LED86) Digits(7) = Array(LED90,LED91,LED92,LED93,LED94,LED95,LED96) Digits(8) = Array(LED100,LED101,LED102,LED103,LED104,LED105,LED106) Digits(9) = Array(LED110,LED111,LED112,LED113,LED114,LED115,LED116) Digits(10) = Array(LED120,LED121,LED122,LED123,LED124,LED125,LED126) Digits(11) = Array(LED130,LED131,LED132,LED133,LED134,LED135,LED136) ' 3rd Player Digits(12) = Array(LED150,LED151,LED152,LED153,LED154,LED155,LED156) Digits(13) = Array(LED160,LED161,LED162,LED163,LED164,LED165,LED166) Digits(14) = Array(LED170,LED171,LED172,LED173,LED174,LED175,LED176) Digits(15) = Array(LED180,LED181,LED182,LED183,LED184,LED185,LED186) Digits(16) = Array(LED190,LED191,LED192,LED193,LED194,LED195,LED196) Digits(17) = Array(LED200,LED201,LED202,LED203,LED204,LED205,LED206) ' 4th Player Digits(18) = Array(LED220,LED221,LED222,LED223,LED224,LED225,LED226) Digits(19) = Array(LED230,LED231,LED232,LED233,LED234,LED235,LED236) Digits(20) = Array(LED240,LED241,LED242,LED243,LED244,LED245,LED246) Digits(21) = Array(LED250,LED251,LED252,LED253,LED254,LED255,LED256) Digits(22) = Array(LED260,LED261,LED262,LED263,LED264,LED265,LED266) Digits(23) = Array(LED270,LED271,LED272,LED273,LED274,LED275,LED276) ' Credits Digits(24) = Array(LED4,LED2,LED6,LED7,LED5,LED1,LED3) Digits(25) = Array(LED18,LED9,LED27,LED28,LED19,LED8,LED17) ' Balls Digits(26) = Array(LED39,LED37,LED48,LED49,LED47,LED29,LED38) Digits(27) = Array(LED67,LED58,LED69,LED77,LED68,LED57,LED59) Sub DisplayTimer_Timer Dim ChgLED,ii,num,chg,stat,obj ChgLed = Controller.ChangedLEDs(&Hffffffff, &Hffffffff) If Not IsEmpty(ChgLED) Then If DesktopMode = True Then For ii = 0 To UBound(chgLED) num = chgLED(ii, 0) : chg = chgLED(ii, 1) : stat = chgLED(ii, 2) if (num < 28) then For Each obj In Digits(num) If chg And 1 Then obj.State = stat And 1 chg = chg\2 : stat = stat\2 Next else end if next end if end if End Sub '********************************************************************************************************** '********************************************************************************************************** ' ********************************************************************* ' ********************************************************************* 'Start of VPX call back Functions ' ********************************************************************* ' ********************************************************************* '**********Sling Shot Animations ' Rstep and Lstep are the variables that increment the animation '**************** Dim RStep, Lstep Sub RightSlingShot_Slingshot vpmTimer.PulseSw 71 PlaySound SoundFXDOF("right_slingshot",105,DOFPulse,DOFContactors), 0, 1, 0.05, 0.05 RSling.Visible = 0 RSling1.Visible = 1 sling1.TransZ = -20 RStep = 0 RightSlingShot.TimerEnabled = 1 End Sub Sub RightSlingShot_Timer Select Case RStep Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.TransZ = -10 Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.TransZ = 0:RightSlingShot.TimerEnabled = 0: End Select RStep = RStep + 1 End Sub Sub LeftSlingShot_Slingshot vpmTimer.PulseSw 71 PlaySound SoundFXDOF("left_slingshot",104,DOFPulse,DOFContactors),0,1,-0.05,0.05 LSling.Visible = 0 LSling1.Visible = 1 sling2.TransZ = -20 LStep = 0 LeftSlingShot.TimerEnabled = 1 End Sub Sub LeftSlingShot_Timer Select Case LStep Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.TransZ = -10 Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.TransZ = 0:LeftSlingShot.TimerEnabled = 0: End Select LStep = LStep + 1 End Sub ' ********************************************************************* ' Supporting Ball & Sound Functions ' ********************************************************************* Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed Vol = Csng(BallVel(ball) ^2 / 2000) End Function Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table Dim tmp tmp = ball.x * 2 / table1.width-1 If tmp > 0 Then Pan = Csng(tmp ^10) Else Pan = Csng(-((- tmp) ^10) ) End If End Function Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed Pitch = BallVel(ball) * 20 End Function Function BallVel(ball) 'Calculates the ball speed BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) ) End Function '***************************************** ' JP's VP10 Rolling Sounds '***************************************** Const tnob = 5 ' total number of balls ReDim rolling(tnob) InitRolling Sub InitRolling Dim i For i = 0 to tnob rolling(i) = False Next End Sub Sub RollingTimer_Timer() Dim BOT, b BOT = GetBalls ' stop the sound of deleted balls For b = UBound(BOT) + 1 to tnob rolling(b) = False StopSound("fx_ballrolling" & b) Next ' exit the sub if no balls on the table If UBound(BOT) = -1 Then Exit Sub ' play the rolling sound for each ball For b = 0 to UBound(BOT) If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then rolling(b) = True PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) ), Pan(BOT(b) ), 0, Pitch(BOT(b) ), 1, 0 Else If rolling(b) = True Then StopSound("fx_ballrolling" & b) rolling(b) = False End If End If Next End Sub '********************** ' Ball Collision Sound '********************** Sub OnBallBallCollision(ball1, ball2, velocity) PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, Pan(ball1), 0, Pitch(ball1), 0, 0 End Sub '************************************ ' What you need to add to your table '************************************ ' a timer called RollingTimer. With a fast interval, like 10 ' one collision sound, in this script is called fx_collide ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc '****************************************** ' Explanation of the rolling sound routine '****************************************** ' sounds are played based on the ball speed and position ' the routine checks first for deleted balls and stops the rolling sound. ' The For loop goes through all the balls on the table and checks for the ball speed and ' if the ball is on the table (height lower than 30) then then it plays the sound ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying. ' The sound is played using the VOL, PAN and PITCH functions, so the volume and pitch of the sound ' will change according to the ball speed, and the PAN function will change the stereo position according ' to the position of the ball on the table. '************************************** ' Explanation of the collision routine '************************************** ' The collision is built in VP. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they ' will call this routine. What you add in the sub is up to you. As an example is a simple Playsound with volume and paning ' depending of the speed of the collision. Sub Pins_Hit (idx) PlaySound "pinhit_low", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0 End Sub Sub Targets_Hit (idx) PlaySound "target", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0 End Sub Sub Metals_Thin_Hit (idx) PlaySound "metalhit_thin", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0 End Sub Sub Metals_Medium_Hit (idx) PlaySound "metalhit_medium", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0 End Sub Sub Metals2_Hit (idx) PlaySound "metalhit2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0 End Sub Sub Gates_Hit (idx) PlaySound "gate4", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0 End Sub Sub Spinner_Spin PlaySound "fx_spinner",0,.25,0,0.25 End Sub Sub Rubbers_Hit(idx) dim finalspeed finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely) If finalspeed > 20 then PlaySound "fx_rubber2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0 End if If finalspeed >= 6 AND finalspeed <= 20 then RandomSoundRubber() End If End Sub Sub Posts_Hit(idx) dim finalspeed finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely) If finalspeed > 16 then PlaySound "fx_rubber2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0 End if If finalspeed >= 6 AND finalspeed <= 16 then RandomSoundRubber() End If End Sub Sub RandomSoundRubber() Select Case Int(Rnd*3)+1 Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0 Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0 Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0 End Select End Sub Sub LeftFlipper_Collide(parm) RandomSoundFlipper() End Sub Sub RightFlipper_Collide(parm) RandomSoundFlipper() End Sub Sub RandomSoundFlipper() Select Case Int(Rnd*3)+1 Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0 Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0 Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0 End Select End Sub