· 6 years ago · Aug 31, 2019, 01:50 AM
1--[[------------
2 Data used by this script.
3--]]------------
4
5-- Which decks to shuffle at the beginning of the heist.
6local shuffleDecks = {
7 "Character Deck", "Event Deck", "Tool Deck", "Loot Deck",
8 "Room Deck", "Patrol1 Deck", "Patrol2 Deck", "Patrol3 Deck" }
9
10-- Table of wall positions for each layout.
11-- Positions are numbered: 1-12 are N-S walls, 13-24 are E-W.
12-- Walls positions count left-to-right, then top-to-bottom.
13-- The wall positions are used by getWallLoc() to find coordinates and facings.
14local walls = {}
15
16wallLayouts = {}
17wallLayouts[ 1 ] = { 1, 6, 10, 11, 15, 17, 18, 24 }
18wallLayouts[ 2 ] = { 1, 2, 3, 10, 11, 12, 18, 19 }
19wallLayouts[ 3 ] = { 4, 6, 7, 8, 12, 15, 17, 19 }
20wallLayouts[ 4 ] = { 3, 4, 5, 17, 18, 19, 21, 23 }
21wallLayouts[ 5 ] = { 1, 4, 5, 6, 7, 11, 15, 16 }
22wallLayouts[ 6 ] = { 5, 6, 11, 13, 14, 19, 22, 24 }
23wallLayouts[ 7 ] = { 4, 8, 14, 15, 18, 19, 20, 22 }
24wallLayouts[ 8 ] = { 5, 6, 14, 18, 19, 20, 21, 24 }
25wallLayouts[ 9 ] = { 1, 4, 5, 6, 7, 11, 16, 19 }
26wallLayouts[ 10 ] = { 4, 7, 8, 14, 15, 17, 22, 24 }
27wallLayouts[ 11 ] = { 6, 9, 14, 17, 18, 20, 22, 23 }
28wallLayouts[ 12 ] = { 2, 6, 7, 11, 14, 16, 19, 22 }
29wallLayouts[ 13 ] = { 1, 6, 7, 8, 12, 15, 18, 21 }
30wallLayouts[ 14 ] = { 7, 9, 10, 12, 15, 16, 18, 23 }
31wallLayouts[ 15 ] = { 4, 5, 6, 8, 9, 10, 16, 22 }
32wallLayouts[ 16 ] = { 4, 5, 6, 7, 8, 12, 17, 18 }
33wallLayouts[ 17 ] = { 5, 6, 7, 9, 10, 14, 22, 23 }
34wallLayouts[ 18 ] = { 3, 4, 6, 9, 10, 15, 19, 23 }
35wallLayouts[ 19 ] = { 1, 3, 4, 9, 10, 14, 19, 22 }
36wallLayouts[ 20 ] = { 2, 5, 6, 12, 13, 18, 20, 23 }
37wallLayouts[ 21 ] = { 4, 5, 6, 7, 9, 10, 15, 24 }
38wallLayouts[ 22 ] = { 2, 3, 6, 7, 10, 13, 19, 22 }
39wallLayouts[ 23 ] = { 1, 5, 8, 9, 15, 20, 21, 23 }
40wallLayouts[ 24 ] = { 1, 3, 5, 7, 8, 17, 22, 23 }
41wallLayouts[ 25 ] = { 2, 11, 12, 13, 15, 17, 18, 20 }
42wallLayouts[ 26 ] = { 4, 6, 7, 8, 15, 19, 22, 24 }
43wallLayouts[ 27 ] = { 2, 4, 5, 11, 13, 19, 22, 23 }
44wallLayouts[ 28 ] = { 1, 2, 8, 10, 17, 20, 22, 24 }
45wallLayouts[ 29 ] = { 9, 12, 14, 16, 17, 18, 21, 22 }
46wallLayouts[ 30 ] = { 1, 4, 7, 14, 16, 19, 23, 24 }
47wallLayouts[ 31 ] = { 1, 7, 12, 15, 16, 20, 21, 23 }
48wallLayouts[ 32 ] = { 3, 5, 7, 8, 14, 15, 18, 24 }
49wallLayouts[ 33 ] = { 4, 6, 7, 12, 14, 15, 19, 23 }
50wallLayouts[ 34 ] = { 3, 4, 7, 8, 10, 18, 20, 23 }
51wallLayouts[ 35 ] = { 1, 7, 8, 11, 16, 18, 19, 23 }
52wallLayouts[ 36 ] = { 2, 4, 7, 15, 17, 18, 23, 24 }
53wallLayouts[ 37 ] = { 1, 2, 3, 4, 11, 20, 21, 23 }
54wallLayouts[ 38 ] = { 2, 6, 11, 12, 16, 18, 19, 21 }
55wallLayouts[ 39 ] = { 5, 6, 9, 11, 14, 18, 22, 23 }
56wallLayouts[ 40 ] = { 2, 4, 5, 9, 16, 17, 21, 23 }
57wallLayouts[ 41 ] = { 6, 11, 12, 13, 14, 19, 20, 22 }
58wallLayouts[ 42 ] = { 4, 6, 8, 11, 15, 18, 22, 23 }
59wallLayouts[ 43 ] = { 2, 4, 8, 10, 14, 16, 19, 20 }
60wallLayouts[ 44 ] = { 7, 9, 10, 13, 14, 15, 19, 24 }
61wallLayouts[ 45 ] = { 5, 11, 14, 15, 16, 18, 19, 21 }
62wallLayouts[ 46 ] = { 1, 2, 6, 9, 11, 12, 17, 21 }
63wallLayouts[ 47 ] = { 3, 7, 8, 9, 11, 12, 14, 17 }
64wallLayouts[ 48 ] = { 2, 4, 5, 13, 16, 20, 22, 23 }
65wallLayouts[ 49 ] = { 2, 6, 9, 11, 12, 17, 19, 22 }
66wallLayouts[ 50 ] = { 5, 7, 10, 12, 13, 18, 20, 23 }
67wallLayouts[ 51 ] = { 4, 10, 12, 13, 15, 18, 19, 22 }
68wallLayouts[ 52 ] = { 1, 3, 5, 11, 14, 19, 21, 23 }
69wallLayouts[ 53 ] = { 1, 8, 11, 15, 17, 20, 21, 23 }
70wallLayouts[ 54 ] = { 2, 3, 4, 7, 8, 12, 17, 22 }
71wallLayouts[ 55 ] = { 1, 2, 3, 5, 12, 18, 21, 23 }
72wallLayouts[ 56 ] = { 5, 6, 7, 9, 14, 19, 22, 24 }
73wallLayouts[ 57 ] = { 2, 7, 8, 9, 10, 13, 23, 24 }
74wallLayouts[ 58 ] = { 2, 8, 10, 11, 12, 14, 18, 19 }
75wallLayouts[ 59 ] = { 2, 3, 5, 7, 10, 11, 12, 20 }
76wallLayouts[ 60 ] = { 2, 6, 9, 10, 12, 13, 19, 22 }
77
78
79-- 3-floor layouts. The first is "The Bank Job" from the rulebook,
80-- the rest were generated from <http://gabob.com/burgle/>
81walls.bank = {}
82
83walls.bank[ 1 ] = {}
84walls.bank[1][1] = wallLayouts[math.random( 1, 60 )]
85walls.bank[1][2] = wallLayouts[math.random( 1, 60 )]
86walls.bank[1][3] = wallLayouts[math.random( 1, 60 )]
87
88
89-- 2-floor layouts. The first is "The Office Job" from the rulebook,
90-- the rest were generated from <http://gabob.com/burgle/>
91walls.office = {}
92
93walls.office[ 1 ] = {}
94walls.office[1][1] = { 1, 2, 4, 6, 8, 16, 22, 24 }
95walls.office[1][2] = { 4, 5, 6, 7, 8, 16, 17, 24 }
96
97walls.office[ 2 ] = {}
98walls.office[2][1] = { 5, 6, 7, 8, 9, 11, 21, 23 }
99walls.office[2][2] = { 1, 3, 8, 11, 12, 14, 18, 19 }
100
101walls.office[ 3 ] = {}
102walls.office[3][1] = { 2, 4, 6, 9, 11, 12, 18, 19 }
103walls.office[3][2] = { 1, 3, 5, 11, 12, 15, 18, 22 }
104
105walls.office[ 4 ] = {}
106walls.office[4][1] = { 4, 6, 10, 11, 12, 16, 18, 19 }
107walls.office[4][2] = { 4, 5, 8, 16, 18, 20, 21, 22 }
108
109walls.office[ 5 ] = {}
110walls.office[5][1] = { 2, 10, 13, 15, 19, 20, 23, 24 }
111walls.office[5][2] = { 1, 4, 5, 6, 7, 14, 20, 24 }
112
113walls.office[ 6 ] = {}
114walls.office[6][1] = { 1, 2, 3, 4, 8, 18, 19, 24 }
115walls.office[6][2] = { 2, 6, 8, 10, 12, 14, 18, 23 }
116
117walls.office[ 7 ] = {}
118walls.office[7][1] = { 2, 5, 6, 10, 12, 14, 17, 23 }
119walls.office[7][2] = { 2, 6, 11, 12, 13, 17, 20, 21 }
120
121walls.office[ 8 ] = {}
122walls.office[8][1] = { 2, 4, 6, 9, 10, 14, 16, 23 }
123walls.office[8][2] = { 3, 4, 5, 6, 7, 12, 15, 21 }
124
125walls.office[ 9 ] = {}
126walls.office[9][1] = { 1, 4, 6, 11, 14, 15, 21, 24 }
127walls.office[9][2] = { 4, 5, 8, 9, 12, 14, 15, 17 }
128
129walls.office[ 10 ] = {}
130walls.office[10][1] = { 2, 5, 7, 8, 14, 18, 19, 24 }
131walls.office[10][2] = { 1, 3, 5, 6, 9, 18, 19, 22 }
132
133
134-- Define game settings and checkbox groups.
135-- The "group" list is a list of indices into the button list for each group.
136local settings = {}
137
138settings.players = {} -- Number of players (2 to 4)
139settings.players.value = 2
140settings.players.group = { 0, 2, 4 }
141
142settings.sizes = {} -- number of floors (2 = office, 3 = bank)
143settings.sizes.value = "bank"
144settings.sizes.group = { 6, 8 }
145
146settings.walls = {} -- which wall set to use (1 = standard, 2 = generated)
147settings.walls.value = "std"
148settings.walls.group = { 10, 12 }
149
150
151--[[------------
152 Button functions.
153--]]------------
154
155-- Initialize the buttons.
156function onLoad()
157
158 -- Location of the "X" displays for the check boxes.
159 -- The third parameter is a horrible kludge to set the buttons' initial values.
160 -- If you change any settings.values, change these parameters too.
161 local checkBoxes = {}
162 checkBoxes.Players2 = { -0.035, -0.458, "X" }
163 checkBoxes.Players3 = { 0.188, -0.458, "" }
164 checkBoxes.Players4 = { 0.41, -0.458, "" }
165 checkBoxes.SizeOffice = { -0.035, -0.28, "" }
166 checkBoxes.SizeBank = { -0.035, -0.17, "X" }
167 checkBoxes.WallsStd = { -0.035, 0.008, "" }
168 checkBoxes.WallsGen = { -0.035, 0.12, "X" }
169
170 -- Create the checkbox displays and buttons.
171 for btnFunc, btnPos in pairs( checkBoxes ) do
172
173 -- The display has no size, so only the text will appear.
174 local btnParams = {}
175 btnParams.click_function = "none"
176 btnParams.function_owner = self
177 btnParams.label = btnPos[3]
178 btnParams.position = {}
179 btnParams.position[1] = btnPos[1]
180 btnParams.position[2] = 1
181 btnParams.position[3] = btnPos[2]
182 btnParams.rotation = { 0, 180, 0 }
183 btnParams.width = 0
184 btnParams.height = 0
185 btnParams.font_size = 39
186 self.createButton( btnParams )
187
188 -- Create the actual button just beneath the remote control.
189 btnParams.click_function = "clickBtn" .. btnFunc
190 btnParams.position[2] = 0.8
191 btnParams.width = 60
192 btnParams.height = 60
193 self.createButton( btnParams )
194
195 end
196
197 -- Create the "Start Heist" button.
198 local btnStart = {}
199 btnStart.click_function = "clickBtnStart"
200 btnStart.function_owner = self
201 btnStart.label = ""
202 btnStart.position = { 0, 0.8, 0.58 }
203 btnStart.rotation = { 0, 180, 0 }
204 btnStart.width = 330
205 btnStart.height = 330
206 btnStart.font_size = 36
207 self.createButton( btnStart )
208
209end
210
211
212-- Respond to clicks in the check boxes.
213function clickBtnPlayers2() setSetting( "players", 0, 2 ) end
214function clickBtnPlayers3() setSetting( "players", 2, 3 ) end
215function clickBtnPlayers4() setSetting( "players", 4, 4 ) end
216function clickBtnSizeOffice() setSetting( "sizes", 6, "office" ) end
217function clickBtnSizeBank() setSetting( "sizes", 8, "bank" ) end
218function clickBtnWallsStd() setSetting( "walls", 10, "std" ) end
219function clickBtnWallsGen() setSetting( "walls", 12, "gen" ) end
220
221
222-- Set the checkboxes for a group and the setting's value.
223function setSetting( theSetting, theCheckedBox, theValue )
224
225 -- Get the checkbox group for this setting and set its value.
226 local thisCheckGroup = settings[ theSetting ].group
227 settings[ theSetting ].value = theValue
228
229 -- Walk the list of buttons to find the ones for this checkbox group.
230 local allButtons = self.getButtons()
231 for _, thisBtn in pairs( allButtons ) do
232
233 -- Search the check group to see if this button is in it.
234 for _, thisCheckBox in pairs( thisCheckGroup ) do
235 if thisBtn.index == thisCheckBox then
236
237 -- If this is the button that was clicked, check it.
238 if thisBtn.index == theCheckedBox then
239 theLabel = "X"
240 else
241 theLabel = ""
242 end
243
244 self.editButton( { index = thisBtn.index, label = theLabel } )
245
246 end
247 end
248
249 end
250
251end
252
253
254-- Respond to the "Start Heist" button.
255function clickBtnStart()
256
257 -- Make sure the game hasn't already been started.
258 local gameStarted = Global.getVar( "gameStarted" )
259 if gameStarted then
260 print( "The heist has already been started." )
261 return
262 end
263
264 -- Get the settings for the game.
265 local numPlayers = settings.players.value
266
267 local theBoard = settings.sizes.value
268
269 local numFloors = 3
270 if theBoard == "office" then
271 numFloors = 2
272 end
273
274 -- The first value in the walls table is the default setup,
275 -- the rest were generated by the gabob.com/burgle/ wall generator.
276 local whichWalls = 1
277 if settings.walls.value == "gen" then
278 if theBoard == "office" then
279 whichWalls = math.random( 2, 10 )
280 else
281 whichWalls = math.random( 2, 20 )
282 end
283 end
284
285 -- Remember the leftmost card position.
286 if numFloors == 2 then
287 Global.setVar( "leftEdge", -26.25 )
288 else
289 Global.setVar( "leftEdge", -40.25 )
290 end
291
292 -- Get the decks and objects needed for the script.
293 local theRooms = Global.call( "getObjectFromName", { "Room Deck" } )
294 local the3rdFloor = Global.call( "getObjectFromName", { "Floor3 Room Deck" } )
295 local the3rdSafeStairs = Global.call( "getObjectFromName", { "Floor3 Deck" } )
296 local theUnused = Global.call( "getObjectFromName", { "Unused Cards" } )
297
298 -- If it's a 3-floor game, add the 3rd floor cards to the room deck.
299 if numFloors == 3 then
300 theRooms.putObject( the3rdFloor )
301 end
302
303 -- Shuffle all the decks.
304 if not shuffleAllTheThings( shuffleDecks ) then
305 print( "Setup cancelled." )
306 return
307 end
308
309 -- Get the list of walls for this game.
310 local wallList = walls[ theBoard ][ whichWalls ]
311
312 -- Deal and arrange the rooms and walls for each floor.
313 for i = 1, numFloors do
314 setupFloor( i )
315 setupWalls( i, wallList[ i ] )
316 setupPatrol( i )
317 end
318
319 -- If it's a two-floor game, clean up the unused pieces.
320 if numFloors == 2 then
321
322 -- Set aside the unused 3rd floor room cards.
323 theUnused.putObject( the3rdFloor )
324 theUnused.putObject( the3rdSafeStairs )
325
326 -- Set aside the third floor patrol deck tray.
327 movePatrolTray( 3, -47.25, 31.5 )
328
329 end
330
331 -- Select and place the characters.
332 setupCharacters( numPlayers )
333
334 -- Remember that the game has been started.
335 Global.setVar( "gameStarted", true )
336
337end
338
339
340--[[------------
341 Main functions.
342--]]------------
343
344-- Shuffle multiple decks of cards.
345function shuffleAllTheThings( deckList )
346
347 -- Shuffle all the decks.
348 for i in pairs( deckList ) do
349
350 -- Get the deck we'll be shuffling.
351 local thisDeckName = deckList[ i ]
352 local thisDeck = Global.call( "getObjectFromName", { thisDeckName } )
353
354 -- Verify that the deck object exists.
355 if not thisDeck then
356 print( "startHeist: No " .. thisDeckName .. " found." )
357 return false
358 end
359
360 -- Shuffle the deck!
361 thisDeck.shuffle()
362
363 end
364
365 return true
366
367end
368
369
370-- Deal cards to a floor deck, and lay them out on the board.
371function setupFloor( theFloor )
372
373 -- Get the room deck and floor deck.
374 local roomDeck = Global.call( "getObjectFromName", { "Room Deck" } )
375 local floorDeck = Global.call( "getObjectFromName",
376 { "Floor" .. theFloor .. " Deck" } )
377
378 -- Deal the room cards into the floor deck.
379 for i = 1, 14 do
380 local thisRoom = roomDeck.takeObject( {} )
381 floorDeck.putObject( thisRoom )
382 end
383
384 -- Shuffle the floor deck.
385 floorDeck.shuffle()
386
387 -- Place each room card in its spot on the board.
388 for i = 1, 16 do
389
390 -- Get the board position for this card.
391 local thisPos = Global.call( "getRoomLoc", { theFloor, i } )
392
393 -- Draw the card and place it on the board.
394 local params = {}
395 params.position = {}
396 params.position.x = thisPos.x
397 params.position.y = 3
398 params.position.z = thisPos.z
399 floorDeck.takeObject( params )
400
401 end
402
403end
404
405
406-- Lay walls out on a floor.
407function setupWalls( theFloor, wallList )
408
409 -- Find the bag containing the wall pieces.
410 local wallBag = Global.call( "getObjectFromName", { "Walls" } )
411
412 -- Walk the list of walls for this floor.
413 for i in pairs( wallList ) do
414
415 -- Get the location for this wall.
416 local thisLoc = getWallLoc( theFloor, wallList[ i ] )
417
418 -- Prepare the parameter list for takeObject().
419 local params = {}
420
421 params.position = {}
422 params.position.x = thisLoc.x
423 params.position.y = 3
424 params.position.z = thisLoc.z
425
426 params.rotation = {}
427 params.rotation.x = 0
428 if wallList[ i ] <= 12 then
429 params.rotation.y = -90
430 else
431 params.rotation.y = 0
432 end
433 params.rotation.z = 0
434
435 -- Draw a wall piece from the bag and place it.
436 local thisWall = wallBag.takeObject( params )
437
438 end
439
440end
441
442
443-- Lay guard pieces out below a floor.
444function setupPatrol( theFloor )
445
446 -- Get the relevant game settings.
447 local numPlayers = settings.players.value
448 local floorPos = Global.getVar( "leftEdge" )
449
450 -- Get the patrol deck for this floor.
451 local thisPatrolDeck = Global.call( "getObjectFromName",
452 { "Patrol" .. theFloor .. " Deck" } )
453
454 local patrolLeftovers = Global.getVar( "patrolLeftovers" )
455
456 -- Calculate where to put the leftover patrol cards for 2- and 3-player games.
457 -- Making sense of constants:
458 -- -49 = left sideboard of table
459 -- 22.75 = z-position of 1st floor leftovers
460 -- 7 = spacing between leftover decks.
461 local thePos = {}
462 thePos.x = -49
463 thePos.y = 3
464 thePos.z = 22.75 - ( theFloor-1 ) * 7
465
466 -- Initialize the patrol leftovers.
467 patrolLeftovers[ theFloor ] = nil
468
469 -- leave out 3 cards for a 3-player game, and 6 cards for a 2-player game.
470 for i = 1, ( 4-numPlayers ) * 3 do
471
472 local thisPatrolCard = thisPatrolDeck.takeObject( { position = thePos } )
473
474 -- Remember the last card we left out, so we can reshuffle it later.
475 -- (Yeah this is redundant, but it's late and the code looks prettier.)
476 patrolLeftovers[ theFloor ] = thisPatrolCard.getName()
477 thePos.y = thePos.y + 1
478
479 end
480
481 -- Place the patrol deck tray for this floor.
482 -- Making sense of constants:
483 -- 10.5 = x-offset from left side of this floor's room layout
484 -- 29.75 = spacing between floors
485 -- -19.25 = z-offset below this floor's room layout
486 movePatrolTray( theFloor, floorPos + 10.5 + ( theFloor - 1 ) * 29.75, -19.25 )
487
488end
489
490
491-- Lay character cards and tokens out on the board.
492function setupCharacters()
493
494 -- Get the number of players, the character card deck,
495 -- and the bag of stealth tokens.
496 local numPlayers = settings.players.value
497 local theCharDeck = Global.call( "getObjectFromName", { "Character Deck" } )
498 local stealthBag = Global.call( "getObjectFromName", { "Stealth Tokens" } )
499
500 -- Deal and arrange the character cards and tokens.
501 for i = 1, numPlayers do
502
503 -- Calculate x and z coordinates for the character card.
504 -- I don't put them directly into the position parameter because
505 -- other pieces will be placed relative to them.
506
507 -- Version 1.0 centered the player cards based on number of players.
508 -- Making sense of constants:
509 -- 17.5 = spacing between cards
510 -- 8.75 = how much to offset for number of players (yes, half of 17.5)
511 -- local xPos = ( i-1 ) * 17.5 - ( numPlayers-1 ) * 8.75
512
513 -- Since I added Hand zones in 1.1, I just lay them out to align with
514 -- the zones.
515 -- Making sense of constants:
516 -- 17.5 = spacing between player cards
517 -- -26.25 = leftmost player card
518 local xPos = ( i-1 ) * 17.5 - 26.25
519 local zPos = -31.5
520
521 -- Prepare the position parameter for drawing and moving pieces.
522 local params = {}
523 params.position = {}
524 params.position.y = 3
525
526 -- Draw and place a character card.
527 params.position.x = xPos
528 params.position.z = zPos
529 local thisCharCard = theCharDeck.takeObject( params )
530
531 -- Do character-specific additional setup.
532 if thisCharCard.getName() == "Raven" then
533
534 -- The Raven gets the Crow counter.
535 local theCrow = Global.call( "getObjectFromName", { "Crow" } )
536 params.position.x = xPos + 3.5
537 params.position.z = zPos + 3.5
538 theCrow.setPositionSmooth( params.position )
539
540 elseif thisCharCard.getName() == "Rigger" then
541
542 -- The Rigger gets the Dynamite tool card. Find it in the tool deck.
543 local toolDeck = Global.call( "getObjectFromName", { "Tool Deck" } )
544 local toolCards = toolDeck.getObjects()
545 local dynamiteTool = nil
546
547 -- Search the tool deck for the Dynamite card and draw it.
548 for i, thisTool in pairs( toolCards ) do
549
550 if thisTool.nickname == "Dynamite" then
551
552 params.position.x = xPos + 3.5
553 params.flip = true
554 params.index = i-1 -- I can't even.
555 dynamiteTool = toolDeck.takeObject( params )
556
557 end
558
559 end
560
561 end
562
563 -- Get and place the token for this character next to its card.
564 local thisCharToken = Global.call( "getObjectFromName",
565 { thisCharCard.getName() .. " Token" } )
566 params.position.x = xPos + 5.25
567 params.position.z = zPos
568 thisCharToken.setPositionSmooth( params.position )
569
570 -- Get and place three stealth tokens for this character.
571 params.position.z = zPos + 5.25
572
573 for j = 1, 1 do
574 -- Making sense of constants: 1.75 = grid increment
575 params.position.x = xPos + (j-2) * 1.75
576 stealthBag.takeObject( params )
577 end
578
579 end
580
581end
582
583
584--[[------------
585 Utility functions.
586--]]------------
587
588-- Return the x and z coordinates and facing for a wall.
589function getWallLoc( theFloor, theWall )
590
591 -- Get the left edge of the layout.
592 local theLeftEdge = Global.getVar( "leftEdge" )
593
594 local theLoc = {}
595
596 -- Wall positions 1-12 are NS walls, positions 13-24 are EW walls.
597 -- All wall positions are counted left-to-right, then top-to-bottom.
598 if theWall <= 12 then
599
600 -- Making sense of constants:
601 -- x theLeftEdge, z 10.5 = base location (top-left N-S wall)
602 -- 3.5 = offset for first N-S wall position (between first two rooms)
603 -- 29.75 = distance between floors
604 -- 3 = number of N-S walls in each row
605 -- 7 = spacing between walls
606 theLoc.x = theLeftEdge + 3.5 + ( theFloor-1 ) * 29.75 + ( ( theWall-1 ) % 3 ) * 7
607 theLoc.z = 10.5 - math.floor( ( theWall-1 ) / 3 ) * 7
608
609 else
610
611 -- Making sense of constants:
612 -- x theLeftEdge, z 7 = base location (top-left E-W wall)
613 -- 29.75 = distance between leftmost EW wall card of each floor
614 -- 4 = number of E-W walls in each row
615 -- 7 = spacing between walls
616 -- Subtract 12 from each wall number to account for E-W numbering.
617 theLoc.x = theLeftEdge + ( theFloor-1 ) * 29.75 + ( ( theWall-13 ) % 4 ) * 7
618 theLoc.z = 7 - math.floor( ( theWall-13 ) / 4 ) * 7
619
620 end
621
622 return theLoc
623
624end
625
626
627-- Move a patrol deck tray and its associated objects.
628function movePatrolTray( theFloor, theX, theZ )
629
630 --Get all the objects to be moved.
631 local thePatrolTray = Global.call( "getObjectFromName", { "Patrol" .. theFloor .. " Tray" } )
632 local thePatrolDeck = Global.call( "getObjectFromName", { "Patrol" .. theFloor .. " Deck" } )
633 local theGuard = Global.call( "getObjectFromName", { "Guard" .. theFloor } )
634 local theDie = Global.call( "getObjectFromName", { "Guard" .. theFloor .. " Die" } )
635
636 -- Move them! The location parameter refers to the tray,
637 -- so the other objects will be offset appropriately.
638 thePatrolTray.setPositionSmooth( { theX, 3, theZ } )
639 thePatrolDeck.setPositionSmooth( { theX - 3.5, 6, theZ + 1.75 } )
640 theGuard.setPositionSmooth( { theX + 3.5, 6, theZ + 1.75 } )
641 theDie.setPositionSmooth( { theX, 6, theZ + 1.75 } )
642
643end