Multiple Characthers

Started by metalmario991, Mon 02/02/2015 15:38:46

Previous topic - Next topic

metalmario991

I am working on a 9-verb game where at the start you can pick 3 characthers and switch between them throughout the game similar to Maniac Mansion. I have a few questions about doing so.
1) How would I program selection to work?
2) What could I do for the in-game character switching?
3) How do I make it so certain characthers do certain actions?
4) What would be needed to kill off characthers?

Andail

Hello,
This is very easy to achieve, it's just a matter of setting the player character, by
Character.SetAsPlayer()

(exchange Character to the script name of your character)

All states that pertain to the character, like which room they're in and what inventory items they have, will change accordingly.

"Killing off" a character is simply done by proclaiming them dead and disabling whatever GUI button or command that changes characters :)

monkey0506

I will also point out that in your scripts you need to make sure you are using the player keyword to refer to the player, not cEgo. I have seen many people use cEgo and player interchangeably. cEgo is just the default name of the first character, and can be renamed to whatever you want. player only refers to the current player character, whichever character that might be.

Code: ags
// on_mouse_click
  // ...
  else cEgo.Walk(mouse.x, mouse.y); // move the player (WRONG, this ONLY moves cEgo!)


Code: ags
// on_mouse_click
  // ...
  else player.Walk(mouse.x, mouse.y); // move the player (RIGHT, this moves the player no matter which character is being controlled)

metalmario991

Okay, but I understand the whole player thing but A) How do I make is so for example, Characther A uses something with an object and says "I can repair this." while Characther B says "I can't fix that!" stuff like that. B) At the start when you select 3 characthers how do I make sure for the game to check that you have 3 selected before continuing. C) How would I give the player the ability to switch on the fly in-game?
These are the things I REALLY need to know.

Andail

You can always check which character is playing by using player, like
if (player == cWarrior) cWarrior.Say ("I can repair this");
else player.Say ("I can't fix that");

I think for now you should probably start making a really simple game and try out the scripting language a bit, because there's no way you can just dive into the code without having learnt the basics.

DISCLAIMER
If you, or anybody else reading this thread, intend to make your game a 'talkie' (i.e voiced dialogue), then you never use player.Say, or the dialogue script will be impossible to use.

Slasher

#5
Hi,

you could do a player condition:

Code: ags

{
 if(player==A){ // player A
// Do this
} else if(player==B){ // player B
//Do this 
}
}


You could make a Global variable Int (name it say Chars_Chosen). set it to 0.
Add 1 to Chars_Chosen when each character is selected. if exactly 3 have not been selected you can not move on and you could have a message to display why and Chars_Chosen gets rest back to 0.

Code: ags

}
 if(Chars_Chosen==3){
// Do this
} else {
 Display("You need to select three players.");
}
}


These are basic examples to get you started and can get quite complex.

EDIT: Just seen Andail's post...




Adeel

Quote from: Andail on Mon 02/02/2015 19:26:36
DISCLAIMER
If you, or anybody else reading this thread, intend to make your game a 'talkie' (i.e voiced dialogue), then you never use player.Say, or the dialogue script will be impossible to use.

I'm curious. Can you please elaborate?

Andail

Quote from: Adeel S. Ahmed on Tue 03/02/2015 10:15:36
Quote from: Andail on Mon 02/02/2015 19:26:36
DISCLAIMER
If you, or anybody else reading this thread, intend to make your game a 'talkie' (i.e voiced dialogue), then you never use player.Say, or the dialogue script will be impossible to use.

I'm curious. Can you please elaborate?

Let's say you have two characters that can be playable. One is named Tom and one is named Sara. Let's say you have some generic responses to certain generic events, such as
player.Say ("I can't do that");

How will you voice those lines? When you export the dialogue manuscript, you won't know who says it.

You'll either have to make such remarks parts of the narration, or constantly check who's currently the player character and use cTom.Say(); or cSara.Say(); respectively.

Snarky

#8
Just to be contrary, if you find yourself in that situation, how hard is it really to run a search-and-replace command over your script files? Can't you simply write something like this...

Code: AGS
function CurrentPlayerSay(String message)
{
   if(player == cBernard)
      cBernard.Say(message);
   else if(player == cHoagie)
      cHoagie.Say(message);
   else if(player == cLaverne)
      cLaverne.Say(message);
   else // This shouldn't happen!
      player.Say(message);
}


And replace every "player.Say(" with "CurrentPlayerSay("?

(Of course, if you've written a lot of character-specific dialog using player.Say() commands, this will cause it to be included in the voice script for all the other player characters as well.)

SMF spam blocked by CleanTalk