Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: KodiakBehr on Wed 17/08/2011 19:40:28

Title: Scripting a contagion.
Post by: KodiakBehr on Wed 17/08/2011 19:40:28
I've hit a mental block and a coffee shortage, so I could use a fresh set of eyes.

You've got a team of 3 to 6 people.
If a randomly generated "sickness event" occurs, a new random number is generated between 0 and whatever the team size is.  The team member assigned to that number "gets sick".

Big whoop.

Now what I want is to show the effects of a contagion.  So if any team member gets sick, the chances of additional team members getting sick increases.  I've done this by changing the likelihood of a "sickness event" occurring.  Problem is, I don't want the SAME team member getting sick again, only new ones.  How would you go about coding this so you're not dealing with a ton of superfluous variables?

I'm sure it's straightforward, but I can't seem to dream up anything elegant...
Title: Re: Scripting a contagion.
Post by: Khris on Wed 17/08/2011 21:50:52
A global bool array will do the trick.

//header

import bool is_sick[10];

//global script

bool is_sick[10];
export is_sick;


If say cGuy gets infected, call is_sick[cGuy.ID] = true;

Before infecting somebody else, run a loop until the randomly selected character's is_sick is false.
Title: Re: Scripting a contagion.
Post by: monkey0506 on Wed 17/08/2011 23:14:35
Dunno why Khris hates dynamic arrays ::), but I'm a big fan:

// header

import bool is_sick[];

// script

bool is_sick[];
export is_sick;

// wherever team size is established, since you said it ranges from 3-6
is_sick = new bool[team_size];
Title: Re: Scripting a contagion.
Post by: KodiakBehr on Wed 17/08/2011 23:41:46
Derp.  Thanks guys.