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 oChest=OBJECT_SELF;
DelayCommand(5.0,replacetrap(oChest));

}