The Crimson Keep Forum :: Neverwinter Nights :: Script Archives ~ Runboard
Community logo

Greetings from The Crimson Keep. If you would like to contact the Keep via email, click Here. If you need a good search engine ( powered by Ask Jeeves ) please consider using this one, Dogs Trust. Everytime it is used, money will be automatically donated to a good cause at no expense to you, thankyou.
The Crimson Keep Forum
 Neverwinter Nights
  Script Archives
Support
Search
RSS

runboard.com       Sign up (learn about it) | Sign in (lost password?)


Page:  1  2 

 
Demortia
Head Administrator
Global user

Registered: 11-2004
Location: UK
Posts: 434
Avatar
Reply | Quote
posticon Script Archives


Starting a script from scratch is a right pain, especially when a particular script has already been written but has been lost.
So a script archive comes in extremely handy as a library and reference for a large number of scripts carrying out complex functions.

This thread permits only posts containing NWN Scripts or modifications to existing scripts ( due to a large number of ways the same functions can be scripted, theres always more efficient ways to do things ).

Last edited by Demortia, 8/1/2008, 12:01 pm


---
Image
A Guest once said to me "Oh I like Roleplaying, I just dont like it when people stand around pretending to be Vampires!"
8/1/2008, 12:01 pm Send Email to Demortia MSN
 
Demortia
Head Administrator
Global user

Registered: 11-2004
Location: UK
Posts: 434
Avatar
Reply | Quote
Enviromental Effects Script


This ( simplified )Enviromental Effects script should be placed in the "heartbeat" entry of the "Invisible Object" which is them placed somewhere in the middle of a particular outdoor area.

This script in its current state will simulate the effects of sunlight upon any Character that has its subrace entry as "Undead" ( case sensitive )

Where this function shows "if (GetDistanceBetween(oPC,oFX) > 160.0)" the number can be reduced or increased depending on the size of the current outdoor area.

If you dont want the nighttime diseased vapours effect then the "Nighttime" check section of the script can be deleted ( very carefully )


//Enviromental Effects Heartbeat//
//Place on Heartbeat Entry of Invisible Object//
object oFX = OBJECT_SELF;

void main()
{

//Scan for PC's in the area.//
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
if (!GetIsPC(oPC))
    {
    oPC = GetNextPC();
    }

if (GetDistanceBetween(oPC,oFX) > 160.0)
    {
    oPC = GetNextPC();
    }

//Check Distance between PC and Enviroment FX Placable//
if (GetDistanceBetween(oPC,oFX) < 160.0)
    {

    //Daytime Check//
    if (GetIsDay())
        {
        if (GetSubRace(oPC)!="Undead") return;

        effect eEffect;
        eEffect = EffectDamage(10, DAMAGE_TYPE_FIRE, DAMAGE_POWER_NORMAL);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);
        object oTarget;
        oTarget = oPC;

        int nInt;
        nInt = GetObjectType(oTarget);
        if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_FIRE), oTarget);
        else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_FIRE), GetLocation(oTarget));
        }

//end of daytime checks//

    //Nighttime Checks//
if (GetIsNight())
        {

        if (GetSubRace(oPC)=="Undead") return;
        if (!GetIsPC(oPC)) return;
        if (d100()>12) return;

        object oTarget;
        oTarget = oPC;
        effect eEffect;
        eEffect = EffectDisease(DISEASE_GHOUL_ROT);
        ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);
        SendMessageToPC(oPC, "The foul vapours in the night air make you feel weakened and ill.");
        }
//end of nighttime checks//

}

if (GetDistanceBetween(oPC,oFX) > 160.0) return;
}



----------------------------------------

The following script contains ONLY the daytime checks for Undead.


//Enviromental Effects Heartbeat//
//Place on Heartbeat Entry of Invisible Object//
object oFX = OBJECT_SELF;

void main()
{

//Scan for PC's in the area.//
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
if (!GetIsPC(oPC))
    {
    oPC = GetNextPC();
    }

if (GetDistanceBetween(oPC,oFX) > 160.0)
    {
    oPC = GetNextPC();
    }

//Check Distance between PC and Enviroment FX Placable//
if (GetDistanceBetween(oPC,oFX) < 160.0)
    {

    //Daytime Check//
    if (GetIsDay())
        {
        if (GetSubRace(oPC)!="Undead") return;

        effect eEffect;
        eEffect = EffectDamage(10, DAMAGE_TYPE_FIRE, DAMAGE_POWER_NORMAL);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);
        object oTarget;
        oTarget = oPC;

        int nInt;
        nInt = GetObjectType(oTarget);
        if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_FIRE), oTarget);
        else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_FIRE), GetLocation(oTarget));
        }

