messagebox dialogue?

Post » Tue Jan 12, 2010 12:54 am

While playing the underground 2 mod, i found that qarl used dialogue through message boxes when two npcs needed to talk to each other. Can anyone explain how this is done, and if so, how i could use it myself.? Because i need a short cutscene between two npcs and don't want it to be through one of their dialogue boxes, because that would stink. Any help appreciated, thanks!
User avatar
Stephani Silva
 
Posts: 3372
Joined: Wed Jan 17, 2007 10:11 pm

Post » Tue Jan 12, 2010 5:07 am

you could write a script that has the dialog in http://www.uesp.net/wiki/Tes3Mod:MessageBox the difficult part would be timing it all so that the messageboxes go slow enough for most folks to read.

i'm guessing you'd want to trigger this conversation through journal entries?

here's how i'd do it

begin sampledialogscriptshort timershort stateif ( menumode == 1 )        returnendifif ( getjournalindex, "samplejournal" == 10 )        if ( getpccell == "cell name of cell where NPCs are" == 1 )                if ( player->getdistance "one of the NPCs actor id" == 100 )                       if ( state == 0 )                                messagebox "first part of conversation"                               set state to 10                               set timer to getsecondspassed                       endif                 endif        endifendifif ( state == 10 )        if ( timer <= ( getsecondspassed + 5 )                set state to 15                set timer to getsecondspassed                messagebox "second part of conversation"        endifelseif ( state == 15 )        if ( timer <= ( getsecondspassed + 5 )                set state to 20                set timer to getsecondspassed                messagebox "third part of convo"        endifelseif ( state == 20 )        if ( timer <= ( getsecondspassed + 5 )                set state to 25                set timer to getsecondspassed                messagebox "fourth part of convo"        endifendifend


and so on. this is untested code, it prolly wants some tweaking.
User avatar
sarah
 
Posts: 3430
Joined: Wed Jul 05, 2006 1:53 pm

Post » Mon Jan 11, 2010 7:05 pm

This will almost never be true. You should never use == with flots.
                if ( player->getdistance "one of the NPCs actor id" == 100 )


And this doesn't do what you think it does.
       if ( timer <= ( getsecondspassed + 5 )



And with your script, after 5s it would never get beyond the fist dialog as timer will never go above 0. getSecondsPassed returns the number of seconds passed in this frame. If you want to count time, then you need to increment timer. The timer also needs to be a float (because for most frames, the time pass will be < 1 )


My attempt assuming a conversation every 5 seconds:
float currentTimefloat lastTimeshort stateshort start; some method of starting here;checks if the conversation has been startedif ( start == 0 )    returnendif;block that only allows entry every 5 secondsset currentTime to currentTime + getSecondsPassedif ( currentTime < lastTime + 5 )    returnendifset lastTime to currentTimeset state to state + 1;the dialogif ( state == 1 )    messagebox "This"elseif ( state == 2 )    messagebox "that"endif

User avatar
Chloe Botham
 
Posts: 3537
Joined: Wed Aug 30, 2006 12:11 am

Post » Tue Jan 12, 2010 1:33 am

you could write a script that has the dialog in http://www.uesp.net/wiki/Tes3Mod:MessageBox the difficult part would be timing it all so that the messageboxes go slow enough for most folks to read.

i'm guessing you'd want to trigger this conversation through journal entries?

here's how i'd do it

begin sampledialogscriptshort timershort stateif ( menumode == 1 )        returnendifif ( getjournalindex, "samplejournal" == 10 )        if ( getpccell == "cell name of cell where NPCs are" == 1 )                if ( player->getdistance "one of the NPCs actor id" == 100 )                       if ( state == 0 )                                messagebox "first part of conversation"                               set state to 10                               set timer to getsecondspassed                       endif                 endif        endifendifif ( state == 10 )        if ( timer <= ( getsecondspassed + 5 )                set state to 15                set timer to getsecondspassed                messagebox "second part of conversation"        endifelseif ( state == 15 )        if ( timer <= ( getsecondspassed + 5 )                set state to 20                set timer to getsecondspassed                messagebox "third part of convo"        endifelseif ( state == 20 )        if ( timer <= ( getsecondspassed + 5 )                set state to 25                set timer to getsecondspassed                messagebox "fourth part of convo"        endifendifend


and so on. this is untested code, it prolly wants some tweaking.



This will almost never be true. You should never use == with flots.
                if ( player->getdistance "one of the NPCs actor id" == 100 )


And this doesn't do what you think it does.
       if ( timer <= ( getsecondspassed + 5 )



And with your script, after 5s it would never get beyond the fist dialog as timer will never go above 0. getSecondsPassed returns the number of seconds passed in this frame. If you want to count time, then you need to increment timer. The timer also needs to be a float (because for most frames, the time pass will be < 1 )


My attempt assuming a conversation every 5 seconds:
float currentTimefloat lastTimeshort stateshort start; some method of starting here;checks if the conversation has been startedif ( start == 0 )    returnendif;block that only allows entry every 5 secondsset currentTime to currentTime + getSecondsPassedif ( currentTime < lastTime + 5 )    returnendifset lastTime to currentTimeset state to state + 1;the dialogif ( state == 1 )    messagebox "This"elseif ( state == 2 )    messagebox "that"endif




To both of you, i greatly appreciate the scripts. But i'm confused now, i thought of using rakninja's then yacoby said it wouldn't work, and replaced it with his own script. However, on your/s yacoby, it seems to only allow for 2 message boxes? I'm not a scripter by any means so i don't know, but i need it to work in the fashion rakninja had, where one message box would appear after the other, going on for as many as need be. If this is possible with the script you supplied, could you please show me how? And to rakninja, thanks very much for it! you've helped me alot with my npc and dialogue problems, i really appreciate it!
User avatar
Andrew Perry
 
Posts: 3505
Joined: Sat Jul 07, 2007 5:40 am

Post » Mon Jan 11, 2010 8:57 pm

To both of you, i greatly appreciate the scripts. But i'm confused now, i thought of using rakninja's then yacoby said it wouldn't work

It would work with a couple of fixes. Mine is just an alternative method of doing it and is slightly different which is why I added it. (It is simpler but less flexible in some respects).

(I am not saying mine works either)

However, on your/s yacoby, it seems to only allow for 2 message boxes? I'm not a scripter by any means so i don't know, but i need it to work in the fashion rakninja had, where one message box would appear after the other, going on for as many as need be. If this is possible with the script you supplied, could you please show me how?

In the end section with the message boxes (if my script works, I am not saying it does) the variable state increases by 1 every 5 seconds. If you want to add more you could just add a check for if ( state == 3 ) etc.

You could also tweak the constants for some more fine tuning (so that state would increase every 1 second, thereby allowing you to chose more variation in the time between messageboxes depending on the messagebox)
User avatar
Sxc-Mary
 
Posts: 3536
Joined: Wed Aug 23, 2006 12:53 pm

Post » Mon Jan 11, 2010 7:18 pm

It would work with a couple of fixes. Mine is just an alternative method of doing it and is slightly different which is why I added it. (It is simpler but less flexible in some respects).

(I am not saying mine works either)


In the end section with the message boxes (if my script works, I am not saying it does) the variable state increases by 1 every 5 seconds. If you want to add more you could just add a check for if ( state == 3 ) etc.

You could also tweak the constants for some more fine tuning (so that state would increase every 1 second, thereby allowing you to chose more variation in the time between messageboxes depending on the messagebox)

So if this would work if i wanted to use say.. 4 boxes? and after the 4th box it would just quit?
begin messageboxscriptfloat currentTimefloat lastTimeshort stateshort start; some method of starting here;checks if the conversation has been startedif ( start == 0 )    returnendif;block that only allows entry every 5 secondsset currentTime to currentTime + getSecondsPassedif ( currentTime < lastTime + 5 )    returnendifset lastTime to currentTimeset state to state + 1;the dialogif ( state == 1 )    messagebox "This"elseif ( state == 2 )    messagebox "that"elseif ( state == 3 )    messagebox "dog"elseif ( state == 4 )    messagebox "tiger"endifend

If this is right, is there anything else i need to add before putting into the cs? I'm horrible at scripting incase i haven't said so yet haha :/
User avatar
Harry Hearing
 
Posts: 3366
Joined: Sun Jul 22, 2007 6:19 am

Post » Tue Jan 12, 2010 2:21 am

you'll need to include some method of starting the script such as the check in my script to see if your journal index is correct, you are in the right cell, and close enough to the NPC (thanks for catching the ==, i was half alseep when i wrote that script, i know better than to check a float for ==, silly me)

yacoby's timer is much better than mine. i dont often use timers that go off of real time rather than frame increments.

so basically, you just need to take yacoby's script, plug in your messages, and where the script has
;some method of starting here


remove that and plug in
if ( getjournalindex, "samplejournal" == 10 )        if ( getpccell == "cell name of cell where NPCs are" == 1 )                if ( player->getdistance "one of the NPCs actor id" <= 100 )                       if ( start == 0 )                                 set start to 1                       endif                endif        endifendif


replacing "samplejournal", the index used (10 in my script) "name of cell where NPCs are" and "one of the NPC's actor id" with the relevant data for your mod.
User avatar
Suzy Santana
 
Posts: 3572
Joined: Fri Aug 10, 2007 12:02 am

Post » Mon Jan 11, 2010 10:48 pm

you'll need to include some method of starting the script such as the check in my script to see if your journal index is correct, you are in the right cell, and close enough to the NPC (thanks for catching the ==, i was half alseep when i wrote that script, i know better than to check a float for ==, silly me)

yacoby's timer is much better than mine. i dont often use timers that go off of real time rather than frame increments.

so basically, you just need to take yacoby's script, plug in your messages, and where the script has
;some method of starting here


remove that and plug in
if ( getjournalindex, "samplejournal" == 10 )        if ( getpccell == "cell name of cell where NPCs are" == 1 )                if ( player->getdistance "one of the NPCs actor id" <= 100 )                       if ( start == 0 )                                 set start to 1                       endif                endif        endifendif


replacing "samplejournal", the index used (10 in my script) "name of cell where NPCs are" and "one of the NPC's actor id" with the relevant data for your mod.


So this should work?

begin messageboxscriptfloat currentTimefloat lastTimeshort stateshort startif ( getjournalindex, "samplejournal" == 10 )        if ( getpccell == "cell name of cell where NPCs are" == 1 )                if ( player->getdistance "one of the NPCs actor id" <= 100 )                       if ( start == 0 )                                 set start to 1                       endif                endif        endifendif;checks if the conversation has been startedif ( start == 0 )    returnendif;block that only allows entry every 5 secondsset currentTime to currentTime + getSecondsPassedif ( currentTime < lastTime + 5 )    returnendifset lastTime to currentTimeset state to state + 1;the dialogif ( state == 1 )    messagebox "This"elseif ( state == 2 )    messagebox "that"elseif ( state == 3 )    messagebox "dog"elseif ( state == 4 )    messagebox "tiger"endifend

User avatar
Bird
 
Posts: 3492
Joined: Fri Nov 30, 2007 12:45 am

Post » Mon Jan 11, 2010 2:24 pm

if, and only if this dialof is dependant on the journal "sample journal" being at index 10, in a cell called "Name of NPC's cell here", 100 game units or less from an NPC named "one of the NPCs actor id"

and even then only if you wanted to have messageboxes that displayed "this" "that" "dog" and "tiger"

update those to the names that you are using in your mod, and it should work. if not, just bring it back, we'll see if we cant patch it up.
User avatar
Natalie Taylor
 
Posts: 3301
Joined: Mon Sep 11, 2006 7:54 pm

Post » Mon Jan 11, 2010 3:12 pm

Also, this line

        if ( getpccell == "cell name of cell where NPCs are" == 1 )
should probaby be

        if ( getpccell "cell name of cell where NPCs are" == 1 )

User avatar
Scotties Hottie
 
Posts: 3406
Joined: Thu Jun 08, 2006 1:40 am

Post » Mon Jan 11, 2010 2:17 pm

if, and only if this dialof is dependant on the journal "sample journal" being at index 10, in a cell called "Name of NPC's cell here", 100 game units or less from an NPC named "one of the NPCs actor id"

and even then only if you wanted to have messageboxes that displayed "this" "that" "dog" and "tiger"

update those to the names that you are using in your mod, and it should work. if not, just bring it back, we'll see if we cant patch it up.

Alright so this is the script i have right now:
begin mc_messageboxscriptfloat currentTimefloat lastTimeshort stateshort startif ( getjournalindex, "mc_tilani" == 260 )        if ( getpccell "Don Macificio's Drug Estate, Don's Quarters" == 1 )                if ( player->getdistance "01mcdonmacificio" <= 200 )                       if ( start == 0 )                                 set start to 1                       endif                endif        endifendif;checks if the conversation has been startedif ( start == 0 )    returnendif;block that only allows entry every 5 secondsset currentTime to currentTime + getSecondsPassedif ( currentTime < lastTime + 5 )    returnendifset lastTime to currentTimeset state to state + 1;the dialogif ( state == 1 )    messagebox "This"elseif ( state == 2 )    messagebox "that"elseif ( state == 3 )    messagebox "dog"elseif ( state == 4 )    messagebox "tiger"endifend


BUT, and i know this is gunna be as silly as it can be, but how do i start it? Should i put a startscript command in the results box? or should i attatch it to a ring on the floor or something? Again thanks so much!
User avatar
Philip Lyon
 
Posts: 3297
Joined: Tue Aug 14, 2007 6:08 am

Post » Tue Jan 12, 2010 1:42 am

Both methods are workable, it all depends on how you want it to be. Ring-on-the floor is preferable for a script that only has to run in a certain cell so that it wouldn't take processor's resources when it's not necessary. (though you better place it somewhere *under* the floor so that the player wouldn't pick it up by mistake)
User avatar
Michael Russ
 
Posts: 3380
Joined: Thu Jul 05, 2007 3:33 am

Post » Mon Jan 11, 2010 9:52 pm

Both methods are workable, it all depends on how you want it to be. Ring-on-the floor is preferable for a script that only has to run in a certain cell so that it wouldn't take processor's resources when it's not necessary. (though you better place it somewhere *under* the floor so that the player wouldn't pick it up by mistake)

Well i would definatly prefer a method that would only runs in a certain cell, but i'm not sure how to go about equiping the script for such a thing
User avatar
Sammie LM
 
Posts: 3424
Joined: Thu Nov 30, 2006 1:59 pm

Post » Mon Jan 11, 2010 4:50 pm

the code arms itself. place it on one of the NPCs that'll be doing the "talking".

or make a copy of the sound emitter object and attach the script to that.

this kind of script is best kept local. if you ran it globally, you'd likely have undesired behavior, such as new messageboxes continuing to be created after the player leaves the area of the conversation.

a local script in an interior cell should not have this kind of problem.
User avatar
Red Bevinz
 
Posts: 3318
Joined: Thu Sep 20, 2007 7:25 am

Post » Mon Jan 11, 2010 4:18 pm

the code arms itself. place it on one of the NPCs that'll be doing the "talking".

or make a copy of the sound emitter object and attach the script to that.

this kind of script is best kept local. if you ran it globally, you'd likely have undesired behavior, such as new messageboxes continuing to be created after the player leaves the area of the conversation.

a local script in an interior cell should not have this kind of problem.

I placed it on the npc, and it started when it should have, and everything works fine, excepttt.... when the messagebox pops up, there are two of them, not just one. So it shows doubles of every box. Any idea what happened?
User avatar
Add Me
 
Posts: 3486
Joined: Thu Jul 05, 2007 8:21 am

Post » Mon Jan 11, 2010 5:43 pm

in the messagebox section, change it so that

if state == 1        messagebox"1"elseif state == 2        messagebox "2"...


becomes :

if ( state == 1 )        messagebox "1"        set state to 2elseif ( state == 3 )        messagebox "2"        set state to 4elseif ( state == 4)        ...


it seems that state is getting twice a frame. doing this will prevent that, but double the time it takes to display the next message, so adjust the timer as needed.
User avatar
Jade
 
Posts: 3520
Joined: Mon Jul 10, 2006 6:42 am

Post » Tue Jan 12, 2010 2:45 am

in the messagebox section, change it so that

if state == 1        messagebox"1"elseif state == 2        messagebox "2"...


becomes :

if ( state == 1 )        messagebox "1"        set state to 2elseif ( state == 3 )        messagebox "2"        set state to 4elseif ( state == 4)        ...


it seems that state is getting twice a frame. doing this will prevent that, but double the time it takes to display the next message, so adjust the timer as needed.

So this is my script now:
begin mc_messageboxscriptfloat currentTimefloat lastTimeshort stateshort startif ( getjournalindex, "mc_tilani" == 260 )        if ( getpccell "Don Macificio's Drug Estate, Don's Quarters" == 1 )                if ( player->getdistance "01mcdonmacificio" <= 200 )                       if ( start == 0 )                                 set start to 1                       endif                endif        endifendif;checks if the conversation has been startedif ( start == 0 )    returnendif;block that only allows entry every 5 secondsset currentTime to currentTime + getSecondsPassedif ( currentTime < lastTime + 2 )    returnendifset lastTime to currentTimeset state to state + 1;the dialogif ( state == 1 )    messagebox "Don: Hello Tilani, I haven't spoken to you in forever!"    set state to 2elseif ( state == 2 )    messagebox "Tilani: I know, it has been so long!"    set state to 3elseif ( state == 3 )    messagebox "Don: So, what can I help you with?"    set state to 4elseif ( state == 4 )    messagebox "Tilani: I want you to help us expand my Cartel!"    set state to 5elseif ( state == 5 )    messagebox "Don: Very well, let me speak to this friend of yours!"    journal "mc_tilani" 260    01mcdonmacificio->forcegreetingendifend


Now it only plays the first and fifth messageboxes, and they are still doubles :/
User avatar
Anna S
 
Posts: 3408
Joined: Thu Apr 19, 2007 2:13 am

Post » Tue Jan 12, 2010 12:10 am

Don't try and increase the state in the if statements with messageboxes in. It won't work as it will just increase it twice. Increasing the state variable is already handled by
set state to state + 1


Are you 100% sure you only have once instance of the script running? You haven't added it to two objects or put two objects that the script has added down in the cell?

The way to tell would be to enter this in the console in a totally different cell:
startscript mc_messageboxscriptset mc_messageboxscript.start to 1


If you get single messageboxes, you then the problem is not with the script.
User avatar
danni Marchant
 
Posts: 3420
Joined: Sat Oct 07, 2006 2:32 am

Post » Mon Jan 11, 2010 3:42 pm

ah, why it didnt work is you didnt change the state checks. first check for 1, then check for 3, then check for 5 and so on.

the reason why it should work is immediately after each messagebox, the state increases to a blank state. the script then has to wait on the timer to advance to a state that will output a messagebox.

do as yacoby suggested first, check for a second instance of the script running.
User avatar
Joe Bonney
 
Posts: 3466
Joined: Tue Jul 17, 2007 12:00 pm

Post » Mon Jan 11, 2010 3:23 pm

Don't try and increase the state in the if statements with messageboxes in. It won't work as it will just increase it twice. Increasing the state variable is already handled by
set state to state + 1


Are you 100% sure you only have once instance of the script running? You haven't added it to two objects or put two objects that the script has added down in the cell?

The way to tell would be to enter this in the console in a totally different cell:
startscript mc_messageboxscriptset mc_messageboxscript.start to 1


If you get single messageboxes, you then the problem is not with the script.



ah, why it didnt work is you didnt change the state checks. first check for 1, then check for 3, then check for 5 and so on.

the reason why it should work is immediately after each messagebox, the state increases to a blank state. the script then has to wait on the timer to advance to a state that will output a messagebox.

do as yacoby suggested first, check for a second instance of the script running.

I feel so dumb, it was simply that I had the script on both the npc, and on an activator in the cell. Thanks for the tip, i never would have realised that!
User avatar
aisha jamil
 
Posts: 3436
Joined: Sun Jul 02, 2006 11:54 am


Return to III - Morrowind