Condition - if player has been in room

Started by Candle, Tue 05/07/2005 06:39:24

Previous topic - Next topic

Candle

I want the NPC to go to a diff roon(room10) if the player has been in the room he is in(room3) .
But when I use it in the Settings > First time player enters room
Soon as he is done talking (NPC) he goes to the room even if it is the first time in the room ? ( it shoiws room 0 but it is room 3 I did that real quick)
I have .See screenshot

What would I be doing wrong ? Better way ?

Gilbert

#1
When the player enters a room, it's automatically set to be "visited", even if it's the first time, and before any interaction is executed. So, in general you shall not use "if player has been in room #" which is the same room of the current room (as it's always true this way).

You can however, do something like this (notice the indentings):
First time player enters screen
Ã,  Run script
Ã,  Conditional - If a variable is set to a certain value (beenroom, 1)
Ã,  Ã,  Character - Move NPC to different room (FRED, 10)
Ã,  Game -Set variable value (beenroom, 1)


(where beenroom is a room variable initialised as 0)
But I don't understand why you put this in "player enters room for the first time" event, since the code won't be run the second time he's in the room anyway, so the moving of the NPC will never be executed.

Candle

What would be the better place to put it then ?

Gilbert

Since I don't understand what you're actually going for, but at least, if it's supposed to be executed everytime the player enters the room, put it in "player enters room after fade in".

If what you want is, the "run script" part only executed the first time the player enters the room, but the moving of the NPC the second time player enters the room, you can try this:


First time player enters screen
Ã,  Run script

Player enters screen (after fadein)
Ã,  Conditional - If a variable is set to a certain value (beenroom, 1)
Ã,  Ã,  Character - Move NPC to different room (FRED, 10)
Ã,  Game -Set variable value (beenroom, 1)


(where beenroom is a room variable initialised as 0)

Candle

Well I have a room and a NPC is there and when you enter the room he gives a little talk and then you can click on a door and go to inside the room . so i want it the next time you go to the room if you have been there he is gone and you don't hear the little talk he gives .
i did the last one you gave but he goes poof when he is done talking .
http://img137.imageshack.us/img137/2125/222222228fm.png
look at the grab see if it is right . maybe it would be better to do this with code ?

Gilbert

Use the codes I posted in my last post, also:
First time player enters screen
  Run script

Player enters screen (after fadein)
  Conditional - If a variable is set to a certain value (beenroom, 1)
    Character - Move NPC to different room (FRED, 10)
  Game -Set variable value (beenroom, 1)

and check the indentions, the last "Game - ..." action is NOT part of "Conditional - If..."

Candle

Well I will keep working on it and see if I can get it to work right . thank you for the help .

monkey0506

You could try creating a static room variable initialized as -1:

Code: ags
// room editor
static int visits = -1;


Then increase it in the First Time Player Enters Room:

Run script:

Code: ags
visits++;


Then, you can test the value of it (add to First time player enters room run script action):

Code: ags
if (visits > 0) NewRoom(FRED, 10);


I'm not 100% sure that NewRoom is the appropriate function (and the right parameters), but I think that this would work.  Oh, and I don't know that you can use static variables in 2.62, so if you're using that then perhaps you could just use a global variable (?).

Then again, this may be completely wrong.  It is only 2 A.M....

Gilbert

Since it's initialized as -1, and the increment was done only for the first time, the variable will be forever 0 from now on (your logic will work if it's just in player enters sceen after fadein" though.
When using text script, I suggest:
On top of room, define:
int beeninroom=0;

In "player enters screen after fadein":
if (beeninroom) character[FRED].room=10;
beeninroom=1;

Note also that NewRoom() works only for the player character and it will result in room changing.
For V2.62 or earlier, you can just use above direct assignment teh variable or NewRoomNPC(FRED, 10).
For V2.7+ you can use also the following to move FRED:
cFred.ChangeRoom(10);

Candle

Well what I did is just sent him to a blank room I have and that seems to work ok.
So I have a hotspot on a door to go back to that room ( it is outside) but the objects that I have (door animated ) don't work like the first time you go to the room ?
I know it is hard for you to know what I'm doing with out seeing it .
Using 6.2 not going to the new one .

EDIT I did get it working now with a little work .
Thanks for the help :) Till next time

monkey0506

Well Gilbot, like I said, it's 2 a.m.

Edit:  Glad to hear you got it working though Candle.

Candle

Quote from: monkey_05_06 on Tue 05/07/2005 08:30:03
Well Gilbot, like I said, it's 2 a.m.

Edit: Glad to hear you got it working though Candle.
Yes thanks for the help . it is late .

SMF spam blocked by CleanTalk