//end of daytime checks//



}

if (GetDistanceBetween(oPC,oFX) > 160.0) return;
}




Last edited by Demortia, 8/1/2008, 1:13 pm


---
Image
A Guest once said to me "Oh I like Roleplaying, I just dont like it when people stand around pretending to be Vampires!"
8/1/2008, 12:10 pm Send Email to Demortia MSN
 
Demortia
Head Administrator
Global user

Registered: 11-2004
Location: UK
Posts: 434
Avatar
Reply | Quote
Enviromental Effects : Holy Ground


This script causes undead to be injured when setting foot in any place deemed as holy ground ( inside a church or a consecrated cemetary for example )
it works in a similar way to the Enviromental script above but has been modified to only apply to Undead.

(All heartbeat scripts fire once every 5 to 10 seconds ( depending on PC speeds ) so the effect is continual until the character leaves the area or leaved the search radius of the script, current set at 160.


//Enviromental Effects Heartbeat//
//Place on Heartbeat Entry of Invisible Object//
object oFX = OBJECT_SELF;

void main()
{

//Scan for PC's in the area.//
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
if (!GetIsPC(oPC))
    {
    oPC = GetNextPC();
    }

if (GetSubRace(oPC)!="Undead") return;

if (GetDistanceBetween(oPC,oFX) > 160.0)
    {
    oPC = GetNextPC();
    }

//Check Distance between PC and Enviroment FX Placable//
if (GetDistanceBetween(oPC,oFX) < 160.0)
    {

    effect eEffect;
    eEffect = EffectDamage(25, DAMAGE_TYPE_FIRE, DAMAGE_POWER_NORMAL);
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oPC);

    object oTarget;
    oTarget = oPC;

    int nInt;
    nInt = GetObjectType(oTarget);

    if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_FIRE), oTarget);
    else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_FIRE), GetLocation(oTarget));

    SendMessageToPC(oPC, "Setting foot on Holy Ground is not a good idea.");

    }

if (GetDistanceBetween(oPC,oFX) > 160.0) return;
}



Last edited by Demortia, 8/1/2008, 1:14 pm


---
Image
A Guest once said to me "Oh I like Roleplaying, I just dont like it when people stand around pretending to be Vampires!"
8/1/2008, 12:17 pm Send Email to Demortia MSN
 
Demortia
Head Administrator
Global user

Registered: 11-2004
Location: UK
Posts: 434
Avatar
Reply | Quote
Door Night-Lock


This is extremely handy when you want shops or other places to close at night ( can be altered to specific times of the day or night )

A very simple and short script, should be placed on a doors "heartbeat" entry.
The door should also be flagged as "Locked", "Can be re-locked" and the "Key Required" should be set to something like "Null-Key"


//OnHeartbeat. Door locks at Night, unlocks at Day.
void main()

{
if (GetIsNight())
   {
   ActionCloseDoor(OBJECT_SELF);
   SetLocked(OBJECT_SELF, TRUE);
   }


else
   {
   SetLocked(OBJECT_SELF, FALSE);
   }

}


---
Image
A Guest once said to me "Oh I like Roleplaying, I just dont like it when people stand around pretending to be Vampires!"
8/1/2008, 12:21 pm Send Email to Demortia MSN
 
Demortia
Head Administrator
Global user

Registered: 11-2004
Location: UK
Posts: 434
Avatar
Reply | Quote
Auto Closing Doors


Setting doors to close themselves after a period of time keeps the place looking tidy. Often, people are just too damn lazy to close doors behind them.
The value given in the "DelayCommand(20.0, ActionCloseDoor" section ( currently 20.0 ) can be increased or decreased to change the length of time after the door is opened that it closed itself.

This script should be placed on the "On Open" section of the door scripts.



//OnOpen : Auto closes doors after a short delay
void main()
{
object oPC = GetLastUsedBy();
if (!GetIsPC(oPC)) return;
DelayCommand(20.0, ActionCloseDoor(OBJECT_SELF));
}




Last edited by Demortia, 8/1/2008, 12:36 pm


---
Image
A Guest once said to me "Oh I like Roleplaying, I just dont like it when people stand around pretending to be Vampires!"
8/1/2008, 12:24 pm Send Email to Demortia MSN
 
Demortia
Head Administrator
Global user

Registered: 11-2004
Location: UK
Posts: 434
Avatar
Reply | Quote
Creature Death effects


if you want a really cool effect when a creature is killed, put this in its "On Death" script section.
The effect resembles the soul escaping from the corpse and heading skyward accompanied by a roaring whooshing sound.


