Jump to content

Timed Dialogue Script (Help would be appreciated)


gammons123

Recommended Posts

Hi,

 

I am attempting to create a script that will allow an NPC to start a sequence of timed conversation topics. Example: every 300 seconds the NPC will talk to the player, each time with a different topic.

 

I have made some progress but I think I am misunderstanding something basic/important. I will include the code I am working on below as I feel it will give a better indication of what I am trying to achieve.

 

 

SCN TimedDialogueScript

 

float Timer

int Counter

int CounterStarted ; 0 or 1 on or off

 

Begin Gamemode
If counter < 10 && CounterStarted == 1
If Timer < 300
set Timer to Timer + GetSecondsPassed
else
set Counter to Counter + 1
set Timer to 0 ; Normally included as a result end script in the appropriate dialogue topic
endif
endif
If Counter == 1
npcREF.StartConversation Player topic01
EndIf
If Counter == 2
npcREF.StartConversation Player topic02
EndIf
End

 

What happens when using the above code is that the NPC waits twice the length of the Timer and then says topic02. This seems to show that the Timer is incrementing Counter properly, so I'd guess the issue is with the other part. Joining the two final If statements with an ElseIf does not make any difference.

 

Hopefully I have made at least a little sense, and would be gratefully for some corrections or a nudge in the right direction.

 

Cheers in advance.

Edited by gammons123
Link to comment
Share on other sites

Well, straight away, I notice that you're missing an endif statement. You need to close every if with an endif. It ought to look like this:

   If counter < 10 && CounterStarted == 1
      If Timer <  300
         set Timer to Timer + GetSecondsPassed
      else
         set Counter to Counter + 1
         set Timer to 0
      endif
   endif
I'm surprised that you were able to save it, considering that the GECK usually won't let you save a script that has a missing endif statement or something similar.
Another thing I should point out, you don't seem to set CounterStarted to 1 anywhere, so your timer will never start.
Hopefully that'll clear things up for you! :)
Edited by Jojash
Link to comment
Share on other sites

Hi Jojash,

 

Thanks for your reply.

 

I typed this at work from memory based on what I was working on last night - the points you have mentioned are not present in the actual script. I will edit the post to add the missing "EndIf" you have pointed out.

 

As for setting CounterStarted to 1 - this is currently being set in a result script for a line of dialogue.

 

The timer seems to be successfully incrementing the value of Counter. The problem (as I see it) is that only one of the If statements with the npcREF.startConversation ever runs - it seems to ignore all of them except the one with the highest value of Counter as a requirement.

 

I hope I'm explaining this sufficiently...

 

Cheers.

Link to comment
Share on other sites

Nothing seems immediately wrong with your script, it makes sense to me, at least. What does "topic01" contain? The only reason that I can come up for that not running is if it were empty.

 

One way of checking yourself whether or not the condition is running is to include printc after if Counter == 2. This will print a message to the console if the condition runs successfully. Something like:

   if Counter == 2
      npcREF.StartConversation Player topic02
     printc "Counter = 2"
   EndIf

That will print "Counter = 2" to the console when the condition has run. If you see that message then the issue lies with the function, or more probably the topic itself. If not, then it is indeed the condition. Sorry I can't be more help, but honestly it looks fine to me.

Edited by Jojash
Link to comment
Share on other sites

Sorted! (I'm pretty sure).

 

Jojash, thanks for that printc command, it helped me work it out in no time.

 

If anyone is interested the correct script should go something like this:

SCN TimedDialogueScript
 
float Timer
int Counter    
int CounterStarted      ; 0 or 1 on or off
 
Begin Gamemode
 
   If Counter < 10 && CounterStarted == 1
      If Timer <  300
         Set Timer to Timer + GetSecondsPassed
      Else
         Set Counter to Counter + 1
         Set Timer to 0
            If Counter == 1
               npcREF.StartConversation Player topic01 
            ElseIf Counter == 2
               npcREF.StartConversation Player topic02
            EndIf
      EndIf
   EndIf
  
End

This will allow an NPC to initiate a series of conversation after a set period of time has passed between topics.

Edited by gammons123
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...