Aller au contenu

Photo

Useable Item with Placeable Conversations?


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

#1
Lucan Silverhand

Lucan Silverhand
  • Members
  • 27 messages
Is it possible to use an activatable item to start a conversation with an object?

I've got the conversation on the Placeable, and I am calling it when I use the Activate Item script. Unfortunately, the conversation only fires off in the game as a one-liner so far. I want a full conversation with the object to be called when using the item based off its tag.

So far my script looks like the following:


#include "x2_inc_switches"
void main()
{
 int nEvent =GetUserDefinedItemEventNumber();
 if (!nEvent == X2_ITEM_EVENT_ACTIVATE) return;

 object oPC = GetItemActivator();
 object oItem = GetItemActivated();
 object oActTarget = GetItemActivatedTarget();

 if(GetObjectType(GetItemActivatedTarget())!=OBJECT_TYPE_PLACEABLE)
SetLocalInt(oPC, GetTag(OBJECT_SELF), TRUE);
object oTarget = GetObjectByTag("Table001");
AssignCommand(oTarget, ActionStartConversation(oPC, "table001conv", FALSE, FALSE));
}

Where "Table001" is the tag of the Placeable.
And "table001conv" is the conversation.

Any help would be appreciated, thanks.

#2
PJ156

PJ156
  • Members
  • 2 987 messages
Do you mean when the player uses the item, i.e. clicks it?

I use this script for that:

//Put this script OnUsed
void main()
{
object oPC = GetLastUsedBy();
if (!GetIsPC(oPC)) return;
object oTarget;
oTarget = GetObjectByTag("speaker");
AssignCommand(oTarget, ActionStartConversation(oPC, ""));
}

Here the speaker is your table tag, you dont need the conversation tag, the table has that, you are simply starting it's default conversation.

It's a Lilac Soul script and works just fine.

It depends on if you are trying to do anything fancier than simply click and talk?

PJ

Modifié par PJ156, 25 septembre 2013 - 05:21 .


#3
Tchos

Tchos
  • Members
  • 5 079 messages
Lucan may be talking about activating an inventory item, which would fire a script to begin a conversation with a separate placeable, not using a usable placeable and starting a conversation with that.

I tried several approaches to that situation some time ago. I think the method that succeeded was a roundabout method of using the item to spawn an Ipoint Speaker to fire the conversation. I'd have to review and test my scripts.

Modifié par Tchos, 25 septembre 2013 - 07:23 .


#4
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
To start a conversation with an item in your inventory I use a tag-based script. Here is an example script from my Silverwand Sample Campaign that starts a conversation allowing the user to specify a travel location.

// i_bb_travelgem_ac
// by Brendan Bellina
// Jan 2008

// bb_travelgem OnActivate handler
// This script is executed automatically when the item is activated
// To trigger properly the name of the script MUST be "i_" + itemtag + "_ac"
// Also to make the item usable set Item Property to Cast Spell: Unique Power on Self

// Allows the party to instantly travel to a waypoint in the module

#include "ginc_debug"
#include "ginc_item_script"

void main()
{
//PrettyDebug("i_bb_travelgem_ac: debug travel gem");

object oPC = GetItemActivator();
AssignCommand(oPC, ActionStartConversation(oPC, "debug_travelgem", FALSE, FALSE, TRUE, FALSE));
}

Regards

#5
Lucan Silverhand

Lucan Silverhand
  • Members
  • 27 messages

Tchos wrote...

Lucan may be talking about activating an inventory item, which would fire a script to begin a conversation with a separate placeable, not using a usable placeable and starting a conversation with that.

I tried several approaches to that situation some time ago. I think the method that succeeded was a roundabout method of using the item to spawn an Ipoint Speaker to fire the conversation. I'd have to review and test my scripts.


This one.

I'm using a 'rod' in your inventory which when used should supposedly allow you to target a placeable in the gameworld and start a conversation with it.

Modifié par Lucan Silverhand, 26 septembre 2013 - 02:27 .


#6
Tchos

Tchos
  • Members
  • 5 079 messages
If you want to start the conversation with the object that you target with the rod, then you don't need to use object oTarget = GetObjectByTag("Table001"); Instead, why not just use the oActTarget, which is not being used in the script as you have it now?

I'm not sure about the purpose of this line:
if(GetObjectType(GetItemActivatedTarget())!=OBJECT_TYPE_PLACEABLE)
SetLocalInt(oPC, GetTag(OBJECT_SELF), TRUE);

This only marks the activated inventory item with a local int when you target an object that's not a placeable. Unless there's some other script that checks the item for that local int, I'd remove it.

Also, if you're using this script as the item's tag-based activation script, then you shouldn't need the nEvent check, because there's no other situation where the script would be fired anyway.

As PJ says, you don't need to specify the name of the conversation if that conversation is assigned already on the placeable itself. The rest of the parameters can be left at their defaults, too, so no need to specify them.

So this is the edit to your original script that I propose, though I haven't tested it:

#include "x2_inc_switches"
void main()
{
object oPC = GetItemActivator();
object oItem = GetItemActivated();
object oActTarget = GetItemActivatedTarget();

AssignCommand(oActTarget, ActionStartConversation(oPC));
}

#7
Morbane

Morbane
  • Members
  • 1 883 messages
if you want to use the item activate power that is designed into item properties, this function is the foundation for that. (right-click on rod to activate)

#include "x2_inc_switches"

void main()
{
int nEvent = GetUserDefinedItemEventNumber();

// Spells might continue to their spell scripts. All other events are
// completely handled by this script.
if ( nEvent != X2_ITEM_EVENT_SPELLCAST_AT )
SetExecutedScriptReturnValue();

case X2_ITEM_EVENT_ACTIVATE:
{
// The item's CastSpell Activate or CastSpell UniquePower was just activated.
object oItemUser = GetItemActivator();
object oItem = GetItemActivated();
object oTarget = GetItemActivatedTarget();

if( !GetIsObjectValid( oItemUser) || !GetIsObjectValid( oItem))
{
SetExecutedScriptReturnValue( X2_EXECUTE_SCRIPT_CONTINUE);
return;
}

// This is where you put your Unique power activation modifications.
if(oTarget == GetObjectByTag("your placeable tag"))
{
conv function goes here.
}
}

}

there are two naming conventions for item scripts such as this one - but i will not go into that here - but i can tell you it includes the tag of your item in both cases

look for lilac soul's script generator on the vault - within its design there is an explaination of both systems of tag based scripting

Modifié par Morbane, 27 septembre 2013 - 07:33 .


#8
Lucan Silverhand

Lucan Silverhand
  • Members
  • 27 messages
Sorry for digging up this old topic again, but I still need some help.

I've managed to get it to do exactly what I wanted it to do, thanks to the great posts above! But I am still getting the issue that the conversation is a one-liner. ActionStartConversation(oPC) only makes the first line of the conversation appear.

In my module I've set up two identical objects in the scene both with the same conversation script; the only difference between them is one is set up to be talkable (nw_g0_convplac on used) while the other needs the usable item from above to call the conversation. The talkable one brings up the whole conversation tree. The item-called one only floats the first line. Is there a way to make the item-called one show the whole tree?

#9
Darin

Darin
  • Members
  • 282 messages
check the tags in the conversation nodes. Also, give everything a unique tag, just in case.

In the conversation, give the "item-called" object the node for each of it's lined; if it's tag were "itemcalled_placeable", then under "speaker" have "itemcalled_placeable". I've found that conversations drop out when the speaker tags are wrong.

#10
Lucan Silverhand

Lucan Silverhand
  • Members
  • 27 messages
putting the unique object's tag on the speaker nodes only serves to stop the conversation from working on the other object. It still does not allow any responses to be chosen.

Edit: I changed the tags in my script and on my objects and for some reason it works now. NVM. Must not like numbers or something.

Modifié par Lucan Silverhand, 12 décembre 2013 - 05:14 .


#11
Darin

Darin
  • Members
  • 282 messages
Could have also been a typo; happens to me all the time, especially "co-name" vs. "co_name"... since there is no "co-name", it ends the conversation.