#include "inc_misc_tools"
/*
This script handles a PC attemping to break in a door (STR Check).
The DC of this door is the Fortitude Save of the Door + the party average level.
This will mean that as PCs progress it will be harder and harder to bash open
the doors on the first try.

If the door is NOT bashed open on the first try the door notifies all nearby
monsters of the PCs beating on the door.

If the door is bashed on the first attempt the monsters will be none the wiser.

An unlocked door will be immediately opened with no check.
*/
void main()
    {
    if (GetPlotFlag())
        return;
    object oDoor = OBJECT_SELF;
    object oAttacker = GetLastAttacker();
    object oWeapon = GetLastWeaponUsed(oAttacker);
    int iDC,iRoll,iPassed;
    string sDC,sRoll;
    if (!GetWeaponRanged(oWeapon) || oWeapon == OBJECT_INVALID)
        {
        if (GetLocked(oDoor))
            {
            iDC = GetLocalInt(oDoor,"Bash");
            if (!iDC)
                {
                iDC = GetFortitudeSavingThrow(OBJECT_SELF);
                SetLocalInt(oDoor,"Bash",iDC);
                }
            iRoll = AbilityCheck(oAttacker,ABILITY_STRENGTH,iDC);
            sRoll = IntToString(iRoll);
            sDC = IntToString(iDC);
            }
        else
            iRoll = TRUE;
        }
    if (iRoll)
        {
        SetLocked(oDoor,FALSE);
        ActionOpenDoor(oDoor);
        AssignCommand(oAttacker,ClearAllActions(TRUE));
        }
    else
        SpeakString("NW_I_WAS_ATTACKED", TALKVOLUME_SILENT_SHOUT);
    }
