Author Topic: Item Conversation - What's wrong with this?  (Read 389 times)

Legacy_BelowTheBelt

  • Hero Member
  • *****
  • Posts: 699
  • Karma: +0/-0
Item Conversation - What's wrong with this?
« on: April 06, 2012, 03:12:52 pm »


               So I've been banging my head on this seemingly innocuous script for a while now and can't figure out my error.  I'm trying to fire a conversation with an inventory item after it's used, but I get an error that the object is too far away to talk to.

Probably an easy fix, I'm just not seeing it.  Your help is much appreciated!

#include "x2_inc_switches"
void main()
{
int nEvent = GetUserDefinedItemEventNumber(); 
if(nEvent !=  X2_ITEM_EVENT_ACTIVATE)return;
int nResult = X2_EXECUTE_SCRIPT_END;
switch (nEvent)
        {
        case X2_ITEM_EVENT_ACTIVATE:
            {
            SendMessageToPC (GetFirstPC(), "DEBUG:  ar_feystone:  tag-based script ar_feystone fired");
            object oItem = GetItemActivated();
            object oPC = GetItemActivator();
            int iPCRace = GetRacialType (oPC);
            string sSubrace = GetStringUpperCase(GetSubRace(oPC));
            if( GetIsInCombat( oPC))
                {
                SendMessageToPC(oPC,  "You cannot use this item while in the midst of combat.");
                return;
                }
            //non-elves can't use feystones, neither can mindflayers
            if ((iPCRace != RACIAL_TYPE_ELF)||(iPCRace == RACIAL_TYPE_ELF && (sSubrace == "MINDFLAYER"||sSubrace=="ILLITHID")))
                {
                SendMessageToPC (oPC, "The arcane magic of this device is too foreign to you and you are unable to make it work.");
                return;
                }
            SendMessageToPC (GetFirstPC(), "DEBUG:  ar_feystone:  completed checks.  Should launch convo");
            SendMessageToPC (GetFirstPC(), "DEBUG:  ar_feystone:  oItem = "+GetName(oItem));
            SendMessageToPC (GetFirstPC(), "DEBUG:  ar_feystone:  PC = "+GetName(oPC));
            SendMessageToPC (GetFirstPC(), "DEBUG:  ar_feystone:  OBJECT_SELF = "+GetName(OBJECT_SELF));
            AssignCommand(oPC, ClearAllActions());
            AssignCommand(oPC, ActionStartConversation(oItem, "ar_feystone")); //, TRUE, FALSE));
            //Change the following line from X2_EXECUTE_SCRIPT_CONTINUE to
            //X2_EXECUTE_SCRIPT_END if you want to prevent the calling of the
            //code after the execute is done
            nResult = X2_EXECUTE_SCRIPT_CONTINUE;
            }
            break;
        }
SetExecutedScriptReturnValue(nResult);
}
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Item Conversation - What's wrong with this?
« Reply #1 on: April 06, 2012, 04:13:46 pm »


               An item can not have a conversation.  You will need to have the PC either talk to himself:

AssignCommand(oPC, ActionStartConversation(oPC, "ar_feystone"));

Or create a placeable for the PC to talk to.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Item Conversation - What's wrong with this?
« Reply #2 on: April 06, 2012, 04:52:06 pm »


               

Lightfoot8 wrote...

An item can not have a conversation.  You will need to have the PC either talk to himself:

AssignCommand(oPC, ActionStartConversation(oPC, "ar_feystone"));

Or create a placeable for the PC to talk to.


BioWare already has a template set up for this. 

1) Put the "Cast Spell: Talk to" property on the chosen item
2) Create a conversation with a name matching the item's tag
3) Use the script "x2_iw_cnv_ok" as the starting conditional for initiating the dialog (there is also the script "
x2_iw_cnv_1st
" which can be used as an earlier conditional pertaining to the a conversation branch which will be accessed only the first time through)
4) Use the script
"x2_iw_conv_abort
" for the normal conversation end script and for the abort end script.
5) If you are using the item in a conversation and do not want the default Enserric portrait and name edit the script "x2_s3_intitemtlk" inserting the bolded lines below


//::///////////////////////////////////////////////
//:: Black Blade of Disaster
//:: X2_S0_BlckBlde
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Summons a greatsword to battle for the caster
*/
//:://////////////////////////////////////////////
//:: Created By: Andrew Nobbs
//:: Created On: Nov 26, 2002
//:://////////////////////////////////////////////
//:: Last Updated By: Georg Zoeller, July 28 - 2003


#include "x2_inc_intweapon"

//Creates the weapon that the creature will be using.
void spellsCreateItemForSummoned(object oCreator, object oBlade, object oSummon)
{

}

#include "x2_inc_spellhook"
void AssignNameAndPortrait()
{
object oItem = GetNearestObjectByTag("x2_plc_intwp");
SetName(oItem, "NAME_OF_ITEM_GOES_HERE");
SetPortraitId(oItem, PORTRAIT_ID_GOES_HERE);
}

void main()
{

    DeleteLocalInt(OBJECT_SELF,"X2_L_IN_INTWEAPON_CONVERSATION");

    object oBlade = GetSpellCastItem();
    object oCreator = OBJECT_SELF;

    IWStartIntelligentWeaponConversation(oCreator,oBlade);

    DelayCommand(0.5, AssignNameAndPortrait());
   // ActionUnequipItem(oBlade);
}


               
               

               


                     Modifié par WhiZard, 06 avril 2012 - 03:53 .
                     
                  


            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Item Conversation - What's wrong with this?