// Create Death visual effect when creature dies
void main()

{
object oTarget;
oTarget = OBJECT_SELF;
int nInt;
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_DEATH), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_DEATH), GetLocation(oTarget));
}


Last edited by Demortia, 8/1/2008, 12:35 pm


---
Image
A Guest once said to me "Oh I like Roleplaying, I just dont like it when people stand around pretending to be Vampires!"
8/1/2008, 12:26 pm Send Email to Demortia MSN
 
Demortia
Head Administrator
Global user

Registered: 11-2004
Location: UK
Posts: 434
Avatar
Reply | Quote
Food usable by living characters, no effect for undead.


Food items apply a gradual regeneration effect that last a specific ammount of time. In reality, eating food does not instantly heal a person, so I figured that a gradual affect is much more relistic.

This is a Unique Item script. You will need to add this small piece of script to your Module "OnActivateItem" script entry.


void main()

{
ExecuteScript(GetTag(GetItemActivated()),
OBJECT_SELF);
}


Now you can make the food item as something like Fish or a Leg of Ham, anything like that.
Apply the "Cast Spell : Unique power Self Only (Single Use)" property, flag as "Identified"

Now add this script via the script editor but the script MUST BE named the same as the food item Tag.


// Applies the regenerative effect of eating food : Meat
void main()

{
object oPC;
if (!GetIsPC(GetItemActivatedTarget()))
{
SendMessageToPC(GetItemActivator(), "This item cannot be used this way.");
return;}
oPC = GetItemActivator();
object oTarget;
oTarget = oPC;

if (GetSubRace(oPC)=="Undead")
   {
   SendMessageToPC(oPC, "This item has no effect on the Undead!");
   return;
   }

effect eEffect;
eEffect = EffectRegenerate(1, 1.0f);
eEffect = SupernaturalEffect(eEffect);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 30.0f);

}




Last edited by Demortia, 8/1/2008, 1:15 pm


---
Image
A Guest once said to me "Oh I like Roleplaying, I just dont like it when people stand around pretending to be Vampires!"
8/1/2008, 12:35 pm Send Email to Demortia MSN
 
Demortia
Head Administrator
Global user

Registered: 11-2004
Location: UK
Posts: 434
Avatar
Reply | Quote
Witch Finders & Random Phrase Speaking NPC's


This is the script I use for the Witch Finders in the Dunwich Module. If can easily be modified to be placed on any NPC to enable them to randomly speak lines as if they are having a conversation with another NPC.

This script should be placed in the NPC's "Heartbeat" entry



#include "nw_i0_generic"
object oTarget;

void main()
{
// If we have the 'constant' waypoints flag set, walk to the next
// waypoint.
    if ( GetWalkCondition(NW_WALK_FLAG_CONSTANT) )
    {
        WalkWayPoints();
    }

//Witch Finders Heartbeat Script.

object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
if (IsInConversation(OBJECT_SELF) || GetIsInCombat()) return;

//Unequip any weapons.
ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND));

//This part gives the Witch Finder a random chance of discovering
//any Sorcerer class and will attack them after a short delay

if ((GetLevelByClass(CLASS_TYPE_SORCERER, oPC)>0))
    {
    if (d100()<=10)
        {
        ActionSpeakString("Thou hast been discovered! Thou art an agent of Lucifer and must die!");
        ActionPlayAnimation(ANIMATION_LOOPING_TALK_FORCEFUL, 1.0f, 2.0f);
        oTarget = OBJECT_SELF;
        DelayCommand(3.0, SetIsTemporaryEnemy(oPC, oTarget));
        DelayCommand(3.0, ActionAttack(oPC));
        DelayCommand(3.0, DetermineCombatRound(oPC));
        }
    }

//This part makes the Witch Finder speak random phrases.

if (d100()>40) return;

    int nInt;
    nInt = d6();

if (nInt==1)
   {
   ActionSpeakString("Heed my words, there be witches among thy number!");
   ActionPlayAnimation(ANIMATION_LOOPING_TALK_FORCEFUL, 1.0f, 2.0f);
   }

if (nInt==2)
   {
   ActionSpeakString("Who of thou art ye spawn of Lucifer? Thou cannot hide!");
   ActionPlayAnimation(ANIMATION_LOOPING_TALK_FORCEFUL, 1.0f, 2.0f);
   }

if (nInt==3)
   {
   ActionSpeakString("Look to god to redeem thy soul lest thou burn in ye eternal fires of hell");
   ActionPlayAnimation(ANIMATION_LOOPING_TALK_FORCEFUL, 1.0f, 2.0f);
   }

