Justin (jwendl) wrote in nwnscripts,
Justin
jwendl
nwnscripts

  • Mood:
  • Music:

A warm welcome

I would like to welcome people to my community. I created this as a place for people who are building NWN modules to discuss code, design, and other in depth topics of world building with Neverwinter Nights.

To start it out so people get a feel of things, I created a script to allow for the players to kill NPC's and yet maintain a persistant world. I dubbed it the PriestofPelor script.


Place in NPC's ondeath event

// onnpcdeath()
//
// Created by: Justin (jwendl@hotmail.com)
//
// Summons Priest to Ressurrect NPC
// Adjusts Alignment for killing NPC
//
/////////////////////////////////////

#include "NW_I0_GENERIC"
void ClearAllFactionMembers(object oMember, object oPlayer);
void main()
{
    int nClass = GetLevelByClass(CLASS_TYPE_COMMONER);
    int nAlign = GetAlignmentGoodEvil(OBJECT_SELF);
    object oKiller = GetLastKiller();
    AdjustAlignment(oKiller, ALIGNMENT_EVIL, 5);
    AdjustReputation(oKiller, OBJECT_SELF, 50);
    ClearAllFactionMembers(OBJECT_SELF, oKiller);
    object oArea = GetArea(OBJECT_SELF);
    vector vMyVec = GetPosition(OBJECT_SELF) + Vector(1.5, 0.0);
    location lDead = Location(oArea, vMyVec, DIRECTION_WEST);
    CreateObject(OBJECT_TYPE_CREATURE, "PriestofPelor", lDead, TRUE);
    SetLocalString(GetModule(), "Dead", GetTag(OBJECT_SELF));
}
void ClearAllFactionMembers (object oMember, object oPlayer)
{
    object oClear = GetFirstFactionMember (oMember, FALSE);
    while (GetIsObjectValid(oClear) == TRUE)
    {
        ClearPersonalReputation(oPlayer, oClear);
        oClear = GetNextFactionMember(oMember, FALSE);
    }
}


Place in NPC's onspawn event

// onnpcspawn()
//
// Created by: Justin (jwendl@hotmail.com)
//
// Causes NPC's body to stay on death
//
/////////////////////////////////////

void main()
{
    ActionDoCommand(SetIsDestroyable(FALSE, TRUE, FALSE));
}


Now you need to create an NPC priest that will be the priest that teleports in (remember the tag I called mine priest of pelor)

PriestofPelor onspawn event
// onpriestspawn()
//
// Created by: Justin (jwendl@hotmail.com)
//
// Gives Priest Action to Res NPC
//
/////////////////////////////////////

void main()
{
    object oDead = GetObjectByTag(GetLocalString(GetModule(), "Dead"), 0);
    DelayCommand(5.0, ActionCastSpellAtObject(SPELL_RESURRECTION, oDead, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, FALSE));
    DelayCommand(10.0, ActionCastFakeSpellAtObject(SPELL_ETHEREAL_VISAGE, OBJECT_SELF, PROJECTILE_PATH_TYPE_DEFAULT));
    DestroyObject(OBJECT_SELF, 12.0);
}




So there ya are. When an NPC dies the priest "teleports" in casts ressurection on the NPC and "teleports" out.
Subscribe
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments