Add code generation for loot