Simple questions (I hope) regarding srcitpting

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.

  1. Tell him to go home alone
  2. Tell him to follow the PC
  3. 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?

This time I will really try to figure this out!

Before I start here are a few links to stuff you’ll find useful.-

So if you can post what non-working code you’ve got we can probably help you better.

Local variables (not variant). You can use those to determine which branch of a conversation as well.

TR

Thank you for the link, Tarot.

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.

  1. 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?

void main()
{
object oPC = GetPCSpeaker();
ActionMoveToObject(GetObjectByTag(“home”));
}

  1. 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.

Re.

void main()
{
    object oPC = GetPCSpeaker();
    ActionMoveToObject(GetObjectByTag(“home”));
}

try

void main()
{
    object oPC = GetPCSpeaker();
    ActionForceMoveToObject(GetObjectByTag(“home”));
}

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.

Hope that helps.

TR

1 Like

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")))));


}

NWN already has a similar function:

ActionForceMoveToObject

Which I already mentioned around about post 4 in this thread :smiley_cat: .

TR

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.

Thank you all (and Tarot especially). I would have answered quicker, but you know Christmas stuff got in the way. I got it to work.

1 Like