#!/usr/bin/env bash
tes3cmd=./tes3cmd
previous_esp="Yet Another Better Sounds Patch.esp"
cell_donor="temp_local_cell_donor.esp"
# Script was edited in OpenMW-CS, which changes other records, so I've exported only script
scripts_donor="scripts_donor_expanded.esp"
result="Yet Another Better Sounds Patch - Tavern and Town Sounds Expansion.esp"
curidx=340

rm -v "${result}"
# Assemble the patch from many pieces
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type TES3 --type SOUN
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type MGEF
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type SCPT\
  --exact-id "outsidebanner"\
  --exact-id "globalstopsoundsscript"
${tes3cmd} dump "${scripts_donor}" --raw "${result}" --type SCPT\
  --exact-id "globaltownsoundscript"
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type SCPT\
  --exact-id "globalweathersoundscript"\
  --exact-id "outsidebanner_2"\
  --exact-id "plains"\
  --exact-id "plains2"\
  --exact-id "plains3"\
  --exact-id "plains4"\
  --exact-id "signrotate_2"\
  --exact-id "sound_blacksmith_ambient"\
  --exact-id "sound_cave_wind_2"\
  --exact-id "sound_daedric_chant_2"\
  --exact-id "sound_forge_ambient"\
  --exact-id "sound_haunted_2"\
  --exact-id "sound_tavern_ambient"\
  --exact-id "sound_tavern_ambient_sp"\
  --exact-id "swampsoundscript"
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type REGN
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type SSCR
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type CONT
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type ACTI
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type SNDG
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type CELL

