Author Topic: Conversation doesn't appear until the next day  (Read 361 times)

Legacy_Sierra Westhaven

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Conversation doesn't appear until the next day
« on: December 04, 2010, 08:54:51 pm »


               Hello. I am trying to make a conversation where the text node doesn't appear until the next day.

This is what I'm trying to accomplish:

The owner will say: Return to me tomorrow for our mission.
The PC says: Okay

The owner will repeat the above text until it is the next day. When it it the next day the owner will say:
Are you ready for the mission?

I'm guessing it might have something to do with the GetCalendarDay() function but I can't figure out how to increment it to the next day and apply it properly to the node. Or maybe there is a better function all together.

Any help would be greatly appreciated!
               
               

               
            

Legacy_eeriegeek

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +0/-0
Conversation doesn't appear until the next day
« Reply #1 on: December 04, 2010, 09:45:02 pm »


               I found that time is a little trickier to handle in NWN that I first expected. The calender will advance automatically (as long as the game is running.) You can see the current date the game thinks it is by mouseovering the compass in the lower right corner of the screen.

A simple solution is to do the following in your initial conversation action:

int nCurrent = GetCalandarYear() * 336 + GetCalendarMonth() * 28 + GetCalendarDay();
int nTimestamp = nCurrent + 1;
SetLocalInt(oPC,"MyQuestTimeout",nTimestamp);

Then, in the conversation conditional for the node you want to enable the next day:

// Need to make sure they have the quest first, then ...
int nCurrent = GetCalandarYear() * 336 + GetCalendarMonth() * 28 + GetCalendarDay();
int nTimestamp = GetLocalInt(oPC,"MyQuestTimeout");
return (nCurrent >= nTimestamp);

If your server is going to get restarted between those events, unfortunatly, you will have to find a method of maintaining persistance of the timeout variable and the game calendar. Also note that the above is for a game day, not a real day! (Hope there aren't too many typos in the above as I didnt get a chance to compile it.) One thing that might help others with better advice is: Are you making a single player module or a PW?
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Conversation doesn't appear until the next day
« Reply #2 on: December 04, 2010, 09:48:10 pm »


               GetCalendarDay() is exactly what you'll want to use.

In a conversation script (actions taken tab) for the 1st time the conversation runs, have it get the day and record it as a local variable on the module (or record it in the database if for a PW).  Then on your check for if it's the next day, have the new message display only if another check for the day returns a different day than the one stored (assuming the PC returns in less than 28 game days).

You could even add a third conversation node that says something like "I told you to come back tomorrow, Mr./Miss Impatient." if the PC returns before the next day.
               
               

               


                     Modifié par The Amethyst Dragon, 04 décembre 2010 - 09:48 .
                     
                  


            

Legacy_eeriegeek

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +0/-0
Conversation doesn't appear until the next day
« Reply #3 on: December 04, 2010, 09:50:03 pm »


               Heh heh, Hi AD, we must have been typing at the same time!
               
               

               
            

Legacy_Sierra Westhaven

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Conversation doesn't appear until the next day
« Reply #4 on: December 05, 2010, 02:33:39 pm »


               Thank you for the advice. I've tried both ideas but I'm still not able to get it to work. I must be coding something wrong.

On the "Return tomorrow" node(which I have listed 2nd in the conversation) I have the following script on Actions taken:

void main()
{
int nCurrentDay = GetCalendarDay();
}
-------------------------------

On the "Glad you could make it, are you ready for your mission?" node I have the following script on Text Appears:

int StartingConditional()
{
object oPC = GetPCSpeaker();
if (GetLocalInt(oPC, "nCurrentDay") <= 1) return TRUE;
return FALSE;
}

--------------------------------------
When I test it out the conversation always starts with "Glad you could make it". I don't want that to appear until the following day.
I was also trying to use <= nCurrentDay+1 but the script fails on that.

Does anyone know where my script is going wrong? Thanks!
               
               

               
            

Legacy__Knightmare_

  • Full Member
  • ***
  • Posts: 191
  • Karma: +0/-0
Conversation doesn't appear until the next day
« Reply #5 on: December 05, 2010, 02:58:44 pm »


               

Sierra Westhaven wrote...

Does anyone know where my script is going wrong? Thanks!


In your first script, you are simply getting the calendar day, but not saving that on anything. Therefore, when you check the calendar day in the second script, nCurrentDay == 0. Since you have it set to "if nCurrentDay is less than or equal to 1 show the convo line", it will always appear (again since nCurrentDay == 0, ie. less than 1).

For the first script, try something like this:

void main()
{
object oPC = GetPCSpeaker();
int nPCDay = GetCalendarDay();
SetLocalInt(oPC, "CurrentDay", nPCDay);
}

In the second script:

int StartingConditional()
{
object oPC = GetPCSpeaker();
int nCurrentDay = GetCalendarDay();
int nPCDay = GetLocalInt(oPC, "CurrentDay");
if(nCurrentDay == nPCDay +1) return TRUE;
return FALSE;
}

The potential problem here though is that what happens if the first day is the last day of the month, and the second day is the first day of the month? If that happens, then the second day will not == nPCDay + 1. Hope you can understand what I mean by that. So you need to change the "return TRUE" line in the second script to account for that possibility.
               
               

               


                     Modifié par _Knightmare_, 05 décembre 2010 - 02:59 .
                     
                  


            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Conversation doesn't appear until the next day
« Reply #6 on: December 05, 2010, 03:04:21 pm »


               I'm going to assume 3 possible nodes for this, single player module:

"return to me tomorrow"
"it is not tomorrow yet"
"Glad you could make it, are you ready for your mission?" (3rd option, default if other ones don't apply)

1st node Text Appears When... script:

// "return to me tomorrow" (text appears)
int StartingConditional()
{
    int nReturn = FALSE;

    if (GetLocalInt(OBJECT_SELF, "storedday") < 1)
       {
       SetLocalInt(OBJECT_SELF, "storedday", GetCalendarDay());
       nReturn = TRUE;
       }
    return nReturn;
}

2nd node Text Appears When... script:

// "it is not tomorrow yet" (text appears)
int StartingConditional()
{
    int nReturn = FALSE;
    int nStoredDay = GetLocalInt(OBJECT_SELF, "storedday");
    if (nStoredDay >= 1 && nStoredDay == GetCalendarDay())
       {
       nReturn = TRUE;
       }
    return nReturn;
}

3rd node, no Text Appears When... script needed.


Hopefully these will work out for you.
               
               

               
            

Legacy_Sierra Westhaven

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Conversation doesn't appear until the next day
« Reply #7 on: December 05, 2010, 10:14:05 pm »


               Thanks for the quick replies. This is exactly what I need. You guys are awesome!
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Conversation doesn't appear until the next day
« Reply #8 on: December 06, 2010, 12:27:26 am »


               If she just wants the Node to appear the Next day.  whay not just make sure it is not the same day.  



If( nStoredDay != GetCalendarDay())



Or  if you want to make sure it is not just after midnight.



If( ( nStoredDay != GetCalendarDay()) && (GetTimeHour() >6) )