Skip to content

Trigger just for NPC

Hello again!
I created a script that works fine but the content should be fire only through an NPC.
I need to set a trigger enter only for an NPC use and when the player walks in it nothing should be happen.
How can I do? Thanks in advance as always!

Comments

  • TarotRedhandTarotRedhand Member Posts: 1,481
    Give the NPC a unique tag. Then in the OnEnter event, instead of checking that it is the PC that enters, instead check that the entering object has that tag.

    TR
  • DarkAliceDarkAlice Member Posts: 7
    Sure, I had given a unique tag to the NPC but I know only how to make the check for the PC. Here's a test version of the script: what I missed to add?

    void main()

    {

    object oTarget;

    oTarget = GetEnteringObject ();

    oTarget = GetObjectByTag("Pippa");

    AssignCommand(oTarget, PlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 7.0));

    AssignCommand(oTarget, SpeakString ("I'm so tired!"));

    object oWp;

    oWp = GetWaypointByTag ("WP_Pippa_02");

    DelayCommand (9.0f,AssignCommand(oTarget, ActionMoveToObject (oWp)));

    }
  • TarotRedhandTarotRedhand Member Posts: 1,481
    Try this
    void main()
    {
        object oTarget;
        object oWp;
    
        oTarget = GetEnteringObject();
        
        if(GetTag(oTarget)=="Pippa")
        {
            AssignCommand(oTarget, PlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 7.0));
            AssignCommand(oTarget, SpeakString ("I'm so tired!"));
            oWp = GetWaypointByTag ("WP_Pippa_02");
            DelayCommand (9.0f,AssignCommand(oTarget, ActionMoveToObject (oWp)));
        }
    }
    

    If you haven't already, grab a copy of the downloadable NwN Lexicon 1.69. As it says, it only covers upto NwN version 1.69 but it does contain explanations of most of the functions that you'll that you'll need. Even if you can't access a windows chm file, there is a link (under Related Projects) on the project page, to the online version of the lexicon that covers all the functions that EE has.

    TR
  • DarkAliceDarkAlice Member Posts: 7
    Thank you so much Tarot! I had tried with if GetTag but i had forgot the == after oTarget. Now I understand better how it work.
    And yes, the Lexicon is a very useful guide but sometimes I still make syntax errors. I need more practice. <3
  • TarotRedhandTarotRedhand Member Posts: 1,481
    No problem. Practice is good. You might find 3 of the 4 tutorials I wrote a little while ago useful too -

    TR's Basics - Decisions
    TR's Basics - Boolean Algebra
    TR's Basics - Mostly Operators

    They are all in fully bookmarked pdf files. Just take a look at the project pages and see if you think they might be useful for you. Hint - I won't be offended if you decide not to download any of them :) . One other thing you might find of use -

    Just The FAQs, ma'am - These are the scripting FAQs (Frequently Asked Questions with Answers)

    TR
  • DarkAliceDarkAlice Member Posts: 7
    I downloaded your tut! They are very clear explained! :) If I had read Decision.pdf earlier I wouldn't have to ask for help here. There you illustrate well the Comparisons Operators where I fell this time (and several ones).
  • TarotRedhandTarotRedhand Member Posts: 1,481
    Thanks. Glad you find them useful.

    TR
Sign In or Register to comment.