Dialog and object question

Started by BIG IR0N NUTZ, Tue 13/07/2010 22:27:04

Previous topic - Next topic

BIG IR0N NUTZ

Hi

I can't figure out a way to do this.  I want an object in my first room not to be visible until my PC talks to an NPC in the third room.  I have a dialog set to play when you talk to the NPC in the third room.  Help is needed!

Dualnames

just find the id number of the object and on the
Code: ags

@S //of the dialog do that:

 if (Game.DoOnceOnly("open cupboard")) {// search the manual here for more info on the DoOnceOnly command http://www.adventuregamestudio.co.uk/manual/Game.DoOnceOnly.htm
 object[idgoeshere].Visible=true;
 }


You have to INDENT THE LINES SO THEY CAN WORK.
INDENT=PUT A SPACE IN FRONT OF THEM
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

geork

#2
  This is very crude, but what you could do is have a bool global variable which is "true" once the player has the conversation, then have a statement checking whether this variable is true in the Room_Load of the first room, and if so set the object to be visible, maybe something like:
Code: ags

  //when player talks to NPC
  GlobalVariable = true //make up your own name for the global variable
  diaolg.start()
  //then later on in room 1
  Room_Load(){
    if(GlobalVariable == true){
       object.Visible = true;
     }
}
  


 As I said, could be done better but there is a crude way of doing it

   EDIT: Looks like a better solution got there first from Dualnames ;)

Dualnames

Forgot to say that you have to turn the object off initially (I thought it is obvious). Either on the editor or on the room's load script.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Ryan Timothy B

#4
Dualnames' code wouldn't work since DrizelMaNizel (what a name) wants the object in Room 1 to become visible once the player talks to the NPC in Room 3.


I would use a global bool.  You set it up in the global variable manager, which you can see on the side bar in the editor.  Its default value will be false.  
Pretend you named it: crazyThingVisible

So when you're in the dialog, you do something like this (note the spacing in front of the in dialog scripting - it only works with the spacing):
Code: ags

@S  // Dialog startup entry point
man: I just saw some crazy thing over there.
  crazyThingVisible = true;
return


Then when you're in the room script, you do this in the room load function.  Which in case you didn't know, you have to create it in the room editor first, you can't just copy this:
Code: ags

function room_Load()
{  
  crazyObject.Visible = crazyThingVisible;
}

Since the bool is either true or false, setting the object's visibility with one works.

Basically what Geork has posted, but I felt it was missing that little extra description to help out Drizel.

BIG IR0N NUTZ

#5
Thanks for all the help guys!  ;D I figured out how to do it on my own lol please tell me if there would be a flaw later in my game with the code i figured out.
Code:

function room_AfterFadeIn()
{
   if (cEgo2.Room == 4)
   {
      oObject.Visible = true;
   }
}


In the game after the dialog is said between cEgo and cEgo2 (cEgo2 is the NPC), cEgo2 goes from room 3 to 4.  cEgo2 also wants you (cEgo) to go back to room 1 to get the object.  That is why I have it say cEgo2.Room == 4.  Will this flaw later in game? and how?

Khris

This will work fine as long as cEgo2 is going to stay in room 4 after the dialog until the end of the game.

However, one of the most common mistakes concerning game logic is assuming that the player knows what to do / doesn't do stuff that doesn't make sense.
E.g. say there's a chest containing an item, and interacting with the chest is supposed to add the item to the inventory. Thus the nearby thing is to check if said item is already carried by the player and if it isn't, add it; if it is, tell the player that the chest is empty.
But, obviously this will only work as long as the item isn't going to leave the inventory for the rest of the game.
If, on the other hand, the player can loose the item, the chest will 'magically' contain it again.

To be on the safe side, always consider the player as a mindless drone that'll try any and everything. Getting rid of loose ends immediately will save you a lot of headaches and bug reports.

BIG IR0N NUTZ

Haha alright welp in my game I will later have cEgo2 follow cEgo around, so I guess I will have to rescript, but hey, it is better to do it now than later in the game's production!

Ryan Timothy B

Also, another little hint.  You shouldn't put object visibility in the room_AfterFadeIn.  If you have have a room transition (ie: fade), the object will appear after the transition.  You'd see a sudden flash of the object appearing.

You should always put stuff like that in Room_Load, which occurs before the fade.  AfterFadeIn should be used for cutscenes and blocking events that occur when you enter.

Dualnames

When the question isn't really clarified, I can't guess what could be the answer.


With what I gave you:
1)It's probable that you can start that dialog on another room
2)It's probable its a generic dialog and you can start it with a different NPC
3)It's probable that you also have some other condition for that object to be visible
4)It's possible that you also have a code that turns visibility off to that object and therefore need to turn it on EVERY TIME on the dialog
5)It's possible that you want once the object is on, never to turn it off again.

If even one of those sentences is true, my code won't work.



DMN, your code will be faulty. Since you want that object to be picked up, I assume you'll turn it off again.
Therefore.

Code: ags

function room_Load(){
   if ((cEgo2.Room == 4)   && (Game.DoOnceOnly("chore"))) {//It means that once the dialog is run, and only once to prevent what i said, the object will regain its visibility.
     oObject.Visible = true;
   }
}
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

BIG IR0N NUTZ

thanks for all the help everyone! 

SMF spam blocked by CleanTalk