' code snippet file for use with shivaEngine3
' released: 5.25.06
'
' *** COPYRIGHT NOTICE ***
'
' written by shiva
' Thanks to all the other authors
' Contact Info : [email][email protected][/email]
'
' All rights are reserved by p.d.sanderson (shiva)
' You may release, or modify for release any portion of this product, as long as it is not
' part of a commercial product or venture.
' This code snippet was meant to be expanded, so please contact the author for additions
' to this base script. All submissions welcome.
'
' The above copyright and remarks MUST be included with this table. Please credit use of
' this script for your own tables.
'
' Please keep any modifications for release as separate code snippet files so others can use
' it for their tables.
'
' *** 1823 - (Playboy) Bumpers ***
'
' Now we use the examples above, but expanded, for our bumpers. We use drop walls, like the wire triggers
' and a collection for the bumper hit, to make a realistic effect for our bumpers.
' You need to create a collection called Bumpers, make 3 bumpers, and add them to the collection.
' I use a my own created system to simulate "Bumper Rings", a series of walls set to different heights
' with custom graphics, but it's a lot of work to set up and make work, so I won't explain it.
' The code is written so that you can just copy and paste the Bumpers_Hit(Index) subroutine, just
' REMOVE the "If HoldBumperSound=0 then", the "HoldBumperSound=1" and the "end if" lines and it will work
Dim bw1,bw2,bw3 ' variables for bumper ring control
' Optional, this "evens" out the sound a bit
Dim HoldBumperSound ' this prevents a second Bumper sound from playing until the first sound has stopped
' First, we set up our code for the engine to read and set the opening variables at Table Start, and for
' each new ball. We call it by the sub name: SetBumpers1823() and place it in the SetNewBall(). A lot easier
' to have one line instead of several. and also, this means you can set up your game very quickly
' without getting confused, or worse, getting the script confused.
' We also do a cheap and nasty way for a tilt state. We could set up tilts to disable objects as separate
' routines, but we do it here instead. We get a "false bump", but it's better than confusing everyone
' with multiple routines and hooks.
Sub SetBumpers1823()
' We reset all the variables, these control the ring effect walls for each bumper
bw1=0:bw2=0:bw3=0
' Now we point to the BumperRings Collection. Since the rings are actually walls that are droppable, we
' use the target code, and make sure each ring is dropped
For Each target in BumperRings
target.IsDropped=1
Next
' If we tilted, we disable the bumpers in the next subroutine, so we better turn them back on.
Bumper1.disabled=0:Bumper2.disabled=0:Bumper3.disabled=0
end sub
' Here's the collection code, and serves as the main routine to control everything. We add each bumper to
' this collection, so we can have this one bit of code to control all of the bumpers.
Sub Bumpers_Hit( Index )
' check the tilt state. tilt=0 means we are NOT tilted. Any other value would mean we are tilted
If tilt = 0 then
PlaySound "Bumper"
' Hold the sound. We use the HoldBumperSound value to control this. If it's 0, then play the sound
' and then set the variable value to 1. We reset the variable back to 0 in the case settings for the
' individual bumper rings, so that way, we don't need a separate timer.
' We do this because the bumpers in Playboy are pretty close together, so a ball will trigger multiple
' hits within a second, and though the sound is switched off at each hit, it still sounds terrible
If HoldBumperSound=0 then ' check that variable is set to 0 or "off"
StopAllSounds() ' stop sounds if playing
' we use the GetScoreBells variable to decide if we want to use the built in sound
' system for Bally/EM type scoring or not. If we don't then set GetScoreBells to 0
' and add the sound here. The GetScoreBells feature, if on (GetBalls=1) will play a set
' sound, and is already added to the engine
If GetScoreBells=0 then PlaySound "Bumper2" ' Play the electronic sound for the bumpers
HoldBumperSound=1 ' set variable to prevent the sound playing until we want to
end if
AddScore 100 ' adds 100 points
' The "else" statement means other than, or in simple terms, if tilt is not 0 but a different value
' which in this case means we have tilted the ball. So using the else statement, we can have code
' for what we want to do if we are tilted.
else
' And here's our code to disable the bumpers if we tilted. It doesn't work for the FIRST
' hit, but will every other hit. A VP thing...
Bumper1.disabled=1:Bumper2.disabled=1:Bumper3.disabled=1
end if
end sub
' Yes, you can write a collection code, and still write code for each object as well. This is for
' setting the ring effect to the proper bumper. You can do this as a collection as well, but it's
' easier for beginners to understand this better
Sub Bumper2_Hit : if tilt=0 then BumpRing2():end if:End Sub
Sub Bumper1_Hit : if tilt=0 then BumpRing1():end if:End Sub
Sub Bumper3_Hit : if tilt=0 then BumpRing3():end if:End Sub
' Bumper 1 (Left)
Sub BumpRing1()
if bw1=0 then ' MAKE SURE SET TO 0 TO DROP FIRST RING OF FOUR, WITHOUT INTERFERENCE FROM MULTIPLE HITS
Bumper1.State=0 ' turn off the bumper light to "flash"
b1a.IsDropped=0:b1b.IsDropped=0:b1c.IsDropped=0:b1d.IsDropped=0 ' all ring walls up
Bumper1.TimerEnabled=0 'stop bumper ring timer if on
b1a.IsDropped=1:Bumper1.TimerEnabled=1 'drop first ring, start timer
end if
end sub
' controls bumper ring wall control
Sub Ring1Control()
bw1=bw1+1 'increase value by one, and read corresponding case number
select case bw1 'loops thru timer
case 1:b1a.IsDropped=1:b1b.IsDropped=0'rings going down
case 2:b1b.IsDropped=1:b1c.IsDropped=0
case 3:b1c.IsDropped=1:b1d.IsDropped=0
case 4:b1d.IsDropped=1:b1c.IsDropped=0'rings going up
case 5:b1c.IsDropped=1:b1b.IsDropped=0
case 6:b1b.IsDropped=1:b1a.IsDropped=0:Bumper1.State=1
end select
If bw1=>7 then 'case 6 is done, so end process
bw1=0:b1a.IsDropped=0:b1b.IsDropped=1:b1c.IsDropped=1:b1d.IsDropped=1' reset variables and walls.
HoldBumperSound=0 'Next hit in the bumpers, the sound will now play
else
Bumper1.TimerEnabled=1 ' if all cases are not done yet, go to timer to start next effect
end if
end sub
' Timer for ring delay, and then we loop back to continue the next case.
' The interval is controlled by the bumper object in the editor
Sub Bumper1_Timer()
if gameover=0 then
Bumper1.TimerEnabled=0:Ring1Control() 'back to loop
end if
end sub
' Bumper 2 (Right)
Sub BumpRing2()
if bw2=0 then
Bumper2.State=0:b2a.IsDropped = 0:b2b.IsDropped = 0:b2b.IsDropped = 0:b2d.IsDropped = 0
Bumper2.TimerEnabled=0:b2a.IsDropped = 1:Bumper2.TimerEnabled=1
end if
end sub
Sub Ring2Control()
bw2=bw2+1
select case bw2
case 1:b2a.IsDropped=1:b2b.IsDropped=0
case 2:b2b.IsDropped=1:b2c.IsDropped=0
case 3:b2c.IsDropped=1:b2d.IsDropped=0
case 4:b2d.IsDropped=1:b2c.IsDropped=0
case 5:b2c.IsDropped=1:b2b.IsDropped=0
case 6:b2b.IsDropped=1:b2a.IsDropped=0:Bumper2.State=1
end select
If bw2=>7 then
bw2=0:b2a.IsDropped=0:b2b.IsDropped=1:b2c.IsDropped=1:b2d.IsDropped=1:HoldBumperSound=0
else
Bumper2.TimerEnabled=1
end if
end sub
Sub Bumper2_Timer()
if gameover=0 then
Bumper2.TimerEnabled=0:Ring2Control()
end if
end sub
' Bumper 3 (Bottom)
Sub BumpRing3()
if bw3=0 then
Bumper3.State=0:b3a.IsDropped = 0:b3b.IsDropped = 0:b3b.IsDropped = 0:b3d.IsDropped = 0
Bumper3.TimerEnabled=0:b3a.IsDropped = 1:Bumper3.TimerEnabled=1
end if
end sub
Sub Ring3Control()
bw3=bw3+1
select case bw3
case 1:b3a.IsDropped=1:b3b.IsDropped=0
case 2:b3b.IsDropped=1:b3c.IsDropped=0
case 3:b3c.IsDropped=1:b3d.IsDropped=0
case 4:b3d.IsDropped=1:b3c.IsDropped=0
case 5:b3c.IsDropped=1:b3b.IsDropped=0
case 6:b3b.IsDropped=1:b3a.IsDropped=0:Bumper3.State=1
end select
If bw3=>7 then
bw3=0:b3a.IsDropped=0:b3b.IsDropped=1:b3c.IsDropped=1:b3d.IsDropped=1:HoldBumperSound=0
else
Bumper3.TimerEnabled=1
end if
end sub
Sub Bumper3_Timer()
if gameover=0 then
Bumper3.TimerEnabled=0:Ring3Control()
end if
end sub