# now start adding cells
${tes3cmd} dump   "Morrowind.esm" --raw-with-header "${cell_donor}" --type CELL --exact-id "seyda neen, arrille's tradehouse"
${tes3cmd} delete "${cell_donor}" --hide-backups --type CELL --instance-match ".*"
${tes3cmd} delete "${cell_donor}" --hide-backups --type CELL --sub-match "Reference_Count:"
${tes3cmd} delete "${cell_donor}" --hide-backups --type CELL --sub-match "Color:"
${tes3cmd} delete "${cell_donor}" --hide-backups --type CELL --sub-match "Water_Height:"
${tes3cmd} delete "${cell_donor}" --hide-backups --type CELL --sub-match "Ambient:"
${tes3cmd} modify "${cell_donor}" --hide-backups --type CELL --exact-id "seyda neen, arrille's tradehouse" --run "\
                    \$R->set({f=>'Name'}, 'interior for generator')"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Solstheim, The Moldy Horker'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.80'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4296.000', 'y', '3672.000', 'z', '12056.000', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Solstheim, LoKKen Main Hall'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '700.913', 'y', '-275.283', 'z', '-242.334', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'St Rilms Beacon'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '1'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4342.778', 'y', '3880.799', 'z', '10209.356', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Uvirith\'s Grave, The Rusty Bucket'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4136.680', 'y', '3998.124', 'z', '14827.817', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Smugglers\' Cross'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '3'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3408.530', 'y', '4418.329', 'z', '167.075', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Vivec, The Blue Kagouti'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '526.923', 'y', '-353.936', 'z', '-218.731', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Havish, Alaina\'s House of Pleasures'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3801.286', 'y', '4370.485', 'z', '14726.179', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Havish, The Broken Drum'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4174.752', 'y', '4223.290', 'z', '12992.439', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Havish, The Citadel'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3702.791', 'y', '3847.011', 'z', '12095.288', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Havish, The Frosty Mug'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4280.551', 'y', '4444.606', 'z', '13374.344', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Havish, The Golden Lady'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4007.409', 'y', '4674.987', 'z', '0.061', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Havish, The Kissing Wench'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '5075.826', 'y', '3941.846', 'z', '15228.613', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Havish, The Loaded Dice'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3865.921', 'y', '3600.979', 'z', '13758.909', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Havish, The Shimmering Unicorn'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4137.229', 'y', '3877.106', 'z', '13959.848', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Wyrmhaven, The Broken Mandolin'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4397.504', 'y', '4223.971', 'z', '15939.728', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Wyrmhaven, The Werewolf\'s Head'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4324.510', 'y', '4585.284', 'z', '15552.025', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Wyrmhaven, The Salty Goblin'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4977.010', 'y', '3647.465', 'z', '15745.741', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Stirk, The Sload\'s Tale'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '722.080', 'y', '-514.814', 'z', '6.212', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Stirk, Safe Harbor Inn'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '391.431', 'y', '565.968', 'z', '256.480', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Stirk, Old Seawater Tavern'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '1063.908', 'y', '509.525', 'z', '4.630', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Even Odds Inn'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3609.930', 'y', '3839.971', 'z', '4000.533', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Karthwasten, The Dancing Saber'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.90'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4329.409', 'y', '3719.349', 'z', '13332.074', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Karthwasten, The Droopy Mare'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.10'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '-207.483', 'y', '-510.627', 'z', '18.448', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Karthwasten, Ruby Drake Inn'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '200.511', 'y', '827.564', 'z', '59.990', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Dragonstar East, Shadowkey Tavern'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.90'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4340.000', 'y', '4004.000', 'z', '12360.000', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Dragonstar East, Ildgar\'s Alehouse'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4110.997', 'y', '4038.841', 'z', '15372.719', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Dragonstar West, Nukra-Tikil Tavern'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3899.595', 'y', '3738.180', 'z', '15634.949', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Dragonstar West, Dragon Fountain Inn'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3964.000', 'y', '3816.000', 'z', '15520.000', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Enamor Dayn, The Gentle Velk'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '5878.199', 'y', '6290.136', 'z', '17496.000', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Bosmora, The Starlight Inn'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4296.437', 'y', '4314.110', 'z', '15584.024', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Gorne, The Emerald Haven Inn'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '2873.845', 'y', '3900.208', 'z', '15259.285', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'The Inn Between'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4419.688', 'y', '4077.187', 'z', '14492.302', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Hlersis, The Leaking Spore'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4242.143', 'y', '4744.400', 'z', '14926.338', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Akamora, Underground Bazaar'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '2118.347', 'y', '4005.741', 'z', '15442.520', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Akamora, The Laughing Goblin'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3682.210', 'y', '3486.484', 'z', '129.599', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Necrom, Seafarer\'s Rest Hostel'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '-3.019', 'y', '-547.276', 'z', '-106.579', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Necrom, Pilgrim\'s Respite'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3657.583', 'y', '2616.970', 'z', '12174.320', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Necrom, Temple Hostel'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '442.221', 'y', '333.112', 'z', '-119.033', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Meralag, The Golden Glade'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.50'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4345.368', 'y', '4584.819', 'z', '12867.832', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Hunted Hound Inn'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4003.569', 'y', '3313.991', 'z', '15558.881', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Sailen, The Toiling Guar'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.50'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3626.694', 'y', '4190.899', 'z', '11265.013', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Tel Ouada, The Magic Mudcrab'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '-553.688', 'y', '-584.617', 'z', '-224.420', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Llothanis, The Water\'s Shadow Tavern'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3360.989', 'y', '4748.277', 'z', '8144.162', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Port Telvannis, The Lost Crab Tavern'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3891.454', 'y', '4213.102', 'z', '14110.418', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Gah Sadrith, The Wetstone Tavern'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4155.939', 'y', '4603.567', 'z', '15176.027', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Ranyon-ruhn, The Dancing Jug'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3761.186', 'y', '4348.568', 'z', '15181.388', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Ranyon-ruhn, Silt Strider Tower'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3720.244', 'y', '4419.026', 'z', '13890.691', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Port Telvannis, The Avenue: Subterranean Balconies'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '7'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '7503.445', 'y', '6109.475', 'z', '15882.056', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Tel Muthada, The Note In Your Eye'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '-1415.630', 'y', '34.362', 'z', '-105.903', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Tel Mothrivra, The Glass Goblet'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3931.131', 'y', '3842.413', 'z', '14101.869', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Marog, The Swallow\'s Nest'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.15'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4424.608', 'y', '3703.758', 'z', '15700.416', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Verulas Pass, Twisted Root'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4359.719', 'y', '4757.417', 'z', '14656.435', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Old Ebonheart, The Moth and Tiger'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '-284.315', 'y', '659.275', 'z', '5.999', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Old Ebonheart, The Empress Katariah'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '-296.000', 'y', '255.311', 'z', '9.513', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Old Ebonheart, The Salty Futtocks'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4639.021', 'y', '5641.431', 'z', '14604.878', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Vhul, Watcher Cornerclub'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4290.435', 'y', '4358.636', 'z', '12954.097', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Vhul, The Howling Hound'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3390.085', 'y', '3892.580', 'z', '15554.678', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Aimrah, The Sailors\' Inn'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.85'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3760.000', 'y', '4048.000', 'z', '14672.000', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Almas Thirr, Thirsty Saint Cornerclub'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3708.707', 'y', '4222.616', 'z', '15249.834', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Almas Thirr, Limping Scrib'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '442.079', 'y', '-726.910', 'z', '140.108', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Almas Thirr, Hospice of the Crossing'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '324.100', 'y', '-849.694', 'z', '-42.857', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Nivalis, The Black Ogre Tavern'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3307.167', 'y', '4204.451', 'z', '258.906', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Firewatch, The Queen\'s Cutlass'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.10'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '6061.670', 'y', '3760.057', 'z', '16272.457', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Firewatch, The Howling Noose'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.20'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '7016.000', 'y', '784.000', 'z', '16200.000', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Helnim, The Red Drake'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4168.000', 'y', '4320.000', 'z', '14858.179', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Helnim, Mjornir\'s Meadhouse'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3878.285', 'y', '4074.480', 'z', '14089.108', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Omaynis, The Kwama\'s Scuttle'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '3888.738', 'y', '4021.309', 'z', '13197.648', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Andothren, The Dancing Cup'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4088.000', 'y', '3984.000', 'z', '14478.612', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Bodrum, Varalaryn Tradehouse'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '515.689', 'y', '-1391.080', 'z', '-367.517', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Teyn, Cirifae\'s Tradehouse'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '-323.022', 'y', '813.779', 'z', '-242.616', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Arvud, Lucky Shalaasa\'s Caravanserai'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '87.398', 'y', '-1746.909', 'z', '-116.801', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Raven Rock, Bar'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '1.00'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '538.436', 'y', '568.410', 'z', '80.604', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Sadrith Mora, Fara\'s Hole in the Wall'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '-2.905', 'y', '-216.206', 'z', '404.663', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Tel Branora, Sethan\'s Tradehouse'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '813.537', 'y', '-501.339', 'z', '124.000', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"
curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Vivec, Black Shalk Cornerclub'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '690.420', 'y', '-346.855', 'z', '-48.392', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Vivec, The Flowers of Gold'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '-335.750', 'y', '53.296', 'z', '-106.560', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Vivec, The Lizard\'s Head'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '416.118', 'y', '176.211', 'z', '-119.333', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Vos, Varo Tradehouse'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '-27.988', 'y', '-208.901', 'z', '128.938', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Khuul, Thongar\'s Tradehouse'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '4241.494', 'y', '4498.365', 'z', '13746.809', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Maar Gan, Andus Tradehouse'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '8.000', 'y', '600.000', 'z', '-0.453', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Molag Mar, The Pilgrim\'s Rest'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '-968.095', 'y', '43.596', 'z', '-0.688', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Mournhold, The Winged Guar'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.50'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '-141.268', 'y', '161.891', 'z', '156.242', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Ald-ruhn, Council Club'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '43.296', 'y', '-308.173', 'z', '0.147', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

curidx=$((curidx + 1))
${tes3cmd} dump   "${cell_donor}" --raw "${result}" --type CELL --exact-id "interior for generator"
${tes3cmd} modify "${result}" --hide-backups --type CELL --exact-id "interior for generator" --run "\
                  \$R->set({t=>'NAME', f=>'Name'}, 'Caldera, Shenk\'s Shovel'), \
                  \$R->set({t=>'DATA', f=>'Fog_Density'}, '0.75'), \
                  \$R->set({t=>'DATA', f=>'Flags'}, '5'), \
                      \$R->append(CELL::NAM0->new({'reference_count', '1'})), \
                      \$R->append(CELL::FRMR->new({'objidx', '${curidx}', 'mastidx', '0'})), \
                      \$R->append(CELL::NAME->new({'name', 'Sound_Tawern_Amb00'})), \
                      \$R->append(CELL::DATA->new({'x', '255.728', 'y', '20.966', 'z', '127.471', 'x_angle', '0', 'y_angle', '0', 'z_angle', '0'}))"

set -e
false

# Recompile scripts for vanilla engine users
# Resulting esp is a mess. So i have to reconstruct it again.

previous_esp="Yet Another Better Sounds Patch - Tavern and Town Sounds Expansion - previous.esp"
cs_esp="Yet Another Better Sounds Patch - Tavern and Town Sounds Expansion - CS.esp"
rm -v "${result}"
# Assemble the patch from many pieces
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type TES3 --type SOUN
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type MGEF
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type SCPT\
  --exact-id "outsidebanner"
${tes3cmd} dump "${cs_esp}" --raw "${result}" --type SCPT\
  --exact-id "globalstopsoundsscript"\
  --exact-id "globaltownsoundscript"
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type SCPT\
  --exact-id "globalweathersoundscript"\
  --exact-id "outsidebanner_2"\
  --exact-id "plains"\
  --exact-id "plains2"\
  --exact-id "plains3"\
  --exact-id "plains4"\
  --exact-id "signrotate_2"\
  --exact-id "sound_blacksmith_ambient"
${tes3cmd} dump "${cs_esp}" --raw "${result}" --type SCPT\
  --exact-id "sound_cave_wind_2"\
  --exact-id "sound_daedric_chant_2"
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type SCPT\
  --exact-id "sound_forge_ambient"
${tes3cmd} dump "${cs_esp}" --raw "${result}" --type SCPT\
  --exact-id "sound_haunted_2"
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type SCPT\
  --exact-id "sound_tavern_ambient"\
  --exact-id "sound_tavern_ambient_sp"
${tes3cmd} dump "${cs_esp}" --raw "${result}" --type SCPT\
  --exact-id "swampsoundscript"
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type REGN
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type SSCR
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type CONT
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type ACTI
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type SNDG
${tes3cmd} dump "${previous_esp}" --raw "${result}" --type CELL
