Aller au contenu

Photo

Calling scripter gods...help giving my script a little discipline, show it whos boss!


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

#1
christinetooley

christinetooley
  • Members
  • 58 messages
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

#2
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
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.

#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
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
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:
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
christinetooley

christinetooley
  • Members
  • 58 messages
Thanks guys. I'll give this a go.

#5
christinetooley

christinetooley
  • Members
  • 58 messages
YEP YEP. That did the trick. Thanks so much for the quick and precise feedback!