void replacetrap(object oObject) { string sResref=GetTag(oObject); int nRandom=d3(); string sRandom=IntToString(nRandom); string sWP=sResref+"_wp"+sRandom; location lLoc=GetLocation(GetWaypointByTag(sWP)); DestroyObject(oObject); CreateObject(OBJECT_TYPE_PLACEABLE,sResref,lLoc); } void main() { object oPC=GetEnteringObject(); int nRandom=Random(5); int nVFX=194+nRandom; ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(nVFX),oPC); FloatingTextStringOnCreature("*Trap triggered!*",oPC); object oChest=OBJECT_SELF; DelayCommand(5.0,replacetrap(oChest)); }