Note: The door ResRefs used in the first script come from my module. Just substitue the ResRefs with the ResRefs for any wooden door in your module. Alternatively, you could alter the line ot read a "Material" variable set on the door.
Yes, the scripts could be combined into one...
Door OnPhysicalAttackedEvent
//Door on Physical Attacked - Bashing Script
/*
Put this in a door's OnPhysicalAttacked Event to emulate pnp object
breaking.
You must check the set the variable "BreakDC" on the door.
By default, if the bash attempt fails then the object takes damage.
*/
void main()
{
object oAttacker = GetLastAttacker();
object oDoor = OBJECT_SELF;
//Abort if a "Plot" object
if (GetPlotFlag(oDoor))
{
SendMessageToPC(oAttacker, "You cannot break the" +GetStringLowerCase(GetName(oDoor))+ ".");
return;
}
int nDC = GetLocalInt(oDoor, "BreakDC");
//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(oDoor) && GetResRef(oDoor) == "dr_wood001" || GetResRef(oDoor) == "dr_wood002" || GetResRef(oDoor) == "dr_wood003")
nDC = nDC +2;
if (GetCurrentHitPoints(oDoor) <= (GetMaxHitPoints(oDoor)/2))
nDC = nDC -2;
switch (nSize)
{
case CREATURE_SIZE_HUGE: nDC = nDC -8; break;
case CREATURE_SIZE_LARGE: nDC = nDC -4; break;
case CREATURE_SIZE_SMALL: nDC = nDC +4; break;
case CREATURE_SIZE_TINY: nDC = nDC +8; break;
}
if ((nRoll + nMod) >= nDC)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(GetCurrentHitPoints(oDoor)), oDoor);
SendMessageToPC(oAttacker, "The " +GetStringLowerCase(GetName(oDoor))+ " breaks apart.");
}
}
Placeable OnPhysicalAttacked Event
//Placeable on Physical Attacked - Bashing Script
/*
Put this in a placeable's OnPhysicalAttacked Event to emulate pnp object
breaking.
You must check the "Useable" flag and set the variable "BreakDC" on the
placeable.
By default, if the bash attempt fails then the object takes damage.
*/
void main()
{
object oAttacker = GetLastAttacker();
object oDoor = OBJECT_SELF;
//Abort if a "Plot" object
if (GetPlotFlag(oDoor))
{
SendMessageToPC(oAttacker, "You cannot break the" +GetStringLowerCase(GetName(oDoor))+ ".");
return;
}
int nDC = GetLocalInt(oDoor, "BreakDC");
//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);
if (GetCurrentHitPoints(oDoor) <= (GetMaxHitPoints(oDoor)/2))
nDC = nDC -2;
switch (nSize)
{
case CREATURE_SIZE_HUGE: nDC = nDC -8; break;
case CREATURE_SIZE_LARGE: nDC = nDC -4; break;
case CREATURE_SIZE_SMALL: nDC = nDC +4; break;
case CREATURE_SIZE_TINY: nDC = nDC +8; break;
}
if ((nRoll + nMod) >= nDC)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(GetCurrentHitPoints(oDoor)), oDoor);
SendMessageToPC(oAttacker, "The " +GetStringLowerCase(GetName(oDoor))+ " breaks apart.");
}
}
Modifié par Pstemarie, 02 juillet 2011 - 05:43 .





Retour en haut






