Scripting a contagion.

Started by KodiakBehr, Wed 17/08/2011 19:40:28

Previous topic - Next topic

KodiakBehr

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...

Khris

A global bool array will do the trick.

Code: ags
//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.

monkey0506

Dunno why Khris hates dynamic arrays ::), but I'm a big fan:

Code: ags
// 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];

KodiakBehr


SMF spam blocked by CleanTalk