I've been working on a program that puts five people on the screen for a police line up. The people are randomly generated, so each time someone comes onto the screen, they have a different skin and name and other stats. The problem I've been having is that each of the characters follow the stats of the last character to enter the room. I've been fiddling with arrays to contain the information of each of the five characters, and everything appears that it should be working, but it's not. I looked around for some info on arrays and structs, but I'm coming up dry. If anyone can give me some insight, it would be greatly appreciated.
Can you provide the minimum amount of code necessary to reproduce your issue? This is too broad to guess.
Here's the bulk of it. The People struct creates a bunch of random people, and then later calls on them. With the Fools struct, I'm trying to get it to correspond with each of the five characters, but it only keeps track of the last one called in the People struct.
int CallSuspect;
String FirstName[520];
String LastName[260];
struct People{
bool Active;
int Formality;
int Manners;
int Forgetfullness;
int Firstly;
int Middly;
int Lastly;
int Beard;
int Hair;
int PersonView;
int Race;
};
struct Placement{
int MumX;
int MumY;
bool Active;
int Dummy;
};
Placement Fools[5];
People Suspects[1000];
function MakePlacements(){
Fools[0].MumX = 120;
Fools[0].MumY = 120;
Fools[0].Active = true;
Fools[1].MumX = 140;
Fools[1].MumY = 120;
Fools[1].Active = true;
Fools[2].MumX = 160;
Fools[2].MumY = 120;
Fools[2].Active = true;
Fools[3].MumX = 180;
Fools[3].MumY = 120;
Fools[3].Active = true;
Fools[4].MumX = 200;
Fools[4].MumY = 120;
Fools[4].Active = true;
}
function MakeSuspects(){
int Countit = 999;
while (Countit >= 0){
int ViewCount = 0;
Suspects[Countit].Active = true;
Suspects[Countit].Formality = Random(2);
Suspects[Countit].Manners = Random(2);
Suspects[Countit].Forgetfullness = Random(2);
Suspects[Countit].Firstly = Random(519);
Suspects[Countit].Middly = Random(519);
Suspects[Countit].Lastly = Random(259);
Suspects[Countit].Beard = Random(1);
Suspects[Countit].Hair = Random(1);
if (Suspects[Countit].Beard == 0){
ViewCount += 7;
}
if (Suspects[Countit].Hair == 0){
ViewCount += 14;
}
Suspects[Countit].Race = Random(3);
if (Suspects[Countit].Race == 1){
ViewCount += 28;
}
else if (Suspects[Countit].Race == 2){
ViewCount += 56;
}
else if (Suspects[Countit].Race == 3){
ViewCount += 84;
}
Suspects[Countit].PersonView = (Random(6)+1) + ViewCount;
Countit --;
}
}
function RandomName(int Pack){
CallSuspect = Random(999);
Fools[Pack-1].Dummy = CallSuspect;
character[Pack].ChangeView(Suspects[Fools[Pack-1].Dummy].PersonView);
Display("Number is %d",Fools[0].Dummy);
Display("Number is %d",Fools[1].Dummy);
Display("Number is %d",Fools[2].Dummy);
Display("Number is %d",Fools[3].Dummy);
Display("Number is %d",Fools[4].Dummy);
}
function Talkie(int Pick){
if (Suspects[Fools[Pick-1].Dummy].Manners == 2){
character[Pick].Say("It's a pleasure to meet you.");
character[Pick].Say("My name is %s %s. %s", FirstName[Suspects[Fools[Pick-1].Dummy].Firstly], FirstName[Suspects[Fools[Pick-1].Dummy].Middly].Truncate(1), LastName[Suspects[Fools[Pick-1].Dummy].Lastly]);
character[Pick].Say("My middle initial stands for %s", FirstName[Suspects[Fools[Pick-1].Dummy].Middly]);
}
else if (Suspects[Fools[Pick-1].Dummy].Manners == 1){
int Greet = Random(1);
character[Pick].Say("Hello.");
if (Greet == 0){
character[Pick].Say("I'm %s %s.", FirstName[Suspects[CallSuspect].Firstly], LastName[Suspects[CallSuspect].Lastly]);
}
else{
if (FirstName[Suspects[Fools[Pick-1].Dummy].Firstly].Length > 5){
character[Pick].Say("I'm %s %s.", FirstName[Suspects[Fools[Pick-1].Dummy].Firstly].Truncate((FirstName[Suspects[Fools[Pick-1].Dummy].Firstly].Length)/2), LastName[Suspects[Fools[Pick-1].Dummy].Lastly]);
character[Pick].Say("%s's short for %s.", FirstName[Suspects[Fools[Pick-1].Dummy].Firstly].Truncate((FirstName[Suspects[Fools[Pick-1].Dummy].Firstly].Length)/2), FirstName[Suspects[Fools[Pick-1].Dummy].Firstly]);
}
else {
character[Pick].Say("I'm %s %s.", FirstName[Suspects[Fools[Pick-1].Dummy].Firstly], LastName[Suspects[Fools[Pick-1].Dummy].Lastly]);
}
}
}
else{
int Greet = Random(1);
if (Greet == 0){
character[Pick].Say("I'm %s.", FirstName[Suspects[Fools[Pick-1].Dummy].Firstly]);
}
else{
if (FirstName[Suspects[Fools[Pick-1].Dummy].Firstly].Length > 5){
character[Pick].Say("I'm %s.", FirstName[Suspects[Fools[Pick-1].Dummy].Firstly].Truncate((FirstName[Suspects[Fools[Pick-1].Dummy].Firstly].Length)/2));
}
else{
character[Pick].Say("I'm %s.", FirstName[Suspects[Fools[Pick-1].Dummy].Firstly]);
}
}
}
if (Suspects[CallSuspect].Beard == 0){
character[Pick].Say("I have a beard.");
}
if (Suspects[CallSuspect].Hair == 0){
character[Pick].Say("I have hair.");
}
character[Pick].Walk(Fools[Pick-1].MumX, 140, eBlock, eAnywhere);
character[Pick].Walk(330, 140, eBlock, eAnywhere);
character[Pick].ChangeRoom(1, -10, 140);
RandomName(Pick);
character[Pick].Walk(Fools[Pick-1].MumX, 120, eBlock, eAnywhere);
}
I cant be sure, but from a quick scan of the code in the Talkie function occasionally you use Pick/Pick-1 to reference which one and sometimes you use CallSuspect, however in the Talkie routine you never set CallSuspect variable so it is referencing the last one you called during the RandomName function.
That was it! That fixed it! Thank you very, very much! :smiley::smiley::smiley::smiley::smiley::smiley: