If using the Bioware Treasure Scripts (or a variation of them as I do), then you can use the OnClosed Event to generate a random trap and even set random DCs and random unlock DCs. Here's an example of one I did for fixed placeables awhile back:
void main()
{
if (GetLocalInt(OBJECT_SELF,"CHEST")== 1) return;
SetLocalInt(OBJECT_SELF,"CHEST",1);
DelayCommand(604.0, SetLocked(OBJECT_SELF, TRUE));
DelayCommand(604.0, SetLockUnlockDC(OBJECT_SELF,25+d12()));
int nInt;
nInt = d10();
object oTarget;
oTarget = (OBJECT_SELF);
if (nInt==1)
{
DelayCommand(606.0, CreateTrapOnObject(TRAP_BASE_TYPE_STRONG_ACID, oTarget, STANDARD_FACTION_HOSTILE, "", ""));
DelayCommand(607.0, SetTrapActive(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDisarmable(oTarget, TRUE));
DelayCommand(607.0, SetTrapOneShot(oTarget, TRUE));
DelayCommand(607.0, SetTrapRecoverable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectDC(oTarget, 15+d12()));
DelayCommand(607.0, SetTrapDisarmDC(oTarget, 25+d12()));
DelayCommand(610.0, SetLocalInt(OBJECT_SELF,"CHEST",0));
}
else if (nInt==2)
{
DelayCommand(606.0, CreateTrapOnObject(TRAP_BASE_TYPE_STRONG_ELECTRICAL, oTarget, STANDARD_FACTION_HOSTILE, "", ""));
DelayCommand(607.0, SetTrapActive(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDisarmable(oTarget, TRUE));
DelayCommand(607.0, SetTrapOneShot(oTarget, TRUE));
DelayCommand(607.0, SetTrapRecoverable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectDC(oTarget, 15+d12()));
DelayCommand(607.0, SetTrapDisarmDC(oTarget, 25+d12()));
DelayCommand(610.0, SetLocalInt(OBJECT_SELF,"CHEST",0));
}
else if (nInt==3)
{
DelayCommand(606.0, CreateTrapOnObject(TRAP_BASE_TYPE_STRONG_FIRE, oTarget, STANDARD_FACTION_HOSTILE, "", ""));
DelayCommand(607.0, SetTrapActive(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDisarmable(oTarget, TRUE));
DelayCommand(607.0, SetTrapOneShot(oTarget, TRUE));
DelayCommand(607.0, SetTrapRecoverable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectDC(oTarget, 15+d12()));
DelayCommand(607.0, SetTrapDisarmDC(oTarget, 25+d12()));
DelayCommand(610.0, SetLocalInt(OBJECT_SELF,"CHEST",0));
}
else if (nInt==4)
{
DelayCommand(606.0, CreateTrapOnObject(TRAP_BASE_TYPE_STRONG_FROST, oTarget, STANDARD_FACTION_HOSTILE, "", ""));
DelayCommand(607.0, SetTrapActive(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDisarmable(oTarget, TRUE));
DelayCommand(607.0, SetTrapOneShot(oTarget, TRUE));
DelayCommand(607.0, SetTrapRecoverable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectDC(oTarget, 15+d12()));
DelayCommand(607.0, SetTrapDisarmDC(oTarget, 25+d12()));
DelayCommand(610.0, SetLocalInt(OBJECT_SELF,"CHEST",0));
}
else if (nInt==5)
{
DelayCommand(606.0, CreateTrapOnObject(TRAP_BASE_TYPE_STRONG_GAS, oTarget, STANDARD_FACTION_HOSTILE, "", ""));
DelayCommand(607.0, SetTrapActive(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDisarmable(oTarget, TRUE));
DelayCommand(607.0, SetTrapOneShot(oTarget, TRUE));
DelayCommand(607.0, SetTrapRecoverable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectDC(oTarget, 15+d12()));
DelayCommand(607.0, SetTrapDisarmDC(oTarget, 25+d12()));
DelayCommand(610.0, SetLocalInt(OBJECT_SELF,"CHEST",0));
}
else if (nInt==6)
{
DelayCommand(606.0, CreateTrapOnObject(TRAP_BASE_TYPE_STRONG_HOLY, oTarget, STANDARD_FACTION_HOSTILE, "", ""));
DelayCommand(607.0, SetTrapActive(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDisarmable(oTarget, TRUE));
DelayCommand(607.0, SetTrapOneShot(oTarget, TRUE));
DelayCommand(607.0, SetTrapRecoverable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectDC(oTarget, 15+d12()));
DelayCommand(607.0, SetTrapDisarmDC(oTarget, 25+d12()));
DelayCommand(610.0, SetLocalInt(OBJECT_SELF,"CHEST",0));
}
else if (nInt==7)
{
DelayCommand(606.0, CreateTrapOnObject(TRAP_BASE_TYPE_STRONG_NEGATIVE, oTarget, STANDARD_FACTION_HOSTILE, "", ""));
DelayCommand(607.0, SetTrapActive(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDisarmable(oTarget, TRUE));
DelayCommand(607.0, SetTrapOneShot(oTarget, TRUE));
DelayCommand(607.0, SetTrapRecoverable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectDC(oTarget, 15+d12()));
DelayCommand(607.0, SetTrapDisarmDC(oTarget, 25+d12()));
DelayCommand(610.0, SetLocalInt(OBJECT_SELF,"CHEST",0));
}
else if (nInt==8)
{
DelayCommand(606.0, CreateTrapOnObject(TRAP_BASE_TYPE_STRONG_SONIC, oTarget, STANDARD_FACTION_HOSTILE, "", ""));
DelayCommand(607.0, SetTrapActive(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDisarmable(oTarget, TRUE));
DelayCommand(607.0, SetTrapOneShot(oTarget, TRUE));
DelayCommand(607.0, SetTrapRecoverable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectDC(oTarget, 15+d12()));
DelayCommand(607.0, SetTrapDisarmDC(oTarget, 25+d12()));
DelayCommand(610.0, SetLocalInt(OBJECT_SELF,"CHEST",0));
}
else if (nInt==9)
{
DelayCommand(606.0, CreateTrapOnObject(TRAP_BASE_TYPE_STRONG_SPIKE, oTarget, STANDARD_FACTION_HOSTILE, "", ""));
DelayCommand(607.0, SetTrapActive(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDisarmable(oTarget, TRUE));
DelayCommand(607.0, SetTrapOneShot(oTarget, TRUE));
DelayCommand(607.0, SetTrapRecoverable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectDC(oTarget, 15+d12()));
DelayCommand(607.0, SetTrapDisarmDC(oTarget, 25+d12()));
DelayCommand(610.0, SetLocalInt(OBJECT_SELF,"CHEST",0));
}
else if (nInt==10)
{
DelayCommand(606.0, CreateTrapOnObject(TRAP_BASE_TYPE_STRONG_TANGLE, oTarget, STANDARD_FACTION_HOSTILE, "", ""));
DelayCommand(607.0, SetTrapActive(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDisarmable(oTarget, TRUE));
DelayCommand(607.0, SetTrapOneShot(oTarget, TRUE));
DelayCommand(607.0, SetTrapRecoverable(oTarget, TRUE));
DelayCommand(607.0, SetTrapDetectDC(oTarget, 15+d12()));
DelayCommand(607.0, SetTrapDisarmDC(oTarget, 25+d12()));
DelayCommand(610.0, SetLocalInt(OBJECT_SELF,"CHEST",0));
}
}