Multiple characters issue (SOLVED)

Started by jamesreg, Thu 17/09/2009 13:44:36

Previous topic - Next topic

jamesreg

I have an issue that I'm sure is simple to figure out butI'm still to new to this to understand fully what I need to do.

I have a game based off Star Trek which will have to have multiple characters that will be playable during landing party missions.

I will need the play at random to be able to select various characters to play and switch back and forth between them

I have that part figured out and working but my problem is this.

I have it set up that for example you use the Look icon to look at a rock on the ground

the response would be an avatar portrait of the character appears with a special text box gui I made custom for each character.

This works just fine as well however when I switch characters and they look at something they are getting the main character I scripted avatar and text box

I need to know how i tell it to check and see who is the active player and then pull up the correct text box and avatar

I know its something simple like a simple check to see if active character is so and so and do this or that

But I could use a point in the right direction if someone doesnt mind

Khris

Something like this?

Code: ags
function CustomSay(String text) {
  if (player == cKirk) {
    gAvatar.BackgroundGraphic = 123;   // set Kirk sprite as background of avatar GUI
    SetTextWindowGUI(1);   // set Kirk's TextWindow GUI
  }
  else if (player == cSpock) {
    ...
  }

  gAvatar.Visible = true;
  Display(text);
  gAvatar.Visible = false;
}

jamesreg

#2
Still having a problem figuring out how to implement this here is the script commandsI'm using

this is nested in the look at hotspot function

function hHotspot1_Look()
{


gspocktalk.Visible=true;   //turns on the avatargui
gStatusline.Transparency=(75);  //sets the gui window tranparency
gStatusline.Visible=true;    //turns on the gui the text window
Overlay* spockla = Overlay.CreateTextual(150,475,440,8,0,"Its a fountain."); //creates the text overla
  Wait(75);  //waits a few mins
  spockla.Remove(); //removes the text
  gspocktalk.Visible=false; //removes the avatar pic
gStatusline.Visible=false;  //removes the text window

}

I attempted what you said but somehow along the way messed it up
The above code is my script for displaying characters text  on its bascialy the same
for each character except i change the colors of the box and name of avatar and so on

do i put the if (player == cspock) {

above my script

and the else if (player == cspock) {

in the middle and then repeat my script commands

can i do this multiple times like up to 5 times for 5 diff characters?

Khris

Imagine having to write (or paste) all that 5 times into each hotspot/object interaction. Phew.
Luckily, that's what custom functions are for.

You have to automatize all that to the greatest extent, similarly to what I did.
Approach it like this: what are the specific differences of the five blocks of code for each person, or, what is the difference that ends up being shown to the player?
I imagine it's just the portrait picture and the color of the speech text.
Both these informations can be determined by checking the active player character.

So all the custom functions needs to know is the line of text.
Plus, you can use one GUI to display the five portraits, even if they aren't of the same size.

Code: ags
function CustomSay(String text) {
  int speech_color;
  if (player == cKirk) {
    gAvatar.BackgroundGraphic = 123;   // set Kirk's portrait sprite as background of avatar GUI
    speech_color = 0;  // black
  }
  else if (player == cSpock) {
    gAvatar.BackgroundGraphic = 124;   // set Spock's portrait sprite as background of avatar GUI
    speech_color = 24;  // light grey
  }
  else if (player == cMcCoy) {
    ...
  }
  ...

  gAvatar.Visible = true;
  gStatusline.Vsible = true;
  Overlay* o = Overlay.CreateTextual(150, 475, 440, 8, speech_color, text); //creates the text overlay

  StartCutscene(eSkipMouseClick); // allow player to skip text
  Wait(((text.Length / game.text_speed) + 1) * GetGameSpeed());  // (AGS formula)
  EndCutscene();

  o.Remove(); //removes the text
  gAvatar.Visible = false;
  gStatusline.Visible=false;  //removes the text window  
}


Now, all you have to put inside the hotspot_Look is
  CustomSay("Its a fountain.");
The function will take care of the rest.


SMF spam blocked by CleanTalk