I have played NWN 1 for years, I have played a ton of modules, and have had some ideas for modules. But every time I get stopped by they ideas becoming to complex for my scripting ability.
So, now I try a different approach. Doing it really simple.
Still I have alot to learn.
So I made a simple quest: go to the forrest save a child from a goblin who kidnapped him. I got to making the journal entries, killing the goblin and getting XP etc. So now a want to make some variations. SO I want the PC to have 3 posibilities when talking to the child.
Tell him to go home alone
Tell him to follow the PC
Tell him to something nasty
1.I have problems of getting him to do so. I tried āgo toā script to a waypoint in his village, but he gets stuck on the way. Anyway to have him do so? Or to just walk in the correct direction and then āfadeā to the correct place?
2. I got him to follow the PC. Now I want him to follow the PC to his parents and then stop following the PC. Either through an āareaā in front of his parents or though a conversation with the child or the parents.
3. No problem here. I just scripted the possibility to have the character go āevilā a few points.
What is the best way to have any possible reward for rescuing him being dependent on the three solutions? Is calling āJournal entriesā or ālocal variantā better?
Before I start here are a few links to stuff youāll find useful.-
A Short Tour of These Forums - Pinned thread that describes the mechanics of using these forums including how to post code.
NwN Lexicon 1.69 - Indispensable guide to scripting (downloadable version). Includes descriptions of functions , constants, etc. Includes tutorials. Link on the project page to the online version.
I did read āGuide to Build Volume I and IIā and look around the Lexicon beforehand. Both where useful, but the lexicon somewhat expect to to know what you are looking for.
About my issues.
I got a code working (see below), that made him go in the right direction, but he got stuck at various objects and then stop. I in many modules I have played they made the NPC walk in the right direction and then āfadeā away and then appear at the right location, and I was considering how this was done?
As mentioned I got the NCP to follow (by using Lilacs soulās script generator). But I donāt see any obvious way of stooping the NCP following the PC again. Was is the command for that? I prefer it to happen in an area around the home (is using a āgeneric triggerā the best way?).
The reason I asked about the local variables (thank you for correcting the vocabulary) is that the Bulders guide wrote:
āIt is possible to use the Journaling facility not only to document the progress of the Quests for the PC, but also to provide the local variable control function for the quests. The process of adding a journal entry also updates a PC based local variable related to the Quest id.ā
So it seemed to spare some steps, but I was wondering what the best solution is.
instead. Look at ActionForceMoveToObject() in the Lexicon. Using that function, the NPC will ājumpā to the object if it hasnāt reached it after a set time.
As to number 2, try -
AssignCommand(oNPC, ClearAllActions());
assuming you used ActionForceFollowObject() or some other action based function (i.e. its name starts with āactionā), to get the NPC to follow the PC.
You can do things in whatever way seems to work best for you.
Escort quests are universally hated in RPGs for a reason: even the professionals canāt make the NPCs move properly.
Having the child run off and despawn and simply be at their parents side when you return seems to me to be the easiest solution.
If you do want the option to escort them home safely, you would typically
Check whether kid was with you when you talked to parent and if so, allow a dialogue tree that completes quest
Check whether kid was with you when you entered the area (or trigger) and have the parent initiate above conversation (Generic Trigger or Area / OnEnter)
Then you either disable whatever you did to make him follow PC or perhaps just redefine the object the kid follows from PC to parent in the script that completes quest. Or maybe parent sends him upstairs/inside and you despawn him again (again, easier, and if your game is multiplayer then the kid wont be standing around next to parent while parent asks next PC to help find kid).
NWLexicon really is your friend. Every page describing a function has links to the other functions that relate to it. You make a good point about needing to know what to look for and for this you use the compiler itself. The script editor in NWNs toolset lists every single function to the right and it even has a search bar. In this case I think youād search for words like āfollowā āmoveā and āspawnā and then look at the different functions you get and then look them up on NWLexicon.
4760 helped me with a script when trying to move an NPC that worked really well, but that was in NWN2, but I tried compiling the script in the NWN1 toolset and it compiled there too, maybe it would work for you
The script tries to move the NPC and if it doesnāt succeed it teleports the NPC there:
void ClearPendingActions(object oPerson, object oWP)
{
// just to make sure we're right on the spot
if (GetCurrentAction(oPerson) == ACTION_MOVETOPOINT)
{
//SendMessageToPC(GetFirstPC(), "Timing issue!");
AssignCommand(oPerson, ClearAllActions());
}
AssignCommand(oPerson, ActionJumpToLocation(GetLocation(oWP)));
}
void main()
{
object oNPC = (GetObjectByTag("npc"));
AssignCommand(oNPC , ClearAllActions());
DelayCommand(0.1, AssignCommand(oNPC,
ActionMoveToObject(GetNearestObjectByTag("waypoint"))));
DelayCommand(0.9, AssignCommand(oNPC, ClearPendingActions(oNPC,(GetNearestObjectByTag("waypoint")))));
}
One thing Iāve noticed in recent experimentation with creatures and following the PC, fleeing to an Exit waypoint (FLAG_ESCAPE_), or ActionMoveTo**** or ActionForceMoveTo****, etc:
Using SetAILevel() to set the AI level to AI_LEVEL_NORMAL or higher seems to GREATLY improve the AIās pathfinding capabilities.
For example, I have a group of slaves that once set free are supposed to flee to an exit WP and disappear. Despite using the OnHeartbeat to keep calling ActionForceMoveToLocation(), sometimes they would get stuck. Once I set the AI level to AI_LEVEL_NORMAL, they stopped getting stuck and have so far been able to find the exit in over a half-dozen consecutive tests.