NPC Heal Script
From NWNWiki
Contents |
[edit] Heal Script
[edit] What it does
heal NPCs of the same faction. For a cleric who walks a few waypoints. heal's other NPCs of the same faction if they see they are at X% hp. Once They have used up the healing spells, they rest before continuing walking and healing.
[edit] Note
Place it in the action tab of the conversation node you want the NPC to heal from
[edit] The Script
/*********************************
Script: NPC Healer
Created By: Jaden Wagener
Created On: 8/28/02
*********************************/
void main()
{
//Set the variables
object xPlayer = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
int xPlayerHP;
effect xPlayerHeal;
effect xHealVis = EffectVisualEffect(VFX_IMP_RESTORATION_GREATER);
//Set how much to heal
xPlayerHP = GetMaxHitPoints(xPlayer);
//Create the heal effect
xPlayerHeal = EffectHeal(xPlayerHP);
//Perform the heal and the effect
ApplyEffectToObject(DURATION_TYPE_INSTANT,xHealVis,xPlayer);
ApplyEffectToObject(DURATION_TYPE_INSTANT,xPlayerHeal,xPlayer);
}
[edit] Note
As for getting the NPC to go back to walking his waypoints, you need to put this...
nw_c2_default9
...in the Current File type Tab for each End Dialog node. The nw_c2_default9 script is the default OnSpawn. Just paste nw_c2_default9 into the Normal and Aborted box there in the Current File Tab.
The Current File Tab is last in the list of tabs
(Text Appears When, Actions Taken, Other Actions, Comments, and finally Current File).
Doing this will tell him to go about walking his points again, whenever the conversation ends.
