Getting a character portrait for a character who is in a different room?

Started by reismahnic, Sat 30/04/2016 23:54:49

Previous topic - Next topic

reismahnic

Hi, I apologize if this is mentioned somewhere, but I couldn't find anything on it in the manual.
If I have a character speak (say, in a dialog) but they are in a different room, they don't get a character portrait (I have speech set to Sierra with Background), as opposed to everyone else in the room, who does.
The text for their speech does appear, though.
How can I fix this?
Thank you very much for your time.

Scavenger

Bring them into the room, but have them be offscreen, such as at -100,-100, so they never actually are visible in the room. Then, when you are done with them, move them back to their original room.

reismahnic

I've considered that option, but unfortunately the WHOLE game is jumping between these two rooms, and the amount of extra scripting that would go into that would be... well, I would prefer to find a better way.
If there really isn't one, though, that may be what I have to do. :cry:

reismahnic

I guess I could create a bool state that makes that happen so I only have to type one line of code instead of multiple... it's just that I'm going to be doing this hundreds and hundreds of times, so I was hoping to cut down the number of times it's required.

Scavenger

Something like this?

Code: AGS


function SayAnywhere (this Character*, String text)
    {
        int prevroom = this.Room;
        int prevx = this.x;
        int prevy = this.y;
        if (prevroom != player.Room)
            {
                this.ChangeRoom (player.Room,-1000,-1000);
            }
        this.Say (text);
        this.ChangeRoom (prevroom,prevx,prevy); //does nothing if the character is already present.
    }


I haven't tested it, but it should work. Use it anywhere you would usually use Say for any character who is going to be speaking through rooms.

It is a little bizarre that the Sierra mode of speaking doesn't use a portrait if the character isn't in the room, though. I wonder why it does that.

reismahnic

I'm sorry, definitely showing my coding noob here, but... I'm assuming I would put that set of lines in the global script?
How would I call it when I'm in the dialog forms?
Thanks. I know this is a noob question. I really appreciate you taking time to help figure this out.

Scavenger

Yeah, put this in the Global Script, near the top, before you call it at any point.

You should also put this in the Global Script Header (the ASH file that goes with the global script):

Code: AGS

import function SayAnywhere (this Character*, String text);


And then you'd be able to call this function in rooms as well.

reismahnic

Sorry it took so long to get back.
Seems to be working great.
Thank you so much for your help, Scavenger. Really appreciate it.

reismahnic

Can I ask a second question?
Since I want to be able to jump between the perspectives of these two locations, I was hoping to do so by changing the player character (it is two characters making different decisions).
I was hoping to do this by changing between characters, but it seems like that doesn't work too well if I use it in the middle of a dialog script.
For example, here is how I typed it in the script.
Code: ags

 Mayfield.SayAnywhere("Yeah?");
West: Is this Andrew Mayfield?
 Mayfield.SayAnywhere("Yeah, you the cop outside?");
West: I'm Sheriff West. I want to help resolve this situation, Andrew. How are you feeling?
 Mayfield.SetAsPlayer();
West: Mayfield?
return
@1
Mayfield: I'm panicked.
@2
Mayfield: I'm calm.


How this winds up playing out:
The scene plays as normal, but when it hits the player change line, West just says 'Mayfield?'
THEN, the scene jumps to the 2nd room, and the dialog choices don't even happen.

Is this method of changing player characters mid- dialog just a dead end way of doing this?

Snarky

Yeah, this breaks because certain commands, including changing a room, can't be called from a dialog script. That is mentioned in the manual. They get queued to run at the end of the script, and then you can't jump back into the dialog to show the next options.

Scavenger

Hmm, I don't think anyone's ever tried to change player characters in different rooms during dialogs before. It seems the dialog is stopped upon room change.

If it were up to me, I'd make both rooms the same room in the code, have a black area between them, and just change the viewport to avoid this cross-room stuff. Unless, like, you really need 30 objects in both rooms. In which case, you'll need to set a bool and check it in the After Fadein of the other room.

reismahnic

Ok, it definitely seems like I may need to rethink my approach a bit.
Thank you!

Snarky

To get around the lack of portrait without needing the character to switch rooms, I would create another character cMayfieldOffscreen in the current room but off-screen, with all the same animation views as Mayfield. Then instead of Mayfield speaking, you'd have this cMayfieldOffscreen doppelganger say the lines. (And similarly with West, if necessary.) The only drawback I can think of is if you have any dialogs that can be launched by either character: in that case you'd need to make two copies of the same conversation.

You'll still probably have to change the logic for whenever you change the player character; I don't think that's something you can really do in the middle of a dialog. If the two characters are always each in their own room, you can do it pretty easily by setting a global flag indicating which dialog you're in (make it an enum, with a different value for each of the different situations where the player changes), then ending the dialog and changing the player. Then in the room_load() method for the other room, you check the global flag and start a new dialog (or whatever else is appropriate, like play a short cut-scene) to pick up where you left off.

reismahnic

Still running into issues, now more confusing to me than ever.
My solution to changing rooms was to keep everything in the same room and change the background frame, making characters transparent as needed.
I'm governing this through a global variable called 'vCharacterPositions' (an int defaulted at one), with this code in the room script:

Code: ags

function room_AfterFadeIn()
{
vCharacterPositions=1;
d1Intro.Start();
}




function room_RepExec()
{
if(vCharacterPositions==1)
{
  Mayfield.Transparency=100;
West.Transparency=0;
Cop.Transparency=0;
SetBackgroundFrame(0);
}
else if(vCharacterPositions==2)
{
  Mayfield.Transparency=0;
  West.Transparency=100;
  Cop.Transparency=100;
  SetBackgroundFrame(1);
}
}


I would think this would work! In the dialog script, I call it.

Code: ags

//Title card: BOSTON, 1974
 Display("BOSTON, 1974");
//Location: Street outside bank
//2 characters onscreen:  cop and Sheriff West.

//*Sheriff West enters.*
 vCharacterPositions=1;


West: When did he go in?
Cop: Half hour ago.
West: Three hostages?
Cop: All civilians. The tellers all ran out the back when he fired in the air.
West: Got a name?
Cop: Yeah, Andrew Mayfield.
West: Ok, let me talk to him.

//*West picks up the car phone*

//Location: Bank interior

//4 characters onscreen: Andrew Mayfield and 3 hostages, standing against a wall.

//*Andrew Mayfield picks up the ringing phone*

Mayfield: Yeah?
West: Is this Andrew Mayfield?
Mayfield: Yeah, you the cop outside?
West: I'm Sheriff West. I want to help resolve this situation, Andrew. How are you feeling?
 vCharacterPositions=2;
West: Mayfield?
//CHOICE: Calm or Panicked? If Calm, go to 2. If Panicked, go to 3.


However, at NEITHER point does the game react to my calling the variable. The background constantly flashes between the two 'rooms', and all characters are visible at all times.
Why is the dialog script completely ignoring my variable?

Snarky

Does room_RepExec() run during a dialog? I'm not sure it does: I think dialogs are considered blocking events, and RepExec() doesn't run during blocking events.

If you change the function name to repeatedly_execute_always() (without changing anything else) it might work.

reismahnic

Seems like that setup will work. Thanks a ton Snarky.
And thanks ALL of you, this was all super helpful.

SMF spam blocked by CleanTalk