-
Notifications
You must be signed in to change notification settings - Fork 1
/
multiball.py
283 lines (234 loc) · 14 KB
/
multiball.py
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
#####################################################################################
## ____ _______ _________________ _ _____ ________ ___ ______________
## / __/__< / / / / __/ __/ ___/ __ \/ |/ / _ \ / __/ __ \/ _ \/_ __/ _/ __/
## / _//___/ /_ _/ _\ \/ _// /__/ /_/ / / // / _\ \/ /_/ / , _/ / / _/ // _/
## /_/ /_/ /_/ /___/___/\___/\____/_/|_/____/ /___/\____/_/|_| /_/ /___/___/
##
## A P-ROC Project by Mark Sunnucks
## Built on PyProcGame from Adam Preble and Gerry Stellenberg
## Thanks to Scott Danesi for inspiration from his Earthshaker Aftershock
#####################################################################################
#################################################################################
# __ ___ ____ _ __ ____
# / |/ /_ __/ / /_(_) / ___ _/ / /
# / /|_/ / // / / __/ / _ \/ _ `/ / /
# /_/ /_/\_,_/_/\__/_/_.__/\_,_/_/_/
#
#################################################################################
import procgame.game
from procgame import *
import pinproc
from random import choice
from random import seed
import logging
class Multiball(game.Mode):
def __init__(self, game, priority):
super(Multiball, self).__init__(game, priority)
#self.game.utilities.get_player_stats('balls_locked') = 0
#self.ballsLanded = 0
#self.game.utilities.get_player_stats('upper_lock') = 'off'
#self.game.utilities.get_player_stats('middle_lock') = 'off'
#self.game.utilities.get_player_stats('lower_lock') = 'off'
self.multiballStarting = False
self.skipLanding = False
self.multiballIntroLength = 11.287
self.log = logging.getLogger('f14.multiball')
def mode_started(self):
self.update_lamps()
return super(Multiball, self).mode_started()
#def mode_stopped(self):
#self.game.update_lamps()
def update_lamps(self):
self.disableLockLamps()
if self.game.utilities.get_player_stats('upper_lock') == 'lit':
self.game.lamps.upperLock.schedule(schedule=0xFF00FF00, cycle_seconds=0, now=True)
self.game.lamps.lockOn.schedule(schedule=0x00FF00FF, cycle_seconds=0, now=True)
elif self.game.utilities.get_player_stats('upper_lock') == 'locked':
self.game.lamps.upperLock.enable()
if self.game.utilities.get_player_stats('upper_landing') == 'landing':
self.game.lamps.upperLanding.schedule(schedule=0xFF00FF00, cycle_seconds=0, now=True)
self.game.lamps.landing.schedule(schedule=0x00FF00FF, cycle_seconds=0, now=True)
elif self.game.utilities.get_player_stats('upper_landing') == 'landed':
self.game.lamps.upperLanding.enable()
if self.game.utilities.get_player_stats('middle_lock') == 'lit':
self.game.lamps.middleLock.schedule(schedule=0xFF00FF00, cycle_seconds=0, now=True)
self.game.lamps.lockOn.schedule(schedule=0x00FF00FF, cycle_seconds=0, now=True)
elif self.game.utilities.get_player_stats('middle_lock') == 'locked':
self.game.lamps.middleLock.enable()
if self.game.utilities.get_player_stats('middle_landing') == 'landing':
self.game.lamps.middleLanding.schedule(schedule=0xFF00FF00, cycle_seconds=0, now=True)
self.game.lamps.landing.schedule(schedule=0x00FF00FF, cycle_seconds=0, now=True)
elif self.game.utilities.get_player_stats('middle_landing') == 'landed':
self.game.lamps.middleLanding.enable()
if self.game.utilities.get_player_stats('lower_lock') == 'lit':
self.game.lamps.lowerLock.schedule(schedule=0xFF00FF00, cycle_seconds=0, now=True)
self.game.lamps.lockOn.schedule(schedule=0x00FF00FF, cycle_seconds=0, now=True)
elif self.game.utilities.get_player_stats('lower_lock') == 'locked':
self.game.lamps.lowerLock.enable()
if self.game.utilities.get_player_stats('lower_landing') == 'landing':
self.game.lamps.lowerLanding.schedule(schedule=0xFF00FF00, cycle_seconds=0, now=True)
self.game.lamps.landing.schedule(schedule=0x00FF00FF, cycle_seconds=0, now=True)
elif self.game.utilities.get_player_stats('lower_landing') == 'landed':
self.game.lamps.lowerLanding.enable()
if self.game.utilities.get_player_stats('balls_locked') == 3:
self.game.lamps.release.schedule(schedule=0xF0F0F0F0, cycle_seconds=0, now=True)
# Switch off all the lamps related to the locks, then the update lamp routine can just take care
# of switching back on the ones that are needed
def disableLockLamps(self):
self.game.lamps.lowerLock.disable()
self.game.lamps.middleLock.disable()
self.game.lamps.upperLock.disable()
self.game.lamps.lowerLanding.disable()
self.game.lamps.middleLanding.disable()
self.game.lamps.upperLanding.disable()
self.game.lamps.release.disable()
self.game.lamps.lockOn.disable()
self.game.lamps.landing.disable()
# This will be called from the base mode whenever all the TOMCAT targets have been lit.
# It will decide which lock to light - this can be made more complex later
def liteLock(self):
if self.game.utilities.get_player_stats('multiball_running') == 'None':
if (self.game.utilities.get_player_stats('balls_locked') == 0):
self.game.utilities.set_player_stats('middle_lock','lit')
self.game.utilities.play_animation('lock_is_lit',frametime=2)
elif (self.game.utilities.get_player_stats('balls_locked') == 1):
self.game.utilities.set_player_stats('upper_lock','lit')
self.game.utilities.play_animation('lock_is_lit',frametime=2)
elif (self.game.utilities.get_player_stats('balls_locked') == 2):
self.game.utilities.set_player_stats('lower_lock','lit')
self.game.utilities.play_animation('lock_is_lit',frametime=2)
self.update_lamps()
def startMultiball(self):
self.log.info("Start multiball")
self.multiballStarting = True
self.game.utilities.set_player_stats('multiball_running','Standard')
self.game.utilities.set_player_stats('multiballs_played',1,mode='add')
self.resetMultiballStats()
self.setupLanding()
self.update_lamps()
self.multiballIntro()
def multiballIntro(self):
self.log.info("Multiball intro")
self.game.utilities.disableGI()
self.game.sound.stop_music()
# Sound FX #
#self.game.sound.play('main_loop_tape_stop')
self.game.utilities.play_animation('second_sortie_rotate')
self.resetMultiballStats()
self.delay(delay=2,handler=self.multiballRun)
def multiballRun(self):
self.log.info("Multiball run")
self.game.utilities.enableGI()
# Switch the stats over to landing instead of regular locks lit
self.setupLanding()
# Make sure the trough knows how many balls are locked
self.game.trough.num_balls_locked = 0
self.game.utilities.set_player_stats('balls_locked',0)
#self.game.sound.play('centerRampComplete')
self.game.sound.play_music('dangerzone')
#kick the balls out
self.game.utilities.acCoilPulse(coilname='lowerEject_flasher7',pulsetime=50)
self.game.utilities.acCoilPulse(coilname='upperEject_flasher5',pulsetime=50)
self.game.coils.middleEject.pulse(50)
self.kickVUK()
# We know one ball will arrive in the landing from the vUK at the start but
# it doesn't count
self.skipLanding = True
# Tell the trough we now now have 3 balls in play, then have it kick another
self.game.trough.num_balls_in_play = 4
#self.log.info("Launch ball auto due to multiball")
#self.game.trough.launch_balls(num=1,autolaunch=True)
self.multiballStarting = False
self.game.update_lamps()
self.multiball_reminder()
def multiball_reminder(self):
self.game.utilities.play_animation('tomcat_multiball_rotate')
self.delay(name='reminder', event_type=None, delay=4.0, handler=self.multiball_reminder)
def stopMultiball(self):
self.log.info("Stop multiball")
self.game.utilities.set_player_stats('multiball_running','None')
self.resetLanding()
self.cancel_delayed('reminder')
self.game.sound.stop_music()
self.game.sound.play_music('tomcatmain',loops=-1)
self.resetMultiballStats()
self.game.update_lamps()
#self.callback()
def resetMultiballStats(self):
self.game.utilities.set_player_stats('upper_lock','off')
self.game.utilities.set_player_stats('middle_lock','off')
self.game.utilities.set_player_stats('lower_lock','off')
# This handles the holding over of successfully landed balls from previous multiball
def setupLanding(self):
if self.game.utilities.get_player_stats('upper_landing') == 'off':
self.game.utilities.set_player_stats('upper_landing','landing')
if self.game.utilities.get_player_stats('middle_landing') == 'off':
self.game.utilities.set_player_stats('middle_landing','landing')
if self.game.utilities.get_player_stats('lower_landing') == 'off':
self.game.utilities.set_player_stats('lower_landing','landing')
# At the end of multiball this will clear locks waiting for landing
def resetLanding(self):
if self.game.utilities.get_player_stats('upper_landing') == 'landing':
self.game.utilities.set_player_stats('upper_landing','off')
if self.game.utilities.get_player_stats('middle_landing') == 'landing':
self.game.utilities.set_player_stats('middle_landing','off')
if self.game.utilities.get_player_stats('lower_landing') == 'landing':
self.game.utilities.set_player_stats('lower_landing','off')
# Called from lock handler when a ball stops in a lock and it was lit
# for regular lock or for landing
def lock_ball(self,location,replacement):
# FIrst of all work out if this is a regular lock or it's for landing during multiball
if self.game.utilities.get_player_stats(location+'_lock') == 'lit':
self.log.info("Locking ball in location "+location)
ballsLocked = self.game.utilities.get_player_stats('balls_locked')
ballsLocked += 1
self.game.utilities.play_animation('ball_'+str(ballsLocked)+'_locked',frametime=2)
self.game.utilities.set_player_stats(location+'_lock','locked')
self.game.utilities.set_player_stats('balls_locked',ballsLocked)
self.update_lamps()
# Only lock ball physically and launch another if a ball wasn't already cleared
# from the lock to make space for this one.
if replacement == False:
self.log.info("Launch ball manual as ball locked")
self.game.trough.launch_balls(num=1,stealth=True)
else:
self.log.info("Ball has landed in location "+location)
ballsLanded = self.game.utilities.get_player_stats('balls_landed')
ballsLanded += 1
self.game.utilities.play_animation('f14landing',txt='LANDINGS : '+str(ballsLanded))
self.game.utilities.set_player_stats('balls_landed',ballsLanded)
if replacement == False:
self.game.utilities.set_player_stats(location+'_landing','landed')
if location == 'upper':
self.game.utilities.acCoilPulse(coilname='upperEject_flasher5',pulsetime=50)
elif location == 'middle':
self.game.coils.middleEject.pulse(50)
else:
self.game.utilities.acCoilPulse(coilname='lowerEject_flasher7',pulsetime=50)
if ballsLanded % 3 == 0:
self.game.utilities.display_text(txt='JACKPOT')
self.game.utilities.set_player_stats('upper_landing','landing')
self.game.utilities.set_player_stats('middle_landing','landing')
self.game.utilities.set_player_stats('lower_landing','landing')
self.update_lamps()
def sw_vUK_active(self, sw):
if self.game.utilities.get_player_stats('balls_locked') == 3:
self.startMultiball()
return procgame.game.SwitchStop
elif (self.game.utilities.get_player_stats('lower_lock') == 'lit' or
self.game.utilities.get_player_stats('middle_lock') == 'lit' or
self.game.utilities.get_player_stats('upper_lock') == 'lit' ):
self.game.lampctrlflash.play_show('topstrobe',repeat=False)
# Let the lampshow play etc, then kick the ball after 1.5 seconds.
self.game.utilities.play_animation('lock_on',frametime=1,txt='MISSILE LOCK ON')
self.game.sound.play('lock_on')
self.delay(name='kickvuk', event_type=None, delay=1.5, handler=self.kickVUK)
return procgame.game.SwitchStop
def kickVUK(self):
self.game.utilities.acCoilPulse(coilname='upKicker_flasher3',pulsetime=50)
self.game.locks.transitStart('base')
def sw_debug_active(self,sw):
self.log.info("Balls locked = "+str(self.game.utilities.get_player_stats('balls_locked')))
self.log.info("Upper lock = "+self.game.utilities.get_player_stats('upper_lock'))
self.log.info("Middle lock = "+self.game.utilities.get_player_stats('middle_lock'))
self.log.info("Lower lock = "+self.game.utilities.get_player_stats('lower_lock'))