Nwn 1 scripting hit placeable

NWN 1 scripting.

How would I go about getting an npc to attack a placeable and destroy it?
I can get the PC to attack it but the NPC(s) stand there?
Please help

Here’s an example (works for placeables, too):

// Break down door

void z100BreakDoor(string sNPC, string sDoor)
{
  object oNPC  = GetObjectByTag(sNPC);
  object oDoor = GetObjectByTag(sDoor);

  if (GetIsObjectValid(oDoor))
    {
      AssignCommand(oNPC, ActionAttack(oDoor));
      DelayCommand(2.0, z100BreakDoor(sNPC)); // Keep going until door broken down
    }
}

Ensure the object belongs to a different faction.

On reflection, it might be neater to make the delay 6 seconds (or use ActionDoCommand) so that there’s one command per round. This would prevent unnecessary command stacking in the case of a placeable with huge HP.

Just a suggestion. For such basic scripting challenges you can use CHAT GPT, it knows a bit about NWScript and should be able to code this for you and explain it.

I am not trying to say Proleric code is bad or anything nor that we won’t help you with scripts here. Just giving you alternative channel to get help.

I try and stay away from chat gpt as much as possible.
I’m a professional programmer. I just need some pointers on how the engine works. For example it’s my understanding a placeable cannot command a NPC. is this true.

FYI thxs for helping me.

I have some very similar to this and the NPC’s (henchman) just stand there.
Can a placeable command a NPC?

Can this is called as a placeable?

Sure it can. Any function can be called from any caller, just some are specifically seeded with information for a specific context (like OBJECT_SELF, GetEnteringObject() ) and problematic outside those use cases, or action assigning functions like SpeakString() or SetFacing() (which are accomplished with AssignCommand(object_to_assign_to, action_to_do) ).

What seems more likely is either the npc is already stuck in an action, or the command to attack object gets stuck in a loop pathing to the placeable. Putting a MoveToObject first may help, or may not, placeables depend on how they’re made and a creature may not be able to path to them well (i.e. the use node of the placeable is opposite the side they’re on).

It’s easy to tell an npc to do something, but sometimes hard (like here) to tell if they’re actually doing it.

Thank you. that is very helpful.

I have encountered cases where this fails.

It may be that all such cases can be resolved, given sufficient arcane insight into NWScript.

One simple solution, though, is for the placeable to do this:

AssignCommand(GetModule(), AssignCommand(oNPC, ClearAllActions(TRUE)));
AssignCommand(GetModule(), AssignCommand(oNPC, ...));

As a rule-of-thumb, it seems that the module will accept commands from any object, and any creature will accept commands from the module.

While not necessary in every case, it does no harm, and saves debugging time.

The snippet I originally posted was run by the module, as it happens.

It’s the clear actions part that’s important. Daz said internally actions aren’t as represented as discrete things, like ActionAttack will involve move to attack distance if needed, and a bunch of other things (which is why things often asked for like ClearCurrentAction aren’t simple things to do).

Another thing might be the script priority of the object (something like 2/3 or 3/4 of a frame goes to high priority things like module, players, areas while things like placeables or even low priority creatures from SetAILevel might be skipped). SP probably distinction without a difference, but busy MP is a consideration.

Then there’s things to not do like tell a placeable or some other object to close a door. Hopefully that one isn’t the crash bug it used to be :slight_smile: (Use playanimation to do this.)

Thank you for your help. I’m just getting into nwn.
Anyone wanna play a module with me? I’m rewriting s4 from vault it’s great but had problems! anyone wanna play?

Is it possible to command a NPC from placeable or should it be done from (module). i.e. one of you says one thing and other says different

What is SP and MP?
Script and module priority ?

It is possible, but, in my experience, it fails under some circumstances. The module route never fails.

1 Like

I think Single player and Multi-player

Thxs man

Have you isolated under what circumstances?

Here is another one for you guys.

I have a PC and NPC henchmen in party. I’d like to jump the npc to the ‘belly’ of a lurker for example and keep the NPC at original location. I know how to do all this, but I was wondering how do I keep the NPC at original location fighting the lurker for example? Don’t I have to raise the AI level?

No.

Given a reliable method and an unreliable method, there are choices:

  1. Use the reliable method
  2. Use the unreliable method but revert to the reliable method when it fails
  3. Test countless potential cases with the unreliable method to see whether there are general rules

I know where my time is best invested, though some people might have fun with option 3.

1 Like