Author Topic: Conversation: 1st conversations action fail  (Read 420 times)

Legacy_AmbrosiaPW

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
Conversation: 1st conversations action fail
« on: April 25, 2011, 07:01:20 pm »


               Hello, I am still pretty new to scripting for NWN. I'm working on a script based quest system for UOAbigails Ambrosia mod. I actually finished it successfully but there is one weird behavior I don't understand.

These are delivery quests. The NPC's all have pre-existing conversations so I am adding my quest convo to these. This has to do with the NPC that accepts the delivered package.

Conversation:

1. A Package for me? Thank you!  (Txt appears when: package_check_script. Action Taken: package_received_script)
2. (Original convo's) Welcome to the shop. How can I help you?

For this set up, when I walk up to the NPC the conversation window doesn't open, instead they show the text in my "Action Taken" script, but the script doesn't completely work. I get text, it calculates the reward and does the goodbye message but doesnt destroy the package.


Conversation:
1. 
(Original convo's) Welcome to the shop. How can I help you?
a. I have a package for you. 
(Txt appears when: package_check_script. Action Taken: package_received_script)

b. Would you like to purchase any of my wares?
c. Goodbye

But when I put the same scripts nested in the conversation like this, as a replay to the NPC the script works. Is there some hidden behavior here I should know about? Thank you. If you like I can post the scripts, but as I said, they work as they should when the convo is nested.

Thank you!':wizard:'
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
Conversation: 1st conversations action fail
« Reply #1 on: April 25, 2011, 09:10:41 pm »


               Conversations work logicaly:

so think about what will be there all the time, and what will appear when a variable is true

npc says "welocome"
pc says a, varialble
pc says b
pc says c

a should only come up if true, that is how it works.

you can also make the NPC do it but you need to have two npc starts

npc "welcome"
pc b,c
npc " oh you have a package"
pc a "why yes here.."
pc b,c

the key is logic what happens when var false what happens when var true.  Generaly most use the first meathod and have the PC text appear when true.

so to insure the npc canversation comes up you need more then just the NPC text you need what the NPC saya and what the PC replies.  Other wise its treated as a message and not a conversation.

I hope I helped I'm a bit groggy, if you need PM me and I can send you a conversation script better describing what I said.
               
               

               
            

Legacy_AmbrosiaPW

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
Conversation: 1st conversations action fail
« Reply #2 on: April 25, 2011, 10:11:05 pm »


               Hey thanks for your help. So my issue here is there is no pc conversation in the actual conversation editor thing. I have the pc reply in the script.

Npc:"That my package?" txt only if check is TRUE; do Action"receive package"
Npc:"Get out of my shop!" txt only if bad faction
Npc:"Hello would you like to see my wares?" txt only if decent faction
pc:yes
pc:no
NPC:"So nice to see you again!" txt only if good faction.
pc:yes
pc:no

I just don't understand why it does most of the script but jumps over destroying the tool.

Here is my actual code. Just a heads up, the Ambrosia mod written by UOAbigail is heavily scripted. Each PC has an "OOC Tool" that, among other things, allows you to store variables. I use this to store PC quest status. You will see my testing messages as well.

Remember this works correctly when it's nested in the conversation, but when it's just the NPC saying something with no PC convo to click on, it skips right over the part that destroys the object. It does do the rest of the script though. Any ideas why?


void main()
{
//NPC receives the item from PC.
//Sends them back to Sender ID.

    object oSelf = OBJECT_SELF;
    object oPC = GetPCSpeaker();

    string sMt = "You are "+GetName(oSelf)+"?";
    FloatingTextStringOnCreature(sMt,oPC,FALSE);
    ActionSpeakString("For me? Right, put it over here.",TALKVOLUME_TALK);

    int iQid = GetLocalInt(oSelf,"iSageQuest_id");                          //NPC QuestID
    string sTag = "Parcel"+IntToString(iQid);
    //Parcel tag
    string sQuest = "sg_quest_"+IntToString(iQid);
    object oItem = GetItemPossessedBy(oPC,sTag);
    int iQuest = GetLocalInt(oItem,sQuest);                                 //Get Quest #
    int iSender = GetLocalInt(oItem,sTag);                                  //Get sender ID

     string sMz = sQuest+" = "+IntToString(iQuest);
     SendMessageToPC(oPC,sMz);

     string sMj = sTag+" = "+IntToString(iSender);
     SendMessageToPC(oPC,sMj);
    //FloatingTextStringOnCreature("Yes, here is your parcel.",oPC);            //Reply to NPC
    //PC Voice something
    //PC Body Action Bow / Possibly NPC action/voice in response.

string sMe = "I'm about to destroy "+GetName(oItem);
SendMessageToPC(oPC,sMe);
    DestroyObject(oItem);              //Destroy Parcel

    //Reward
    string sSend = Get2DAString("sg_quest","Name",iSender);                     //Find Sender Name
    int iReward = GetLocalInt(oSelf,"iSage_rcvd_reward") * iQuest;              //Create reward amount
    string sMsg;
    if (iQuest != 0) {sMsg = "Here, take this for your trouble.";}   //If gold reward
    else {sMsg = "Please give "+sSend+" my thanks.";}                           //If no gold reward
    DelayCommand(2.0,ActionSpeakString(sMsg,TALKVOLUME_TALK));

    if (iReward != 0) {DelayCommand(2.5,GiveGoldToCreature(oPC,iReward));}

    object oTool = GetItemPossessedBy(oPC,"WW_OOCTool");                               //Set Rcvd status
    string sQst = "sg_quest_"+IntToString(iSender);
    SetLocalInt(oTool,sQst,1);

    ExportSingleCharacter(oPC);
}



 
               
               

               


                     Modifié par AmbrosiaPW, 25 avril 2011 - 09:12 .
                     
                  


            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
Conversation: 1st conversations action fail
« Reply #3 on: April 25, 2011, 11:58:36 pm »


               destroyed objects are not destroyed until end of script, your export char which would save the item that could be one issue.

I was able to use object oItem = GetItemPossessedBy(oPC,sTag); to destroy a item, so the above question comes into play.  The export of character didn't effect it either.

Also the object oItem may be a issue the default tag of item is "Parcel" then you add a var to it...
string sTag = "Parcel"+IntToString(iQid); making it "Parcel#" wich logicaly all seems to be correct, I dont see anything that chages the items tag.

a Delay Command may fix the issue since it is a npc preforming the actions
try: DelayCommand(3.0,DestroyObject(oItem)); //Destroy Parcel

or place the destroy at the end...

string sMe = "I'm about to destroy "+GetName(oItem);
SendMessageToPC(oPC,sMe);
DelayCommand(3.0,DestroyObject(oItem)); //Destroy Parcel

ExportSingleCharacter(oPC);

I will keep looking into it.
               
               

               
            

Legacy_AmbrosiaPW

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
Conversation: 1st conversations action fail
« Reply #4 on: April 26, 2011, 12:10:14 am »


               Thanks for replying. Don't waste too much time with it on my account. Like I said it works fine when it is an action from the PC text, so I just made it:

NPC: Is That a package for me?
PC. yes: Do Action

NPC:Would you like to see my wares. etc.


Thanks for your time.
               
               

               


                     Modifié par AmbrosiaPW, 25 avril 2011 - 11:10 .