Hi Guys,
I'm afraid I've hit on a wall and I need to ask you for help.
In my game, the player has to walk onto a number of regions in a specific order to solve a puzzle. However, the order changes depending on which region is walked onto first. There are four regions in total and the player can decide from which they are going to start the sequence.
In order to do that I set up four regions in my room and used four region_WalksOnto functions to detect the event of walking onto them. What's more, I've got a counter of how many regions have been walked onto in a correct order (I called it a numberOfTrues) and an array of possible paths (there are four: "1,2,3,4,1", "2,3,4,1,2", "3,4,1,2,3", "4,1,2,3,4"; the numbers represent the IDs of the regions; each path has five values, where each five stands for a whole round). This way I've been able to check if the next region the player walks onto is the next one on the given path. If the player walks on a region that is not correct and breaks the sequence, then the numberOfTrues gets reset to 1 and a new path is selected.
Now, I'm not saying it's the best way of doing it but it seemed to be working fine. At least I thought so until I stopped displaying the current value of numberOfTrues during the game. What I mean is during the development I would use either Display() or a label to show the current values of numberOfTrues or what region had been walked onto. Without displaying those values the game seems to be working randomly... Sometimes it would work fine and the character would recognise that the path has been completed and then it would not. And that happens only when the values are not displayed.
I've tested it now about 30 times... (at this point, even thought it's a game I've made, I am sick of looking at it
) and I'm sure it works fine with the values displayed (with the use of Display() or labels) and that it works randomly without.
I'm far from saying that this might be the case, but could it be possible that for some reason AGS may be failing to detect walking onto a region?
Here is the excerpt of my code that handles the walking onto regions plus variables used in them:
Code: ags
P.S.
I know the code inside WalkOnto functions could be put into a separate function but I got bogged down with this problem and haven't got time to do it.
I'm using AGS 3.4.3.
I would appreciate any suggestions as I feel defeated by AGS
I'm afraid I've hit on a wall and I need to ask you for help.
In my game, the player has to walk onto a number of regions in a specific order to solve a puzzle. However, the order changes depending on which region is walked onto first. There are four regions in total and the player can decide from which they are going to start the sequence.
In order to do that I set up four regions in my room and used four region_WalksOnto functions to detect the event of walking onto them. What's more, I've got a counter of how many regions have been walked onto in a correct order (I called it a numberOfTrues) and an array of possible paths (there are four: "1,2,3,4,1", "2,3,4,1,2", "3,4,1,2,3", "4,1,2,3,4"; the numbers represent the IDs of the regions; each path has five values, where each five stands for a whole round). This way I've been able to check if the next region the player walks onto is the next one on the given path. If the player walks on a region that is not correct and breaks the sequence, then the numberOfTrues gets reset to 1 and a new path is selected.
Now, I'm not saying it's the best way of doing it but it seemed to be working fine. At least I thought so until I stopped displaying the current value of numberOfTrues during the game. What I mean is during the development I would use either Display() or a label to show the current values of numberOfTrues or what region had been walked onto. Without displaying those values the game seems to be working randomly... Sometimes it would work fine and the character would recognise that the path has been completed and then it would not. And that happens only when the values are not displayed.
I've tested it now about 30 times... (at this point, even thought it's a game I've made, I am sick of looking at it

I'm far from saying that this might be the case, but could it be possible that for some reason AGS may be failing to detect walking onto a region?
Here is the excerpt of my code that handles the walking onto regions plus variables used in them:
int tablePaths[20];
int pathSelected;
int numberOfTrues = 0;
function room_Load()
{
//starting from south
tablePaths[0] = 1;
tablePaths[1] = 2;
tablePaths[2] = 3;
tablePaths[3] = 4;
tablePaths[4] = 1;
//starting from east
tablePaths[5] = 2;
tablePaths[6] = 3;
tablePaths[7] = 4;
tablePaths[8] = 1;
tablePaths[9] = 2;
//starting from north
tablePaths[10] = 3;
tablePaths[11] = 4;
tablePaths[12] = 1;
tablePaths[13] = 2;
tablePaths[14] = 3;
//starting from west
tablePaths[15] = 4;
tablePaths[16] = 1;
tablePaths[17] = 2;
tablePaths[18] = 3;
tablePaths[19] = 4;
}
function region1_WalksOnto()
{
if(listHasBeenRead == true && tableWalkedAroundThreeTimes == false)
{
if(numberOfTrues == 0 && justEnteredKitchen == true)
{
pathSelected = 0;
numberOfTrues++;
}
else
{
if(region[1].ID == tablePaths[pathSelected+numberOfTrues])
{
numberOfTrues++;
}
else
{
numberOfTrues = 1;
pathSelected = 0;
}
}
if(justEnteredKitchen == true && numberOfTrues == 2)
{
justEnteredKitchen = false;
}
}
}
function region2_WalksOnto()
{
if(listHasBeenRead == true && tableWalkedAroundThreeTimes == false)
{
if(numberOfTrues == 0 && justEnteredKitchen == true)
{
pathSelected = 5;
numberOfTrues++;
}
else
{
if(region[2].ID == tablePaths[pathSelected+numberOfTrues])
{
numberOfTrues++;
}
else
{
numberOfTrues = 1;
pathSelected = 5;
}
}
if(justEnteredKitchen == true && numberOfTrues == 2)
{
justEnteredKitchen = false;
}
}
}
function region3_WalksOnto()
{
if(listHasBeenRead == true && tableWalkedAroundThreeTimes == false)
{
if(numberOfTrues == 0 && justEnteredKitchen == true)
{
pathSelected = 10;
numberOfTrues++;
}
else
{
if(region[3].ID == tablePaths[pathSelected+numberOfTrues])
{
numberOfTrues++;
}
else
{
numberOfTrues = 1;
pathSelected = 10;
}
}
if(justEnteredKitchen == true && numberOfTrues == 2)
{
justEnteredKitchen = false;
}
}
}
function region4_WalksOnto()
{
if(listHasBeenRead == true && tableWalkedAroundThreeTimes == false)
{
if(numberOfTrues == 0 && justEnteredKitchen == true)
{
pathSelected = 15;
numberOfTrues++;
}
else
{
if(region[4].ID == tablePaths[pathSelected+numberOfTrues])
{
numberOfTrues++;
}
else
{
numberOfTrues = 1;
pathSelected = 15;
}
}
if(justEnteredKitchen == true && numberOfTrues == 2)
{
justEnteredKitchen = false;
}
}
}
P.S.
I know the code inside WalkOnto functions could be put into a separate function but I got bogged down with this problem and haven't got time to do it.
I'm using AGS 3.4.3.
I would appreciate any suggestions as I feel defeated by AGS
