//::///////////////////////////////////////////////
//:: Placeable OnPhysicalAttacked Script
//:: plc_onattack.nss
//:://////////////////////////////////////////////
/*
Put into: Door's or Placeable's OnPhysicalAttacked Event
Emmulates PHB object bashing and breaking. The break DC
is equal to the object's FORT save. By default, if the
bash attempt fails, the object takes damage.
*/
//:://////////////////////////////////////////////
//:: Created By: Pstemarie
//:: Created On: July 14, 2011
//:://////////////////////////////////////////////
//:: 11-24-2011, Pstemarie: Added a variable check (MATERIAL_WOOD) for wooden
//:: doors to accomadate tileset doors that do not use the
//:: custom templates
void main()
{
// Declare major variables
object oAttacker = GetLastAttacker();
object oTarget = OBJECT_SELF;
// Abort if a "Plot" object
if (GetPlotFlag(oTarget))
{
// Feedback for PCs only
if (GetIsPC(oAttacker))
SendMessageToPC(oAttacker, "You cannot break the" +GetStringLowerCase(GetName(oTarget))+ ".");
return;
}
int nDC = GetFortitudeSavingThrow(oTarget);
// If no DC is assigned, give the default value
if (nDC = 0)
nDC = 20;
int nSize = GetCreatureSize(oAttacker);
int nRoll = d20(1);
int nMod = GetAbilityModifier(ABILITY_STRENGTH, oAttacker);
// DC for breaking locked wooden doors is at +2
if (GetLocked(oTarget) && ( GetStringLeft(GetResRef(oTarget),9) == "wooddoor_" || GetLocalInt(oTarget, "MATERIAL_WOOD") == 1) )
nDC += 2;
// If HP has been reduced to 50% or less then DC is at -2
if (GetCurrentHitPoints(oTarget) <= (GetMaxHitPoints(oTarget)/2))
nDC -= 2;
switch (nSize)
{
case CREATURE_SIZE_HUGE: nDC -= 8; break;
case CREATURE_SIZE_LARGE: nDC -= 4; break;
case CREATURE_SIZE_SMALL: nDC += 4; break;
case CREATURE_SIZE_TINY: nDC += 8; break;
}
if ((nRoll + nMod) >= nDC)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(GetCurrentHitPoints(oTarget)), oTarget);
// Feedback for PCs
if (GetIsPC(oAttacker))
SendMessageToPC(oAttacker, "The " +GetStringLowerCase(GetName(oTarget))+ " breaks apart.");
}
}