Skip to content

how do you make NPCs pick up items?

sarevok57sarevok57 Member Posts: 6,002
for the life of me the scripting in the toolset is such a nightmare that i can't get my head around

i can do okay for when it comes to copy and pasting things from other instances i want

but when it comes to new things, im at a complete loss, i even tried using the NWN lexion site and it was absolutely no help at all *sigh*

so for you tool set gods i need assistance with a script i want to run:

i want to make it so that every time the NPC reaches their way point they do the "picking something up" animation

thanks

Comments

  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited July 2019
    Have you looked at the Scripting FAQs (Frequently Asked Questions with answers)? Have you tried the downloadable version of the lexicon? It has most of the content of the lexicon website including scripting tutorials. Just not the new functions that have been introduced for EE. If you really want to learn scripting have you looked at this primer I wrote? There are another 3 in ebooks in the series and they are linked to on the project page under related projects.

    For most small scripts try the Script Generator.

    TR
  • TarotRedhandTarotRedhand Member Posts: 1,481
    If you can find the "picking something up" animation I can probably make you the script. Trouble is I've looked and I can't find that animation for use with scripts.

    On a related point. If you open up the properties for a waypoint you'll see they have no events. That means you can't have scripts triggered by walking on them. The way around this is to paint a generic trigger around the waypoint and use the trigger's OnEnter or OnExit events instead.

    TR
  • sarevok57sarevok57 Member Posts: 6,002
    ah triggers, haha oi, i think i vaguely know how to do trigger stuff

    and the "pick up item" is actually not an "animation" per se but its own script

    - using that script generator under the tab where "play animation" is one of the options, another option in that menu is "pick up item" -
  • ABJECT_SELFABJECT_SELF Member Posts: 24
    edited July 2019
    I believe the NPC Activities library has the exact function you're looking for. I can't tell you how to use it but I remember the documentation being easy to follow.
  • ProlericProleric Member Posts: 1,316
    The animation you're looking for is ANIMATION_LOOPING_GET_LOW (invoked by ActionPlayAnimation).

    You can also use ActionPickUpItem to recover an actual item.
  • Pixel_MayhemPixel_Mayhem Member Posts: 61
    Just yell at the NPC, I'm sure they'll get to it eventually :p
  • GruffbaneJoeGruffbaneJoe Member Posts: 39
    edited November 2019
    Yes if you could make a script that will walk to a way point, do the pick-up animation, and then walk to the next and do the same that would be awesome! I tried but she hardly ever does the animation:

    void main()
    {
    { object oTarget = GetNearestObjectByTag("WP_WPLANTER1_01");
    ActionMoveToObject(oTarget); ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 2.0);
    }
    { object oTarget = GetNearestObjectByTag("WP_WPLANTER1_02");
    ActionMoveToObject(oTarget); ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 2.0);
    }
    }
  • GruffbaneJoeGruffbaneJoe Member Posts: 39
    edited November 2019
    OK I figured it out!
    The script I wrote above was fine except for the waypoint names. I didn't need any kind of pause.

    The reason the NPCs wouldn't "get_low" was because the ambient AI for walking waypoints overrides the script.
    So the solution was simply to name/tag the waypoints something other than standard "walkwaypoints" tags.

    void main()
    {
    { object oTarget = GetNearestObjectByTag("WP_WPLANTER1_A");
    ActionMoveToObject(oTarget); ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 2.0);
    }
    { object oTarget = GetNearestObjectByTag("WP_WPLANTER1_B");
    ActionMoveToObject(oTarget); ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 2.0);
    }
    }

    I renamed/retagged the two waypoints "WP_WPLANTER1_A" and "WP_WPLANTER1_B" and now she picks up something every time.
    Post edited by GruffbaneJoe on
  • GruffbaneJoeGruffbaneJoe Member Posts: 39
    If you want the PC to actually pick up stuff, this script works great:

    /*
    Used with Old Man character model. This is VERY basic, not necessarily a 'daily' routine but
    good enough to put in. Also really funny when you see careless players throwing items all over.
    */

    void main()
    {
    ClearAllActions();
    object oNearest = GetNearestObject(OBJECT_TYPE_ITEM, OBJECT_SELF);
    if (GetIsObjectValid(oNearest))
    {
    ActionMoveToObject(oNearest, TRUE, 1.0f);
    int nSay0 = Random(4);
    if (nSay0 == 1)
    {
    SpeakString("Ooo, stuff!");
    }
    else if (nSay0 == 2)
    {
    SpeakString("It's -MINE-");
    }
    else if (nSay0 == 3)
    {
    SpeakString("Old guy comin' through!");
    }
    else if (nSay0 == 0)
    {
    SpeakString("Ahahaha, gold for the old!");
    }
    ActionPickUpItem(oNearest);
    }
    else
    {
    int nRand = Random(3);
    if (nRand == 1)
    {
    ActionRandomWalk();
    int nSay1 = Random(4);
    if (nSay1 == 1)
    {
    SpeakString("*sigh*");
    }
    else if (nSay1 == 2)
    {
    SpeakString("Walk, walk, walk. It's all I do!");
    }
    else if (nSay1 == 3)
    {
    SpeakString("Must.. find.. stuff!");
    }
    else if (nSay1 == 0)
    {
    SpeakString("*cough*");
    }
    }
    else if (nRand == 2)
    {
    object oFollow = GetNearestCreature(CREATURE_TYPE_CLASS, CLASS_TYPE_COMMONER);
    ActionForceFollowObject(oFollow);
    int nSay2 = Random(4);
    if (nSay2 == 1)
    {
    SpeakString("Here I come!");
    }
    else if (nSay2 == 2)
    {
    SpeakString("Bum rush!");
    }
    else if (nSay2 == 3)
    {
    SpeakString("Hahaha!");
    }
    else if (nSay2 == 0)
    {
    SpeakString("<This model powered by Energizer. Do you have the Bunny inside?>");
    }
    }
    else if (nRand == 0)
    {
    int nSay3 = Random(4);
    if (nSay3 == 1)
    {
    SpeakString("Uh, what?");
    }
    else if (nSay3 == 2)
    {
    SpeakString("You lookin' at me punk?");
    }
    else if (nSay3 == 3)
    {
    SpeakString("Leave me be!");
    }
    else if (nSay3 == 0)
    {
    SpeakString("Default text goes here. Uhh... huh?");
    }
    }
    }
    }


    It was meant as a humorous way to clean up items players drop on the ground or don't pick up, but there's lots of creative things you can do with it and his one-liners are easy to change. Put it in the OnHeartbeat of the Old Man NPC under Humans. I got it from this old guide, which is invaluable even though a few of the scripts don't work anymore when you're running the current version.

    https://neverwintervault.org/article/tutorial/nwn1-guide-dms-and-builders
Sign In or Register to comment.