I'm making a monopoly-like tower defense game. I have most everything worked out, but here's my problem: All players move fine the first time, but the second time they move, it rolls twice and moves twice as far and so on... If there's only one player it works. Here's my triggers:
Roll 2 (the function that says to which place on the board they will move)
Actions
Variable - Set Current Turn Unit Placement = 0
If
P2 Pawn != No Unit
Then
Variable - Set Current Turn Unit = P2 Pawn
UI - Display ((Name of player (Owner of Current Turn Unit)) + "'s turn") for (All players) to Subtitle area
Variable - Set Move Distance = (Random integer between 1 and 12)
Variable - Set P2 Pawn Placement = (P2 Pawn Placement + Move Distance)
If
P2 Pawn Placement >= 40
Then
Variable - Modify P2 Pawn Placement: - 40
Variable - Set Current Turn Unit Placement = P2 Pawn Placement
UI - Display (Combine ("Player 2 has rolled a ", (Text(Move Distance)))) for (All players) to Subtitle area
Variable - Set Current Turn Player = (Owner of Current Turn Unit)
Trigger - Run Move (Ignore Conditions, Don't Wait until it finishes)
Else
Trigger - Run Roll 3 (Check Conditions, Don't Wait until it finishes)
Here's some code from the move function:
Move
Actions
If
Current Turn Unit Placement == 17
Then
Unit - Order Current Turn Unit to ( Move targeting [Point]17) (Replace Existing Orders)
(this is repeated fro all 40 spaces)
If
Current Turn Player == 2
Then
Unit - Wait until Current Turn Unit Becomes idle
General - Wait 5.0 Game Time seconds
Trigger - Run Roll 3 (Check Conditions, Don't Wait until it finishes)
(repeated for all four players)
Without looking at more specifics, here are two things to watch for:
(1) Is your code executing based on some event? If so, is that event getting fired multiple times when you don't expect it to? A good test method is to have your code fire on a specific chat message so you can fire it whenever you want to test it.
(2) Do you have global variables that are carrying over between turns? Should these be cleared out on each turn start?
I'm making a monopoly-like tower defense game. I have most everything worked out, but here's my problem: All players move fine the first time, but the second time they move, it rolls twice and moves twice as far and so on... If there's only one player it works. Here's my triggers:
Roll 2 (the function that says to which place on the board they will move)
Actions
Variable - Set Current Turn Unit Placement = 0
If
P2 Pawn != No Unit
Then
Variable - Set Current Turn Unit = P2 Pawn
UI - Display ((Name of player (Owner of Current Turn Unit)) + "'s turn") for (All players) to Subtitle area
Variable - Set Move Distance = (Random integer between 1 and 12)
Variable - Set P2 Pawn Placement = (P2 Pawn Placement + Move Distance)
If
P2 Pawn Placement >= 40
Then
Variable - Modify P2 Pawn Placement: - 40
Variable - Set Current Turn Unit Placement = P2 Pawn Placement
UI - Display (Combine ("Player 2 has rolled a ", (Text(Move Distance)))) for (All players) to Subtitle area
Variable - Set Current Turn Player = (Owner of Current Turn Unit)
Trigger - Run Move (Ignore Conditions, Don't Wait until it finishes)
Else
Trigger - Run Roll 3 (Check Conditions, Don't Wait until it finishes)
Here's some code from the move function:
Move
Actions
If
Current Turn Unit Placement == 17
Then
Unit - Order Current Turn Unit to ( Move targeting [Point]17) (Replace Existing Orders)
(this is repeated fro all 40 spaces)
If
Current Turn Player == 2
Then
Unit - Wait until Current Turn Unit Becomes idle
General - Wait 5.0 Game Time seconds
Trigger - Run Roll 3 (Check Conditions, Don't Wait until it finishes)
(repeated for all four players)
Any help would be greatly appreciated, thanks!
@tornato7: Go
Without looking at more specifics, here are two things to watch for:
(1) Is your code executing based on some event? If so, is that event getting fired multiple times when you don't expect it to? A good test method is to have your code fire on a specific chat message so you can fire it whenever you want to test it.
(2) Do you have global variables that are carrying over between turns? Should these be cleared out on each turn start?
@jcraigk: Go
Oh! thanks, i was having an external function to reset the values but i put them into the move fxn and it is working nicely. Thanks dude.