Problems with character.ChangeRoom when character is elsewhere in the game

Started by Lewis, Thu 22/11/2012 20:10:46

Previous topic - Next topic

Lewis

I know, I know, I'm posting a ridiculous number of questions at the moment. (I've taken a week off work to try to make loads of progress with my game, and it seems I'm just running into problem after problem that I can't find a solution for.)

I'm having a bizarre issue with non-player characters changing rooms. Specifically, the issue seems to be with changing the rooms of characters who are not in the same room as the player at the time.

So, for example, if I leave cCharacter2 in Room 1, then later enter Room 3, I want cCharacter2 to be in Room 3 when I arrive.

I've tried calling cCharacter2.ChangeRoom(3) upon leaving Room 1, upon entering Room 3, and at various random points in between, but for some reason the character is just not changing rooms. I've been bashing my head against a hundred walls all afternoon with this, and I'm at the stage now where if I try any more workarounds I'm just going to screw up a whole load of other things in the game. It's starting to really stress me out.

I think this is the issue, anyway. The weird thing is that if I start the game from a certain later point, things seem to work more or less normally - the issue only seems to crop up if I play the game from the start. So I'm not sure if there's some earlier code that's messing things up, which makes having someone else look at the code a difficult thing.

Any pointers hugely appreciated. I'm tearing my hair out here, and it's probably something super-obvious.
Returning to AGS after a hiatus. Co-director of Richard & Alice and The Charnel House Trilogy.

geork

I dunno is this'll help: try setting the co-ordinates you want cCharacter2 to go, so:
Code: AGS
cCharacter2.ChangeRoom(3,200,200)

it ay be that he HAS changed room, but sits in an awkward place...

this is a very hasty reply, so it's probably not the issue - my apologies if I am wasting time

Volcan

I'm not sure about your question. I'd use variables for this:

Code: AGS
if (Story==3)
{
 cCharacter2.ChangeRoom(3,160,100);
}

Khris

If you run the game in debug mode, you can press CTRL-D to get info about characters inside the current room (coords, view, etc.)

The place to move NPCs around is definitely the before fadein event; maybe it's a bit silly to ask this but are you sure that it's actually room 3 you're entering? You can always use cNPC.ChangeRoom(player.Room); to stay independent of AGS's numbering of the rooms.

Also double-check if the character might get moved off-screen, that their view contains sprites and that they aren't transparent or behind a walk-behind or object; and of course make sure that the function is actually called: if a Display("x happens"); is inconvenient for the event, you can always play a short sound instead.

I know that this isn't helping but your problem is almost certainly a user error, not an engine bug.

You don't need workarounds to put a character in a room, and if you try those and it screws up a whole load of other things, as you say, it really makes me wonder what else is going on.

SMF spam blocked by CleanTalk