Author Topic: Activate item and placeable target  (Read 526 times)

Legacy_archer4217

  • Full Member
  • ***
  • Posts: 206
  • Karma: +0/-0
Activate item and placeable target
« on: October 09, 2011, 04:54:03 pm »


               Hi all,

I have this script where you activate an item and the target has to be a placeable, but the generator doesn't give an option to specify the placeable. Is it possible to say which placeable has to be targeted? As you can see, using this item on a placeable starts the conversation 'workbench'. It would be great if the item wouldn't work on anything but the workbench.

/*   Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...=4683&id=625    */

void main()
{
object oPC;

if ((GetObjectType(GetItemActivatedTarget())!=OBJECT_TYPE_PLACEABLE)
|| GetIsInCombat(GetItemActivator())
){

SendMessageToPC(GetItemActivator(), "Improper use of item!");
return;}

oPC = GetItemActivator();

//The PC will technically start a conversation with himself
//You should add some odd little sound to the first line in the
//conversation file, or the PC will give his normal voicegreeting.

object oTarget;
oTarget = oPC;

AssignCommand(oTarget, ActionStartConversation(oPC, "workbench"));

}

Any help is greatly appreciated. '<img'>
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Activate item and placeable target
« Reply #1 on: October 09, 2011, 05:05:37 pm »


               void main()
{
object oPC = GetItemActivator();;
object oTarget=GetItemActivatedTarget();
string sTargetTag =GetTag(oTarget);
int iCombat =GetIsInCombat(oPC);
//we going off that the workbench tag is workbench


if(GetObjectType(oTarget)!=OBJECT_TYPE_PLACEABLE || iCombat==TRUE || sTargetTag!="workbench")
{
SendMessageToPC(oPC, "Improper use of item!");
return;
}



//The PC will technically start a conversation with himself
//You should add some odd little sound to the first line in the
//conversation file, or the PC will give his normal voicegreeting.

AssignCommand(oTarget, ActionStartConversation(oPC, "workbench"));

}
               
               

               


                     Modifié par ShadowM, 09 octobre 2011 - 04:08 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Activate item and placeable target
« Reply #2 on: October 09, 2011, 05:15:25 pm »


               Give your WorkBench a unique tag. for an example I will assume that your workbench has the Tag "workbench" and nothing else has that tag in the game, In that case you do not even need to check if it is a placable or not. Just check to see if the tag is correct.

void main()
{
  object oPC= GetItemActivator();

  if (GetTag(GetItemActivatedTarget())!="workbench"
  || GetIsInCombat(GetItemActivator()))
  {
    SendMessageToPC(GetItemActivator(), "Improper use of item!");
    return;
  }
  //The PC will technically start a conversation with himself
  //You should add some odd little sound to the first line in the
  //conversation file, or the PC will give his normal voicegreeting.
  AssignCommand(oPC, ActionStartConversation(oPC, "workbench"));
}

EDIT:  If this is a TagBased Script you will also need to add a filter to make sure that it does not fire for the other events.
               
               

               


                     Modifié par Lightfoot8, 09 octobre 2011 - 04:18 .
                     
                  


            

Legacy_archer4217

  • Full Member
  • ***
  • Posts: 206
  • Karma: +0/-0
Activate item and placeable target
« Reply #3 on: October 09, 2011, 06:54:15 pm »


               Thank you sweeties! *hugs to ShadowM and Lightfoot8*