My game Deeper does this a lot. Here is an example of a function that takes a prototype object and a location, clones the prototype in the location and then modifies the description and price it to give variety.
<function name="CreateTreasure" parameters="obj, room">
o = CloneObjectAndMove(obj, room)
if (HasString(o, "look")) o.look = RandomisePlus(o.look)
o.price = o.price - GetRandomInt(o.price/-4, o.price/4)
</function>
<function name="Randomise" parameters="s" type="string">
mylist = Split (s, "{")
output = StringListItem (mylist, 0)
list remove (mylist, output)
count = 0
foreach (s1, mylist) {
list1 = Split (s1, "}")
if (not ListCount (list1) = 2) {
error ("Unable to parse: " + s)
}
s2 = StringListItem (list1, 0)
list2 = Split (s2, "|")
pos = GetRandomInt (0, ListCount (list2) - 1)
extra = StringListItem (list2, pos)
output = output + extra + StringListItem (list1, 1)
count = count + 1
}
return (output)
</function>
<function name="RandomisePlus" parameters="s" type="string">
s = Randomise(s)
s = Replace(s, "%gem%", PickOneStr("ruby|sapphire|crystal|amethyst|emerald|diamond|opal|moonstone|chrysoberyl|garnet|jade|onyx|sunstone|topaz|tourmaline|turquoise"))
s = Replace(s, "%metal%", PickOneStr("electrum|gold|silver|white gold|crown gold|meteorite iron|mithril|adamantine|blood alloy"))
s = Replace(s, "%stone%", PickOneStr("alabaster|soapstone|chlorite|wonderstone|limestone|onyx|obsidian|marble|moonstone|coral|amber"))
return (s)
</function>
<!--
Randomly picks asubstring of the given string, or a string from a string list. Substrings should be separated by a vertical bar.
-->
<function name="PickOneStr" parameters="lst" type="string">
if (TypeOf(lst) = "string") {
lst = Split(lst, "|")
}
index = GetRandomInt(0, ListCount(lst) - 1)
return (StringListItem(lst, index))
</function>