Author Topic: Open Inventory through conversation?  (Read 330 times)

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Open Inventory through conversation?
« on: June 15, 2011, 05:26:57 am »


               I am stumped. *shrugs* Went to search the old Bioware archives but it looks like Bioware has finally taken them down.

I've used OpenInventory enough times to know it does work but this particular issue just won't fire.

ISSUE

A placeable with a conversation, with an option in the conversation to open up the inventory of the placeable. The OnUsed event fires the script noted below to start the conversation.

void main()
{

    object oPC = GetLastUsedBy();
    if (oPC == OBJECT_INVALID)
    {
        oPC = GetClickingObject();   // for doors that fail to open
    }

    if (oPC == OBJECT_INVALID)
    {
        SendMessageToPC(GetFirstPC(), "ERROR: null user in talk event");
    }

    ActionStartConversation(oPC);
}


I am unable to get the container I'm having a conversation with to open its inventory with the ACTIONS TAKEN TAB.

Here's what I've tried -

void main()
{
// INVENTORY TEST
// NOTHING BUT HAD TO TRY
object oTarget = GetObjectByTag("MIXING_CONTAINER");
OpenInventory(oTarget, GetFirstPC());

// NOTHING BUT HAD TO TRY
AssignCommand(GetFirstPC(), OpenInventory(GetObjectByTag("MIXING_CONTAINER"), GetFirstPC()));

// NOTHING BUT HAD TO TRY
AssignCommand(GetObjectByTag("MIXING_CONTAINER"), OpenInventory(GetObjectByTag("MIXING_CONTAINER"), GetFirstPC()));

// OPENS PLAYER'S INVENTORY INSTEAD ...
DelayCommand(0.5, AssignCommand(GetFirstPC(), OpenInventory(OBJECT_SELF, GetFirstPC())));

// FIRES CONVO AGAIN ...
DelayCommand(0.5, AssignCommand(GetFirstPC(), ActionInteractObject(GetObjectByTag("MIXING_CONTAINER"))));
}


Is it even possible to do?

FP!
               
               

               


                     Modifié par Fester Pot, 15 juin 2011 - 04:33 .
                     
                  


            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Open Inventory through conversation?
« Reply #1 on: June 15, 2011, 06:13:23 am »


               Thought I'd answer my own question. In fact, I've asked it before ':crying:'. If Axe Murderer or Cereborn still lurked in the scripting forum, I think they'd have a stern message for me about this one because of my fading memory.

So here's what I had to do and I thank the NWN Omnibus for refreshing my memory.

The OnUsed script had to be moved to the OnClick even of the placeable. It also had to be modified so the conversation wouldn't start from across the room but rather, right when the player is standing next to it. It also simulates the player moving to an object to activate it like a normal placeable with an inventory that had no scripts to start up a conversation.

void main()
{

    object oPC = GetPlaceableLastClickedBy();
    if (oPC == OBJECT_INVALID)
    {
        oPC = GetClickingObject();   // for doors that fail to open
    }

    if (oPC == OBJECT_INVALID)
    {
        SendMessageToPC(GetFirstPC(), "ERROR: null user in talk event");
    }

 // Let's see if player is close enough to start a conversation

 float fMinDistanceToGuide = 1.5f;
 vector vPCPosition = GetPosition(oPC);
 vector vGuideLocation = GetPosition(GetNearestObjectByTag("MIXING_CONTAINER", oPC));
 vector vDistance = vPCPosition - vGuideLocation;
 float fDistance = VectorMagnitude(vDistance);

 if (fDistance > fMinDistanceToGuide)
 // PLAYER CLICKED PLACEABLE FROM TOO FAR A DISTANCE
 {
 AssignCommand(oPC, ClearAllActions());
 AssignCommand(oPC, ActionForceMoveToObject(GetNearestObjectByTag("MIXING_CONTAINER"), TRUE, 1.0f, 30.0));

 AssignCommand(oPC, ActionStartConversation(GetNearestObjectByTag("MIXING_CONTAINER")));
 return;
 }

 else

 {
 // PLAYER CLICKED PLACEABLE FROM WITHIN RANGE
     ActionStartConversation(oPC);

 }
}


Then the ACTIONS TAKEN TAB script for opening up the inventory of the placeable is now,

void main()
{

DelayCommand(0.5, AssignCommand(GetFirstPC(), ActionInteractObject(GetObjectByTag("MIXING_CONTAINER"))));
}


FP!
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Open Inventory through conversation?
« Reply #2 on: June 15, 2011, 06:46:06 am »


               Instead of useing GetNearestObjectByTag("MIXING_CONTAINER") and searching for the table. Why not just use OBJECT+SELF.

Of cource you will not be able to use it in your assign commands but you could use it like this.

void main()
{
object oTable=OBJECT_SELF;
DelayCommand(0.5, AssignCommand(GetFirstPC(), ActionInteractObject(oTable)));
}

I would hate to see him click on one tabe just to run to a differant one.
               
               

               


                     Modifié par Lightfoot8, 15 juin 2011 - 05:47 .