Gimli wrote:
Quote:
It now supports up to 4 players. Originally it would let you play 4 players, but the goals of the game were not tracked correctly;
Well done.
I would love to see what you've done.
I suspect you use the DIM shell game approach?
Hey Gimli. I saw the approach you're talking about in SLAMT1LTs Star Trek table. At some point he suggested someone make Star Trek multiplayer, but I thought I'd finish my Midieval Madness shtuff first. That said, I did not use the Shell game approach...
What I did was use arrays for each variable that needs to be player specific. There are chunks/examples of this in the default table script:
Code:
' initialise all the variables which are used for the duration of the game
' (do all players incase any new ones start a game)
For i = 1 To constMaxPlayers
' Bonus Points for the current player
BonusPoints(i) = 0
' Initial Bonus Multiplier
BonusMultiplier(i) = 1
' Balls Per Game
BallsRemaining(i) = nvBallsPerGame
' Number of EB's out-standing
ExtraBallsAwards(i) = 0
Next
Even in the original code for this table, the AddScore references some Arrays
nvScore(CurrentPlayer)
BallsRemaining(CurrentPlayer)
Being that I was new to FP scripting, I figured I should do what the original authors did. In the end, I think it's cleaner (just my personal opinion).
For example, to track the number of times the castle has been hit I use:
Code:
'Original Code
dim Castlegatehits
'Multi-Player Code
Dim CastleGateHits(4)
Then, wherever the original CastleGateHits was used, you change it to:
Code:
CastleGateHits(CurrentPlayer)
This change is actually pretty simple as a Find/Replace does
almost all the work for you. Here is an example of the change...
Code:
'Original Code
CastlegateHits = CastlegateHits + 1
'Multi-Player Code
CastleGateHits(CurrentPlayer) = CastleGateHits(CurrentPlayer) + 1
Doing it this way avoids all those extra Player1-4 variables as well as swapping values to/from them. You do still need to adjust the table when a player starts a new ball though. Most of the tables I've look at use the targets and lights to determine the game logic, so setting these appropriately (which should happen anyways) is important. It's not difficult, but necessary.
On a side note, I did modify a bunch of code to use the Array variables instead of the status of a light or target. This is much more consistent, and makes multi-player very easy to implement. For example, when you hit a joust target, you simply increment the joust target counter, then call a Sub to adjust the lights (based on the joust target counter). This same Sub is then used when a player starts a new ball, or after multiball, or after the final battle, etc... Very clean and consistent.
I also use helper Subs a lot rather than copy/pasted code. In the end, the lines of code drop from roughly 15k to 9k.
Anyways, using the same example, when a new player starts, you need to set the Castle up (lower/raise the bridge, open/close the gate). This code does that:
Code:
Select Case (CastleGateHits(CurrentPlayer) - 1) ' Reset the castle
Case 1, 2, 6, 7, 8, 13, 14, 15, 16, 22, 23, 24, 25, 26, 33, 34, 35, 36, 37, 38, 46, 47, 48, 49, 50, 51, 52
OpenGate FALSE
LowerBridge TRUE
BulbCF1.State = BulbOff
BulbCF2.State = BulbOff
BulbCF3.State = BulbOff
Case 3, 9, 17, 27, 39, 53
OpenGate TRUE
LowerBridge TRUE
CastleOnFire
Case Else
OpenGate FALSE
LowerBridge FALSE
BulbCF1.State = BulbOff
BulbCF2.State = BulbOff
BulbCF3.State = BulbOff
End Select
The above also contains an example of 2 Subs I added:
This helps makes the code more compact (again, a personal preference), but also lets me easily add new logic that will happen every time the Gate is modified. For instance it will only play the "LowerGate" sound if the status of the gate is actually changing. Imagine player 1s turn ends and the Gate is down. When player two starts, it will call OpenGate to set it appropriately for Player 2. So, if Player 2 needs the gate down (and it already is), don't play a sound. It's the little things like that which I try to accommodate.
I do enjoy writing FP script, so if you know anyone who needs some scripting help, I'm willing and happy to jump in and try to help.
Hopefully this information is helpful.