if (nInt==4)
   {
   ActionSpeakString("This place is beset by evil on all sides, join ye holy cause and redeem thy soul!");
   ActionPlayAnimation(ANIMATION_LOOPING_TALK_FORCEFUL, 1.0f, 2.0f);
   }

if (nInt==5)
   {
   ActionSpeakString("Denounce ye wicked and thy soul will be saved!");
   ActionPlayAnimation(ANIMATION_LOOPING_TALK_FORCEFUL, 1.0f, 2.0f);
   }

if (nInt==6)
   {
   ActionSpeakString("Ye agents of Lucifer are all around us!");
   ActionPlayAnimation(ANIMATION_LOOPING_TALK_FORCEFUL, 1.0f, 2.0f);
   }

}



---------------------------------------


The following script is generic to any NPC you might wish to have speak random phrases. Simply paste the script into the NPC "Heartbeat" and type whatver phrases you wish the NPC to say in the relevant places.



#include "nw_i0_generic"
object oTarget;

void main()
{
// If we have the 'constant' waypoints flag set, walk to the next
// waypoint.
    if ( GetWalkCondition(NW_WALK_FLAG_CONSTANT) )
    {
        WalkWayPoints();
    }

object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
if (IsInConversation(OBJECT_SELF) || GetIsInCombat()) return;

//Unequip any weapons.
ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND));

//This part makes the NPC speak random phrases.

if (d100()>40) return;

    int nInt;
    nInt = d6();

if (nInt==1)
   {
   ActionSpeakString("Phrase 1, type your phrase here!");
   }

if (nInt==2)
   {
   ActionSpeakString("Phrase 2, type your phrase here!");
   }

if (nInt==3)
   {
   ActionSpeakString("Phrase 3, type your phrase here!");
   
   }

if (nInt==4)
   {
   ActionSpeakString("Phrase 4, type your phrase here!");
   }

if (nInt==5)
   {
   ActionSpeakString("Phrase 5, type your phrase here!");
   }

if (nInt==6)
   {
   ActionSpeakString("Phrase 6, type your phrase here!");
   }

}



Last edited by Demortia, 8/1/2008, 1:22 pm


---
Image
A Guest once said to me "Oh I like Roleplaying, I just dont like it when people stand around pretending to be Vampires!"
8/1/2008, 12:40 pm Send Email to Demortia MSN
 
Demortia
Head Administrator
Global user

Registered: 11-2004
Location: UK
Posts: 434
Avatar
Reply | Quote
Module Timekeeper


One of the most annoying bugs that happens only when a module contains a lot of custom resources and scripts is time skipping.

You'll know it happens when the clock seems to freeze for a long time, then suddenly starts, plunging day into instant night or vice versa.

This happens because the game clock is given a low CPU priority. Theres a solution though, add this script to the Modules Heartbeat entry and the problem is solved


void main()
{
    SetTime(GetTimeHour(), GetTimeMinute(), GetTimeSecond(), GetTimeMillisecond());
}


---
Image
A Guest once said to me "Oh I like Roleplaying, I just dont like it when people stand around pretending to be Vampires!"
8/1/2008, 12:47 pm Send Email to Demortia MSN
 
Demortia
Head Administrator
Global user

Registered: 11-2004
Location: UK
Posts: 434
Avatar
Reply | Quote
Changing a Characters Appearence (Ghast)


This should be used as part of an "OOC" NPC conversation somewhere in a location that is considered OOC.
With the Dunwich Module, the starting place is the Module Lobby, where players can gather and talk OOC and learn about the Module from various OOC NPC's.

This script should be placed in the "On Actions Taken" section of a conversation and will change the characters appearence to that of an undead creature. The creature appearence can be changed to any from within the game if you know the correct reference tag.


//action taken : Morphs Character into a Ghast and sets
//Sub-Race as Undead.
void main()

{
object oPC = GetPCSpeaker();
SetSubRace(oPC, "Undead");
object oTarget;
oTarget = oPC;
SetCreatureAppearanceType(oTarget, APPEARANCE_TYPE_GHAST);
//SetPortraitResRef(oTarget, "po_ghast_");
//changing the characters portrait has been
//removed due to certain problems arrising
//when the player wishing to revert back to
//human.
}


---
Image
A Guest once said to me "Oh I like Roleplaying, I just dont like it when people stand around pretending to be Vampires!"
8/1/2008, 12:52 pm Send Email to Demortia MSN
 


Add a reply

Page:  1  2 






Link to us   -  Blogs   -  Hall of Honour   -  Chat
You are not logged in (login)      Board's time is: 11/30/2009, 4:10 am