Making a crowd of cloned characters

Started by Samwise, Tue 06/03/2007 11:39:41

Previous topic - Next topic

Samwise

Hi all,

In my game I have two scenes with multiple and identical characters - one with about 10-15 soldiers, and one with about 20 activists.

I want them all to look the same, and to react the exact same way to the player's actions.

I know it's possible to create all these characters manually by using the same views and copying all the scripts, but for 30-35 characters that would be a real pain.

Does anyone have an idea how to solve this issue?

Ashen

#1
You can more quickly assign the views with a couple of while loops in game_start:
Code: ags

int Temp = 1; // Or first 'activist' character
while (Temp < 21) { // first non-activist
  character[Temp].ChangeView(ACTIVISTVIEW);
  // Can also set Speech view, Name, etc if needed
  Temp++;
}
 // If 'soldiers' and 'activists' aren't consectutive characetrs, set Temp to first soldier
while (Temp < 36) { // first non-soldier
  character[Temp].ChangeView(SOLDIERVIEW);
  // Also set Speech view if needed
  Temp++;
}

I've done something similar in the past, and it works fine.

For the interactions, you could probably use unhandled_event - just check if the character is a soldier or activist, and run the appropriate interaction:
Code: ags

function unhandled_event(int what, int type) {
  if (what == 3) { // Character was clicked
    Character *theChar = Character.GetAtScreenXY(mouse.x, mouse.y);
    int Temp = theChar.ID;
    if (Temp >= 1 && Temp < 21) { // character is an 'activist'
      // 'Activist' reactions here. Use 'theChar' to make sure the right character reacts, e.g.
      theChar.Say("Don't push me, fascist!");
    }
    else if (Temp >= 21 && Temp < 36) {
      // 'Soldier' reactions here. Use 'theChar' to make sure the right character reacts, e.g.
      theChar.Say("Clear off, hippy.");
    }
  }
}

Not fully tested, but SHOULD work (provided the values for Temp are right, and I didn't mess up the braces...).
I know what you're thinking ... Don't think that.

Samwise

Thank you very much.

There isn't a conventional method or a specific module to clone characters, right?

Ashen

No, because there's really enough call for that in adventure games (which is obviously what AGS is mostly for), that it's worth including as standard. That said, some sort of copy-paste function for Characters, Inventory Items and GUIs might be a nice little timesaver.

You could probably module-ify this code whith a bit of work, if you were interested, but I'm not sure it'd be worth it.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk