OK so I'm making a conversation on an item which calls for ACTIVATE in module properties. Problem is that I have 2 other scripts that are ALSO onItemActivate and one of them is calling on the conversation of another. What I need is to re-write this to where it is only called on by the activation of the "I_craftsmankit" item tag.
the code is as follows
[code=auto:0]void main()
{
object oPC = GetItemActivator();
object oTarget;
object item = GetItemActivated();
oPC = GetItemActivator();
oTarget = oPC;
object oItem = GetItemActivated();
string sTag = GetTag(oItem);
if (sTag == "craftsmankit")
{
AssignCommand(oTarget, ActionStartConversation(oPC, "crftkitconvo", FALSE, FALSE, TRUE, FALSE));
}[code=auto:0]
Thanks in advance for your help. I am NO kinda scripter and just guessing for the most part.<3
Calling scripter gods...help giving my script a little discipline, show it whos boss!
Débuté par
christinetooley
, févr. 05 2011 02:01
#1
Posté 05 février 2011 - 02:01
#2
Posté 05 février 2011 - 02:59
Use tag based scripts to do that. That way you can create scripts for each item as needed.
First read jaaspers tutorial on it...http://www.noobscorner.Jassper.com/frm_tag_basics.htm#TBS_nwn2
Name your script as such...
i_craftsmankit_ac.nss
I copy pasted from Jassper's tutorial here, and put in your code into the above file name. I have not tested this myself.
This requires a flag on the module enabling item based scripting, and the default on acquire script to support this. I left the send messages he included which you can delete, but should help you see how it's set up.
You can also use case statements, but this is more robust and does not really cause problems the way NWN2 is set up. If you are doing a massive PW with 50 players all the time it might be something you give a closer look, even then i'd put something in the items resref which indicates it should have an tag based script it should look for.
First read jaaspers tutorial on it...http://www.noobscorner.Jassper.com/frm_tag_basics.htm#TBS_nwn2
Name your script as such...
i_craftsmankit_ac.nss
I copy pasted from Jassper's tutorial here, and put in your code into the above file name. I have not tested this myself.
This requires a flag on the module enabling item based scripting, and the default on acquire script to support this. I left the send messages he included which you can delete, but should help you see how it's set up.
#include"x2_inc_switches"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
// Exit if not an activate event
if(nEvent != X2_ITEM_EVENT_ACTIVATE)return;
// Your script here
object oUser = GetItemActivator();
object oTarget = GetItemActivatedTarget();
string sName = GetName(oTarget);
string sTag = GetTag(oTarget);
location lLoc = GetLocation(oTarget);
vector vPos = GetPositionFromLocation(lLoc);
SendMessageToPC(oUser,"OBJECT NAME: "+sName);
SendMessageToPC(oUser,"OBJECT TAG: "+sTag);
SendMessageToPC(oUser,"OBJECT POSITION: "+FloatToString(vPos.x)+","+FloatToString(vPos.y)+","+FloatToString(vPos.z));
SendMessageToPC(oUser,"OBJECT AREA: "+GetName(GetAreaFromLocation(lLoc)));
AssignCommand(oTarget, ActionStartConversation(oUser, "crftkitconvo", FALSE, FALSE, TRUE, FALSE));
}
You can also use case statements, but this is more robust and does not really cause problems the way NWN2 is set up. If you are doing a massive PW with 50 players all the time it might be something you give a closer look, even then i'd put something in the items resref which indicates it should have an tag based script it should look for.
Modifié par painofdungeoneternal, 05 février 2011 - 03:00 .
#3
Posté 05 février 2011 - 03:43
I would just use the standard on activate script template to create the script structure. In the toolset go to the campaign scripts tab, right click in it and select Add from Template -> Item Activate. This will create a script names Script1. Rename it to i_craftsmankit_ac, add your code, and compile it.
The only lines you need to start your conversation though are:
Regards
The only lines you need to start your conversation though are:
void main()
{
object oPC = GetItemActivator();
AssignCommand(oPC, ClearAllActions(TRUE));
AssignCommand(oPC, ActionStartConversation(oPC, "crftkitconvo", FALSE, FALSE));
}
Regards
Modifié par Kaldor Silverwand, 05 février 2011 - 03:44 .
#4
Posté 05 février 2011 - 05:29
Thanks guys. I'll give this a go.
#5
Posté 07 février 2011 - 01:01
YEP YEP. That did the trick. Thanks so much for the quick and precise feedback!





Retour en haut






