Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Monsieur OUXX on Tue 18/12/2018 23:29:33

Title: [SOLVED] Character won't go away
Post by: Monsieur OUXX on Tue 18/12/2018 23:29:33
Once again a dumb issue that will be fixed in two seconds by someone.

- I have a room (room 6)  that is NOT the starting room of character cChar
- cChar is NOt the player character
- At some point, I do "player.ChangeRoom(6)" in order to go to that room.
- Just to be sure, in Room_Load of room 6, I do "cChar.ChangeRoom(7); Wait(1);" to force-remove cChar.

...And yet after the fade-in, cChar is here in room 6, in all his glory.
I can't make the damned character f**k off.

what am I missing?
Title: Re: Character won't go away
Post by: Crimson Wizard on Tue 18/12/2018 23:37:27
Hmm, since you tried in Room_Load and it still there after fade-in, that may mean either:
- Room_Load is not executed (not linked on events pane);
- It actually gets there after that again; this I cannot tell because I don't know under which conditions you move it there in the first place.
Title: Re: Character won't go away
Post by: Khris on Tue 18/12/2018 23:55:03
Make sure it's the character you think it is. Press Ctrl+D to see a list of characters.
Title: Re: Character won't go away
Post by: Monsieur OUXX on Wed 19/12/2018 00:01:07
I've double-checked, triple-checked both your suggestions.

When I press Ctrl+D it tells me that Player is in this room and I see that the view is the correct view cChar has another very recogniazable view).

In AfterFadeIn I executed this verification code :
Code (ags) Select

function room_AfterFadeIn()
{
    cChar.SayAt(0, 10,  150,  "It's me");
    cChar.ChangeRoom(7, 160, 100); //send him away
    Wait(1);
    //cChar.Walk(200,  50, eNoBlock); //This makes the game crash with the message "this character is NOT in this room"
    cChar.SayAt(0, 10,  150,  "It's still me");
   
    for (int i=0; i<Game.CharacterCount; i++) {
        if (character[i].Room == player.Room) {
            Display("Character %s is in this room", character[i].Name); //cChar still gets listed here
        }
    }


Now the really, REALLy odd thing is that the commented line makes the engine tell you that cChar is not in this room.
HOWEVER the loop underneath DOES display cChar as being in this room, additionally to the player character.

I'm super duper confused.
Title: Re: Character won't go away
Post by: Crimson Wizard on Wed 19/12/2018 00:04:35
Quote from: Monsieur OUXX on Wed 19/12/2018 00:01:07
HOWEVER the loop underneath DOES display cChar as being in this room, additionally to the player character.

Earlier you said this is room 6, but you are testing to room 13 in that loop? :/

To avoid confusion better test as:
Code (ags) Select
if (character[i].Room == player.Room)
Title: Re: Character won't go away
Post by: Monsieur OUXX on Wed 19/12/2018 00:10:09
Quote from: Crimson Wizard on Wed 19/12/2018 00:04:35
To avoid confusion better test as:
Code (ags) Select
if (character[i].Room == player.Room)

Haha you're too quick, I've edited my post instantly but you still picked it up. ;)
In my description it's room 6, in real life it's room 13.

Anyways I think I've found the issue. In room 6 I have some code that forcefully swaps the player character in case I'm in debug mode and I arrived there with the wrong character. I suspect that this code is mlessed up and brings in the unwanted character at the same time.

I'll keep looking. thanks, gentlemen (and ladies who might have been silently reading).
Title: Re: Character won't go away
Post by: Monsieur OUXX on Wed 19/12/2018 00:16:15
I just can't find it, it's driving me mad. May I send you guys a PM with the game sources?
Title: Re: Character won't go away
Post by: Khris on Wed 19/12/2018 09:23:58
Sure, send away.
Title: Re: Character won't go away
Post by: dayowlron on Wed 19/12/2018 17:13:47
Is SayAt a blocking command? could it be that the script is not proceeding to the change room until after the SayAt has completed?
Title: Re: Character won't go away
Post by: Monsieur OUXX on Wed 19/12/2018 19:46:14
Quote from: dayowlron on Wed 19/12/2018 17:13:47
Is SayAt a blocking command? could it be that the script is not proceeding to the change room until after the SayAt has completed?
Hmmm, could be. But even after the SayAt, the character stays. That motherspriter. OK Khris I'll zip it up and send you a PM. thanks a lot.
Title: Re: Character won't go away
Post by: Khris on Wed 19/12/2018 20:39:24
I assumed the character was actually visibly appearing in the room. Turns out they aren't :P

Character.Say() will always show the message, even if the character isn't actually present in the current room. My guess is that this was decided to allow narrator speech without having to make sure the narrator character is constantly moved to the current room.
Title: Re: Character won't go away
Post by: Crimson Wizard on Wed 19/12/2018 21:07:10
Quote from: Khris on Wed 19/12/2018 20:39:24
I assumed the character was actually visibly appearing in the room. Turns out they aren't :P

Erm what.... I assumed the same.

What about the loop displaying that character cChar is still in the current room?
Title: Re: Character won't go away
Post by: Khris on Wed 19/12/2018 21:24:23
The loop confirms that the stubborn character isn't in the room.
Doesn't matter if the ChangeRoom line is commented out or not; for me the loop never shows the motherspritin' character misbehaving, because they aren't in the room to begin with.
Title: Re: Character won't go away
Post by: ManicMatt on Thu 20/12/2018 20:16:03
Yeah, I like that feature. In my current game I have a character behind a locked door and I didn't need to hide him behind the door to have him say something and have his text appear in the right spot.
Title: Re: Character won't go away
Post by: Monsieur OUXX on Fri 21/12/2018 01:29:02
Quote from: Khris on Wed 19/12/2018 21:24:23
The loop confirms that the stubborn character isn't in the room.
Doesn't matter if the ChangeRoom line is commented out or not; for me the loop never shows the motherspritin' character misbehaving, because they aren't in the room to begin with.

OK but do you see the character dressed in city clothes appearing right in the middle of the room?
- If not, then I might have given bad directions to reproduce the issue.
- If yes, then I want this character to go away, no matter the reason. I don't understand why it appears there.

EDIT: I have indeed given you bad directions to reproduce the issue. I'll update with proper directions asap.
Title: Re: Character won't go away
Post by: Monsieur OUXX on Fri 21/12/2018 02:10:41
OK so the issue is resolved.

It was a real mess of confusing characters (because Character.Say works even if the character is not here), having the player character invisible, having custom code swapping characters (to be able to revert to previous character when chaging room) and more custom code changing the character's view automatically (to apply some sort of costume).

Long things short: I had no idead what character was where displayed with what view  (roll)

Thanks thanks thanks so much to people who tried to look into it.


Also, Khris, enjoy the sneak peek to this little game that should be released with two weeks ;)