Aller au contenu

Photo

Check if conversation exists


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
Zeke

Zeke
  • Members
  • 46 messages

So, yeah, I'll be quick. I'm trying to create a conversation system. Something like this:

string tag = GetTag(OBJECT_SELF);
string conv;

conv = "conv_" + tag;

How can I check if the generated conversation name exists?



#2
Proleric

Proleric
  • Members
  • 2 346 messages
There's no generic method in NWScript to test whether resources exist.

You can perform an offline check with, say, moneo, but I assume you mean in game?

The obvious method would be to check the proposed conversation name against a list of the valid conversation names (which you could create offline with moneo and then paste into the script, perhaps).

Otherwise, the best I can suggest is to test whether the conversation has actually started. For example, assuming it has more than one line, ActionStartConversation could be followed by an ActionDoCommand to test IsInConversation (or some local variable set by the first script in the conversation). If positive, the conversation exists. The converse is not necessarily true, as a conversation can fail in several ways.

If it's not acceptable for the player to enter a trial conversation, you could try starting a conversation between two NPCs in an area players don't visit, first boosting their AI level. I don't know whether that works.

#3
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

I am not sure if there is a good way to tell if a conversation file exists, Outside of making a list of them to check.  

 

I just really want to make sure you understand the limitations of the characters lengths for the for the tags vs. Convo file names(ResRef's)

 

Tags are limited to being 32 characters long.

ResRef's,  the convo name being a ResRef, Is limited to being 16 characters long.    

 

So if you use the system of taking the "conv_" + tag;  You will need to make sute that all of your tags are less then 11 characters long.   

 

 

   it is not that hard to make the list. assuming  that the list is just of the conversations in the module and not in biff's and haks.

 

If making a list sounds like something you want to do and you are going to have a long list,  It is not that hard to create a script with a batch file ran in the temp0 folder to generate the list for you.    The batch file would look something like this:

( a batch file is nothing more then a pure text file with a . bat extension) 

 

echo>"zztest.nss" void main()
echo>>"zztest.nss" { 
echo>>"zztest.nss"   string CONV_LIST;  
FOR  %%a IN (*.dlg) do echo>>"zztest.nss"   CONV_LIST+=" %%a ";
echo>>"zztest.nss" }


run the bat and it will give you a .nss (Neverwinter Source Script) that will look something like this. 

 

void main()
{ 
  string CONV_LIST;  
  CONV_LIST+=" acadameyportal.dlg ";
  CONV_LIST+=" academychef.dlg ";
  CONV_LIST+=" evpcpawnshop.dlg ";
  CONV_LIST+=" evpctigergate1.dlg ";
  CONV_LIST+=" evpctigergate2.dlg ";
  CONV_LIST+=" evpctrader.dlg ";
  CONV_LIST+=" eyecontesttalk.dlg ";
  CONV_LIST+=" fansenacamp.dlg ";
  CONV_LIST+=" finegoods.dlg ";
  CONV_LIST+=" fishing.dlg ";
  CONV_LIST+=" flameburst.dlg ";
  CONV_LIST+=" quest36.dlg ";
  CONV_LIST+=" quest37.dlg ";
  CONV_LIST+=" quest38.dlg ";
  CONV_LIST+=" quest4.dlg ";
  CONV_LIST+=" silverlakeweapon.dlg ";
  CONV_LIST+=" simplestore.dlg ";
  CONV_LIST+=" singingguard.dlg ";
  CONV_LIST+=" wondollyuglygirl.dlg ";
  CONV_LIST+=" woodworkershop.dlg ";
  CONV_LIST+=" xiongtalk.dlg ";
}

Compile the script and add it to your module OnLoad  event. or wherever you want to the do the population of the list from.  I would just make sure you only did it once.   

 

The you will be able to test to see if the conversation is in the list this way.

 

 

    string ConvList = GetLocalString (GetModule(),"CONV_LIST");
    string tag = GetTag(OBJECT_SELF);
    string conv = "conv_" + tag;


    if ( TestStringAgainstPattern( ConvList," "+conv+".dlg"))
    {
      // Do something.
    }    

  • Proleric aime ceci

#4
Zeke

Zeke
  • Members
  • 46 messages

Thank you for the answers. I'll see if the ActionDoCommand IsInConversation is working as it should. if not I will create a list. I didn't know about the TestStringAgainstPattern() function.