Author Sticky: Post Working Scripts Here
CrushingBlow Posted: Monday, 29 July 01:11AM
This is my version of a door that can't be damaged by spells or weapons, but can still be bashed open based upon the 3rd Edition rules. Knock spells will also work on the door.

Place this script on a door's OnPhysicalAttacked. Set the door as a plot item. Set the fortitude save of the door for the DC to break open the door. Table 8-14 of the 3rd Edition Player's Handbook gives examples of this DC.

NWScript:
//::////////////////////////////

//:: bashable_door

//::////////////////////////////

//:: Created By: CrushingBlow

//:: Created On: 7/28/02

//::////////////////////////////

void main()

{

  object oDoor = OBJECT_SELF;

  object oAttacker = GetLastAttacker(oDoor);

  int nBreakDC = GetFortitudeSavingThrow(oDoor);

  int nStrength = GetAbilityModifier(ABILITY_STRENGTH, oAttacker);

  int nBash = d20(1); //Rolls the strength DC

  object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND ,oAttacker);

  int nWeapon = GetWeaponRanged(oItem);

  ActionWait(0.5);

  if (nWeapon == FALSE) //Can't bash door with ranged weapons

    {

    //Displays strength DC with modifiers

    ActionSpeakString("Bash Door: ("+IntToString(nBash)+" + "+IntToString(nStrength)+" = "+IntToString(nBash+nStrength)+")");

    if (nBash + nStrength >= nBreakDC)

      {

      //Unlocks and opens door if DC is successful

      SetLocked(oDoor, FALSE);

      ActionOpenDoor(oDoor);

      ActionDoCommand(AssignCommand(oAttacker, ClearAllActions()));

      }

    }

}



Next create a placeable item. Make sure it is not a plot item or static. The item's initial state can be destroyed if you do not want player's to see the item. Place the item behind the door, not close to any other doors, for the best effect. Place this script in the item's OnHeartbeat.

NWScript:
//::////////////////////////////

//:: knock_door

//::////////////////////////////

//:: Created By: CrushingBlow

//:: Created On: 7/28/02

//::////////////////////////////

void main()

{

  int nSpell = GetLastSpell();

  object oDoor = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF, 1);

  int nLocked = GetLocked(oDoor);

  SetLocked(OBJECT_SELF, nLocked);

  effect eKnock = EffectVisualEffect(VFX_IMP_KNOCK, FALSE);

  if (nSpell == SPELL_KNOCK && nLocked == TRUE)

    {

    SetLocked(oDoor, FALSE);

    ApplyEffectToObject(DURATION_TYPE_INSTANT, eKnock, oDoor, 0.0);

    }

}



Next we have to fix the knock spell so that it will show up when we use GetLastSpell(). We will have to edit the existing script nw_sO_knock. This is the full script with the addition of the SignalEvent command I added. This command will let the GetLastSpell() command the spell number.

NWScript:
//::///////////////////////////////////////////////

//:: Knock

//:: NW_S0_Knock

//:: Copyright (c) 2001 Bioware Corp.

//:://////////////////////////////////////////////

/*

    Opens doors not locked by magical means.

*/

//:://////////////////////////////////////////////

//:: Created By: Preston Watamaniuk

//:: Created On: Nov 29, 2001

//:://////////////////////////////////////////////

//:: Last Updated By: Preston Watamaniuk

//:: VFX Pass By: Preston W, On: June 22, 2001

#include "NW_I0_SPELLS"

void main()

{

    object oTarget;

    effect eVis = EffectVisualEffect(VFX_IMP_KNOCK);

    oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 50.0, GetLocation(OBJECT_SELF), FALSE, OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);

    float fDelay;

    while(GetIsObjectValid(oTarget))

    {

        fDelay = GetRandomDelay(0.5, 2.5);

        if(!GetPlotFlag(oTarget) && GetLocked(oTarget))

        {

            DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));

            SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_KNOCK));

            AssignCommand(oTarget, ActionUnlockObject(oTarget));

        }

        oTarget = GetNextObjectInShape(SHAPE_SPHERE, 50.0, GetLocation(OBJECT_SELF), FALSE, OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);

    }

}



I hope Bioware fixes the scripts for all of the spells as GetLastSpell() will not work on every spell.