« Reply #3 on: April 06, 2012, 05:03:37 pm »


               <prying...>

How was the Enserric convo in HotU done? Was that done with the PC talking to himself?

<...his fingers off the hilt>
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Item Conversation - What's wrong with this?
« Reply #4 on: April 06, 2012, 05:14:10 pm »


               

Rolo Kipp wrote...

<prying...>

How was the Enserric convo in HotU done? Was that done with the PC talking to himself?

<...his fingers off the hilt>


No, the PC talks to an invisible placeable with resref and tag of "x2_plc_intwp".  This placeable has the name "Enserric the sword" and the portrait of the black blade of disaster.
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Item Conversation - What's wrong with this?
« Reply #5 on: April 06, 2012, 05:40:00 pm »


               <doing...>

Your post actually answered me before I posted... but I didn't see your post until *after* I submitted mine.

I don't mean I didn't *notice* it. I mean it wasn't showing in the thread until I responded, making my post moot :-P

Weird.

But, as always, you give good knowledge ;-) I didn't know any of that.

Cool!

<...a double-take>
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Item Conversation - What's wrong with this?
« Reply #6 on: April 06, 2012, 06:35:09 pm »


               

Rolo Kipp wrote...

<doing...>

Your post actually answered me before I posted... but I didn't see your post until *after* I submitted mine.

I don't mean I didn't *notice* it. I mean it wasn't showing in the thread until I responded, making my post moot :-P

Weird.

But, as always, you give good knowledge ;-) I didn't know any of that.

Cool!

<...a double-take>


A few more tidbits: In addition to the "Cast Spell: Talk to" property, there is also the "On Hit Cast Spell: Intelligent Weapon" property.  Intelligent weapon handles the one-liners (where the PC is talking to himself) for unequipping, equipping, and on-hit race identification and random battle one liners.  Both Talk to and Intelligent Weapon will share the same conversation (though will be directed to different dialogue paths).
               
               

               
            

Legacy_BelowTheBelt

  • Hero Member
  • *****
  • Posts: 699
  • Karma: +0/-0
Item Conversation - What's wrong with this?
« Reply #7 on: April 06, 2012, 06:42:46 pm »


               I think I'll start with the 'easy' way by having the PC talk to himself.  I think it works both from a simplicity and an RP standpoint.  

I do have a question regarding the intelligent weapon version.  "x2_iw_cnv_ok" calls the function IWGetIsInIntelligentWeaponConversation, which checks for whether or not the local variable X2_L_IN_INTWEAPON_CONVERSATION is on the PC.  

This variable seems to be set via the function IWStartIntelligentWeaponConversation, which in turn, seems to be called from somewhere else.  It seems like I'd either need to set the variable via a script or call the IWStartIntelligentWeaponConversation function) in order to pass through the Starting Conditional.  Or, am I missing something?

Thanks!
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Item Conversation - What's wrong with this?
« Reply #8 on: April 06, 2012, 06:57:31 pm »


               

BelowTheBelt wrote...

I think I'll start with the 'easy' way by having the PC talk to himself.  I think it works both from a simplicity and an RP standpoint.  

I do have a question regarding the intelligent weapon version.  "x2_iw_cnv_ok" calls the function IWGetIsInIntelligentWeaponConversation, which checks for whether or not the local variable X2_L_IN_INTWEAPON_CONVERSATION is on the PC.  

This variable seems to be set via the function IWStartIntelligentWeaponConversation, which in turn, seems to be called from somewhere else.  It seems like I'd either need to set the variable via a script or call the IWStartIntelligentWeaponConversation function) in order to pass through the Starting Conditional.  Or, am I missing something?

Thanks!

The script for Talk to "x2_s3_intitemtlk" already calls IWStartIntelligentWeaponConversation.  If you want it called separately just do it the same way the script does it (with my modifications above if you want a different portrait or name).

For example, if you want to make so that it looks like you are talking to yourself, you can set the name and portrait to match your own name and portrait.

EDIT: fixed a typo in script name
               
               

               


                     Modifié par WhiZard, 06 avril 2012 - 06:04 .
                     
                  


            

Legacy_BelowTheBelt

  • Hero Member
  • *****
  • Posts: 699
  • Karma: +0/-0
Item Conversation - What's wrong with this?
« Reply #9 on: April 06, 2012, 07:30:13 pm »


               Ahh, so from your list, #1 calls #5 before the convo starts?  Or does the script 'x2_s3_intitemtlk' go somewhere specific?  I was confused because I was reading the list as if that were the order in which the actions would occur.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Item Conversation - What's wrong with this?
« Reply #10 on: April 06, 2012, 07:36:52 pm »


               

BelowTheBelt wrote...

Ahh, so from your list, #1 calls #5 before the convo starts?  Or does the script 'x2_s3_intitemtlk' go somewhere specific?  I was confused because I was reading the list as if that were the order in which the actions would occur.


Correct, the conversation is delayed 1.0, my modification is delayed 0.5.  Having the modification in the conditionals is too late as the change of portrait and name will not take effect until the next conditional fires.

The list is in order of how to piece it together, the order of occurence starts with the cast spell, followed by the modification followed by the conversation.