how do you make NPCs pick up items?
sarevok57
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
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
0
Comments
For most small scripts try the Script Generator.
TR
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
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" -
You can also use ActionPickUpItem to recover an actual item.
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);
}
}
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.
/*
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