You are on page 1of 3

How Do I Make My NPC Attack The PC He Is Talking To?

Intended Audience:
By David Gaider
[Printer Friendly / Syntax Highlight]
You want to add a script that makes the NPC go hostile. Place the script in the 'Actions
Taken' tab down on the bottom right of the dialogue editor... make sure you have the node
selected where you want the battle to begin.
If you want the NPC's faction to become hostile against the target, use the generic script
"nw_d1_attonend":
NWScript:
--------------------//::///////////////////////////////////////////////
//:: Attack on End of Conversation
//:: NW_D1_AttOnEnd
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
This script makes an NPC attack the person
they are currently talking with.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Nov 7, 2001
//:://////////////////////////////////////////////
#include "NW_I0_GENERIC"
void main()
{
AdjustReputation(GetPCSpeaker(), OBJECT_SELF, -100);
DetermineCombatRound();
}
-------------------------------

If, however, you just want the sole NPC to become hostile and attack, use the generic
script "nw_d1_attonend02":
NWScript:
-------------------------

//There are several different scripts that make NPCs or their entire factions attack the PC.
Scripts from NWN2, as well as scripts from NWN1 that still work. //In script assist
search for att and attack
//::///////////////////////////////////////////////
//:: Attack on End of Conversation
//:: NW_D1_AttOnEnd02
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
This script makes an NPC attack the person
they are currently talking with. This will
only make the single character hostile not
their entire faction.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Nov 7, 2001
//:://////////////////////////////////////////////
#include "NW_I0_GENERIC"
void main()
{
SetIsTemporaryEnemy(GetPCSpeaker());
DetermineCombatRound(); //didnt see this function in NWN2 script assist, but there
is this NW_D1_AttOnEnd script, and it works.
}
----------------------------One thing to beware of: if you apply this script to the actual node where the NPC is
speaking, they will go hostile right as the dialogue of that node is put up. Likely the NPC
will not have time to read it all if it is a long piece of dialogue.
If you are OK with that, great. If not, use the Add button on the last NPC node to add a
PC response. Erase the text in the PC response and press Enter... it should become an
'End Dialogue' node. Add the script to the 'Actions Taken' area for the End Dialogue,
instead. This way, the player can read the dialogue the NPC is speaking... and when he
presses 'Enter to Continue', the NPC will attack.
COMMON PROBLEMS: Make sure that a creature you want to go into combat does not
have levels in Commoner. Commoners are set up by the generic AI to run away from
hostiles and only form into a mob when there is both a level 10+ Commoner nearby.
Also make sure that if you are using the 'Special Behaviors' in the OnSpawn script (one
of the special behavior command lines is uncommented) that you are not using the
'Herbivore' behavior. Herbivores also never engage in combat and will always run away.

My notes:
//There are several different scripts that make NPCs or their entire factions attack the PC.
Scripts from NWN2, as well as scripts from NWN1 that still work
//In script assist search for att and attack
//For some reason, script for making single NPC hostile didnt work so far; Script that
makes NPCs entire faction did work.
//ga_attack gives option to change NPC to standard hostile faction or not.
-When chosen not, the NPC doesnt become hostile(altough he should); ---And when chosen to change his faction, he will become hostile to PC, but also to the
members of his own faction ++//nw_d1_attonend makes entire NPCs faction hostile to PC. It worked +++ (but its not
a good idea to make whole Defender, or Commoner, or Merchant, etc. factions hostile to
you)
//nw_d1_attonend02 makes only single NPC hostile to PC Didnt work so far ---Not wise to make a defender or commoner or merchant faction hostile to the PC,
because then all the members of that faction, even in other areas, will become hostile to
the PC.
Better is to change NPCs faction to Hostile. I could also make a separate faction just for
purposes of putting in it NPCs or groups of NPCs in it if i want to make them hostile to
PC, and i can choose will they be neutral, hostile, or friendly to other factions in the
faction editor.

You might also like