#!/usr/bin/env bash
# Changelog:
# 2022-12-03
#   - Comment out one command for Beware the Sixth House(fixed upstream)
#
# 2022-09-07
#   - Remove(move to "Miscellaneous Patches")
#     - Missing Snow Armor
#     - Grandfather Frost
#     - Entertainers Expanded
#
# 2022-07-24
#   - Add Alchemical Hustle(Toxicity)
#
# 2022-07-23
#   - Add Grandfather Frost(red colovian helm)
#   - Add Entertainers Expanded(colovian helm)
#
# 2022-07-22
#   - Add CLOT "aryongloveleft" and "aryongloveright" to Uvirith's Legacy patch(change price)
#   - Add ARMO "bm wolf shield" from "Missing Snow Armor"(TOTSP, change enchantment and AR)
#
# 2021-12-30
#   - Remove Open Helmets(a lot of clipping)
#
# 2021-12-05
#   - Add Open Helmets
#
# 2021-11-01
#   - Remove redundant changes to "extravagant_robe_01_red"
#
# 2021-10-15
#   - Change Remiros' Uniques Conoon Chodala's health from 1000 to 100 according to BTBGI
#   - Fix Hair Shirt of St. Aralor name, Veloth's Robe value
#   - Remove redundant changes to enchatment of enchanted robes
#   - Rebalance Tribunal Rebalance's DB Armor slightly to fit better into BTB progression:
#     - AR 12->15, weight a bit higher, health and enchantment a bit lower.
#
# 2021-10-11
#   - Change Better Clothes Complete common shirts, skirts, pants enchantment according to BTBGI
#   - Change most Better Robes enchantment according to BTBGI
#
# 2021-10-05
#   - Add Remiros' Uniques
#
# 2021-09-27
#   - Replace Remiros' Tombs Expansion with OAAB - Tombs and Towers
#
# 2021-09-24
#   - Add NPC_ "king hlaalu helseth" to Tribunal Rebalance patch after Necro introduced helseth's ability
#   - Add Better Sounds
#
# 2021-09-18
#   - Remove Tamriel Rebuilt after Necro introduced necro_honorguard_en
#
# 2021-07-17
#   - Add Tribunal Rebalance
#   - Add Bloodmoon Rebalance
#   - Add Beware The Sixth House
#   - Add Tamriel Rebuilt
#   - Add Imperial Legion Expansion
#
# 2021-07-11
#   - Improve Syc At Home Alchemy and move into separate patch
#
# 2021-07-08
#   - Split Various and Misc
#   - Split Various and Faction
#   - Join  Various and Syc At Home Alchemy
#
# vim: nowrap
# command used for formatting text: '<,'>EasyAlign 4/\-\-/r0 ; '<,'>EasyAlign / '/r0

source_btb_gi_necro="BTB's Game Improvements (Necro Edit).esp"
source_better_cloth="Better Clothes Complete.ESP"
source_better_robes="Better Robes.ESP"
source_remiros_uniq="Remiros' Uniques.ESP"
source_oaab_tombs_t="OAAB - Tombs and Towers.ESP"
source_patch_for_pu="Patch for Purists.esm"
source_oaab_data_es="OAAB_Data.esm"
source_tribunal_reb="Tribunal Rebalance.ESP"
source_bloodmoon_re="Bloodmoon Rebalance.esp"
source_beware_sixth="Beware the Sixth House.ESP"
# source_bloodmoon_es="Bloodmoon.esm"
source_imperial_leg="Imperial Legion Expansion.esp"
# i use my own patched version, though any better sounds patched will work
source_better_sound="Yet Another Better Sounds Patch - Tavern and Town Sounds Expansion.esp"
# source_open_helmets="Open Helmets.ESP"
source_uvirith_lega="Uvirith's Legacy_3.53.esp"
# source_missing_snow="Missing snow armor.esp"
# source_grandf_frost="Grandfather Frost - TOTSP.ESP"
# source_entert_expan="Entertainers Expanded.esp"
tes3cmd="./tes3cmd"

# 01 Better Clothes Complete
result="avp BTBGI-NE - Better Clothes Complete.esp"
$tes3cmd dump "${source_better_cloth}" --raw-with-header "${result}" --type CLOT \
  --exact-id "templar skirt obj" \
  --exact-id "expensive_shirt_hair" \
  --exact-id "therana's skirt" \
  --exact-id "sarandas_shoes_2" \
  --exact-id "peakstar_pants_unique" \
  --exact-id "shoes_of_conviction" \
  --exact-id "zenithar_frock" \
  --exact-id "caius_pants" \
  --exact-id "caius_shirt" \
  --exact-id "tailored_trousers" \
  --exact-id "restoration_shirt" \
  --exact-id "common_shoes_02_surefeet" \
  --exact-id "common_shirt_gondolier" \
  --exact-id "bc_thong_male" \
  --exact-id "bc_thong_female" \
  --exact-id "bm_nordic01_pants" \
  --exact-id "bm_nordic02_pants" \
  --exact-id "bm_wool01_pants" \
  --exact-id "bm_wool02_pants" \
  --exact-id "common_pants_01" \
  --exact-id "common_pants_01_a" \
  --exact-id "common_pants_01_e" \
  --exact-id "common_pants_01_u" \
  --exact-id "common_pants_01_z" \
  --exact-id "common_pants_02" \
  --exact-id "common_pants_02_hentus" \
  --exact-id "common_pants_03" \
  --exact-id "common_pants_03_b" \
  --exact-id "common_pants_03_c" \
  --exact-id "common_pants_04" \
  --exact-id "common_pants_04_b" \
  --exact-id "common_pants_05" \
  --exact-id "common_pants_06" \
  --exact-id "common_pants_07" \
  --exact-id "common_shirt_01" \
  --exact-id "common_shirt_01_a" \
  --exact-id "common_shirt_01_e" \
  --exact-id "common_shirt_01_u" \
  --exact-id "common_shirt_01_z" \
  --exact-id "common_shirt_02" \
  --exact-id "common_shirt_02_h" \
  --exact-id "common_shirt_02_hh" \
  --exact-id "common_shirt_02_r" \
  --exact-id "common_shirt_02_rr" \
  --exact-id "common_shirt_02_t" \
  --exact-id "common_shirt_02_tt" \
  --exact-id "common_shirt_03" \
  --exact-id "common_shirt_03_b" \
  --exact-id "common_shirt_03_c" \
  --exact-id "common_shirt_04" \
  --exact-id "common_shirt_04_a" \
  --exact-id "common_shirt_04_b" \
  --exact-id "common_shirt_04_c" \
  --exact-id "common_shirt_05" \
  --exact-id "common_skirt_01" \
  --exact-id "common_skirt_02" \
  --exact-id "common_skirt_03" \
  --exact-id "common_skirt_04" \
  --exact-id "common_skirt_04_c" \
  --exact-id "common_skirt_05" \
  --exact-id "imperial skirt_clothing"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "templar skirt obj"            --run "\$R->set({t=>'CTDT',f=>'Enchantment'},  '75')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "expensive_shirt_hair"         --run "\$R->set({t=>'CTDT',f=>'Value'},        '1000')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "expensive_shirt_hair"         --run "\$R->set({t=>'FNAM',f=>'Name'},         'Hair Shirt of St. Aralor')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "therana's skirt"              --run "\$R->set({t=>'CTDT',f=>'Enchantment'},  '15')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "sarandas_shoes_2"             --run "\$R->set({t=>'ENAM',f=>'Enchanting'},   'BTB Designer Shoes')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "peakstar_pants_unique"        --run "\$R->set({t=>'CTDT',f=>'Value'},        '250')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "shoes_of_conviction"          --run "\$R->set({t=>'ENAM',f=>'Enchanting'},   'charisma_en')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "zenithar_frock"               --run "\$R->set({t=>'CTDT',f=>'Value'},        '2000')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "caius_pants"                  --run "\$R->set({t=>'CTDT',f=>'Value'},        '500')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "caius_shirt"                  --run "\$R->set({t=>'CTDT',f=>'Value'},        '500')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "tailored_trousers"            --run "\$R->set({t=>'CTDT',f=>'Value'},        '250')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "restoration_shirt"            --run "\$R->set({t=>'CTDT',f=>'Value'},        '100')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "restoration_shirt"            --run "\$R->set({t=>'ENAM',f=>'Enchanting'},   'BTB Restoration Shirt')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "common_shoes_02_surefeet"     --run "\$R->set({t=>'CTDT',f=>'Value'},        '250')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "common_shirt_gondolier"       --run "\$R->set({t=>'CTDT',f=>'Enchantment'},  '15')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "common_pants_02_hentus"       --run "\$R->set({t=>'FNAM',f=>'Name'},         'Hentus\' Pants')"

$tes3cmd modify "${result}" --hide-backups --type CLOT \
  --exact-id "bc_thong_male" \
  --exact-id "bc_thong_female" \
  --run "\$R->set({t=>'CTDT',f=>'Enchantment'},  '5')"

$tes3cmd modify "${result}" --hide-backups --type CLOT \
  --exact-id "bm_nordic01_pants" \
  --exact-id "bm_nordic02_pants" \
  --exact-id "bm_wool01_pants" \
  --exact-id "bm_wool02_pants" \
  --exact-id "common_pants_01" \
  --exact-id "common_pants_01_a" \
  --exact-id "common_pants_01_e" \
  --exact-id "common_pants_01_u" \
  --exact-id "common_pants_01_z" \
  --exact-id "common_pants_02" \
  --exact-id "common_pants_02_hentus" \
  --exact-id "common_pants_03" \
  --exact-id "common_pants_03_b" \
  --exact-id "common_pants_03_c" \
  --exact-id "common_pants_04" \
  --exact-id "common_pants_04_b" \
  --exact-id "common_pants_05" \
  --exact-id "common_pants_06" \
  --exact-id "common_pants_07" \
  --exact-id "common_shirt_01" \
  --exact-id "common_shirt_01_a" \
  --exact-id "common_shirt_01_e" \
  --exact-id "common_shirt_01_u" \
  --exact-id "common_shirt_01_z" \
  --exact-id "common_shirt_02" \
  --exact-id "common_shirt_02_h" \
  --exact-id "common_shirt_02_hh" \
  --exact-id "common_shirt_02_r" \
  --exact-id "common_shirt_02_rr" \
  --exact-id "common_shirt_02_t" \
  --exact-id "common_shirt_02_tt" \
  --exact-id "common_shirt_03" \
  --exact-id "common_shirt_03_b" \
  --exact-id "common_shirt_03_c" \
  --exact-id "common_shirt_04" \
  --exact-id "common_shirt_04_a" \
  --exact-id "common_shirt_04_b" \
  --exact-id "common_shirt_04_c" \
  --exact-id "common_shirt_05" \
  --exact-id "common_skirt_01" \
  --exact-id "common_skirt_02" \
  --exact-id "common_skirt_03" \
  --exact-id "common_skirt_04" \
  --exact-id "common_skirt_04_c" \
  --exact-id "common_skirt_05" \
  --exact-id "imperial skirt_clothing" \
  --run "\$R->set({t=>'CTDT',f=>'Enchantment'},  '15')"

# 02 Better Robes
result="avp BTBGI-NE - Better Robes.esp"
$tes3cmd dump "${source_better_robes}" --raw-with-header "${result}" --type CLOT \
  --exact-id "exquisite_robe_drake's pride" \
  --exact-id "adusamsi's_robe" \
  --exact-id "helseth's robe" \
  --exact-id "robe_lich_unique" \
  --exact-id "robe_lich_unique_x" \
  --exact-id "mantle of woe" \
  --exact-id "veloth's robe" \
  --exact-id "common_robe_01" \
  --exact-id "common_robe_02" \
  --exact-id "common_robe_02_h" \
  --exact-id "common_robe_02_hh" \
  --exact-id "common_robe_02_r" \
  --exact-id "common_robe_02_rr" \
  --exact-id "common_robe_02_t" \
  --exact-id "common_robe_02_tt" \
  --exact-id "common_robe_03" \
  --exact-id "common_robe_03_a" \
  --exact-id "common_robe_03_b" \
  --exact-id "common_robe_04" \
  --exact-id "common_robe_05" \
  --exact-id "common_robe_05_a" \
  --exact-id "common_robe_05_b" \
  --exact-id "common_robe_05_c" \
  --exact-id "common_robe_eot" \
  --exact-id "common_robe_unique" \
  --exact-id "expensive_robe_01" \
  --exact-id "expensive_robe_02" \
  --exact-id "expensive_robe_02_a" \
  --exact-id "expensive_robe_03" \
  --exact-id "extravagant_robe_01" \
  --exact-id "extravagant_robe_01_a" \
  --exact-id "extravagant_robe_01_b" \
  --exact-id "extravagant_robe_01_c" \
  --exact-id "extravagant_robe_01_h" \
  --exact-id "extravagant_robe_01_r" \
  --exact-id "extravagant_robe_01_t" \
  --exact-id "extravagant_robe_02" \
  --exact-id "exquisite_robe_01"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "exquisite_robe_drake's pride" --run "\$R->set({t=>'CTDT',f=>'Value'},        '1000')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "adusamsi's_robe"              --run "\$R->set({t=>'CTDT',f=>'Value'},        '100')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "helseth's robe"               --run "\$R->set({t=>'FNAM',f=>'Name'},         'Helseth\'s Robe')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "robe_lich_unique"             --run "\$R->set({t=>'CTDT',f=>'Value'},        '5000')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "robe_lich_unique"             --run "\$R->set({t=>'CTDT',f=>'Weight'},       '3')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "robe_lich_unique_x"           --run "\$R->set({t=>'CTDT',f=>'Value'},        '5000')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "robe_lich_unique_x"           --run "\$R->set({t=>'CTDT',f=>'Weight'},       '3')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "mantle of woe"                --run "\$R->set({t=>'CTDT',f=>'Value'},        '5000')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "veloth's robe"                --run "\$R->set({t=>'CTDT',f=>'Value'},        '200')"

$tes3cmd modify "${result}" --hide-backups --type CLOT \
  --exact-id "common_robe_01" \
  --exact-id "common_robe_02" \
  --exact-id "common_robe_02_h" \
  --exact-id "common_robe_02_hh" \
  --exact-id "common_robe_02_r" \
  --exact-id "common_robe_02_rr" \
  --exact-id "common_robe_02_t" \
  --exact-id "common_robe_02_tt" \
  --exact-id "common_robe_03" \
  --exact-id "common_robe_03_a" \
  --exact-id "common_robe_03_b" \
  --exact-id "common_robe_04" \
  --exact-id "common_robe_05" \
  --exact-id "common_robe_05_a" \
  --exact-id "common_robe_05_b" \
  --exact-id "common_robe_05_c" \
  --exact-id "common_robe_eot" \
  --exact-id "common_robe_unique" \
  --run "\$R->set({t=>'CTDT',f=>'Enchantment'},  '15')"

$tes3cmd modify "${result}" --hide-backups --type CLOT \
  --exact-id "expensive_robe_01" \
  --exact-id "expensive_robe_02" \
  --exact-id "expensive_robe_02_a" \
  --exact-id "expensive_robe_03" \
  --run "\$R->set({t=>'CTDT',f=>'Enchantment'},  '75')"

$tes3cmd modify "${result}" --hide-backups --type CLOT \
  --exact-id "extravagant_robe_01" \
  --exact-id "extravagant_robe_01_a" \
  --exact-id "extravagant_robe_01_b" \
  --exact-id "extravagant_robe_01_c" \
  --exact-id "extravagant_robe_01_h" \
  --exact-id "extravagant_robe_01_r" \
  --exact-id "extravagant_robe_01_t" \
  --exact-id "extravagant_robe_02" \
  --run "\$R->set({t=>'CTDT',f=>'Enchantment'},  '300')"

$tes3cmd modify "${result}" --hide-backups --type CLOT \
  --exact-id "exquisite_robe_01" \
  --exact-id "helseth's robe" \
  --run "\$R->set({t=>'CTDT',f=>'Enchantment'},  '600')"

# 03 OAAB Tombs and Towers
result="avp BTBGI-NE - OAAB Tombs and Towers.esp"
$tes3cmd dump "${source_patch_for_pu}" --raw-with-header "${result}" --type WEAP --exact-id "bonebiter_bow_unique"
# bonebiter look from TT, stats from BTB, including enchantment (remiros' is overpowered)
$tes3cmd modify "${result}" --hide-backups --type WEAP --exact-id "bonebiter_bow_unique" --run "\
  \$R->set({t=>'WPDT',f=>'Flags'}, '0'),\
  \$R->set({t=>'MODL',f=>'Model'}, 'OAAB\\w\\rem_bonebiter.nif'),\
  \$R->set({t=>'ITEX',f=>'Icon'}, 'OAAB\\w\\w_bonebiter.dds')"
# take ebony helm from TT, change Value and Ench
$tes3cmd dump "${source_oaab_tombs_t}" --raw "${result}" --type ARMO --exact-id "ebony_closed_helm_fghl"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "ebony_closed_helm_fghl" --run "\
  \$R->set({t=>'AODT',f=>'Value'}, '1000'),\
  \$R->set({t=>'AODT',f=>'Enchantment'}, '600')"
# take sandas chest from tt, fix name, replace bracers with adamantium (same as expansions integrated)
$tes3cmd dump "${source_oaab_tombs_t}" --raw "${result}" --type CONT --exact-id "chest_tomb_sandas"
$tes3cmd modify "${result}" --hide-backups --type CONT --exact-id "chest_tomb_sandas" --run "\
  \$R->set({t=>'FNAM',f=>'Name'}, 'A Nobleman\'s Chest')"
$tes3cmd modify "${result}" --hide-backups --type CONT --exact-id "chest_tomb_sandas"\
  --replace '/orcish_bracer_right$/adamantium_bracer_right/'
$tes3cmd modify "${result}" --hide-backups --type CONT --exact-id "chest_tomb_sandas"\
  --replace '/orcish_bracer_left$/adamantium_bracer_left/'
# Take redas goblet from TT, fix name (from PFP) 
$tes3cmd dump "${source_oaab_tombs_t}" --raw "${result}" --type MISC --exact-id "misc_de_goblet_01_redas"
$tes3cmd modify "${result}" --hide-backups --type MISC --exact-id "misc_de_goblet_01_redas" --run "\
  \$R->set({t=>'FNAM',f=>'Name'}, 'Redas Chalice')"
# take shimsil from TT, value from btb
$tes3cmd dump "${source_oaab_tombs_t}" --raw "${result}" --type WEAP --exact-id "we_shimsil"
$tes3cmd modify "${result}" --hide-backups --type WEAP --exact-id "we_shimsil" --run "\
  \$R->set({t=>'WPDT',f=>'Value'}, '3000')"
# take Magebane from BTB, take Model and Icon from TT (overpowered ench removed)
$tes3cmd dump "${source_btb_gi_necro}" --raw "${result}" --type WEAP --exact-id "glass claymore_magebane"
$tes3cmd modify "${result}" --hide-backups --type WEAP --exact-id "glass claymore_magebane" --run "\
  \$R->set({t=>'MODL',f=>'Model'}, 'OAAB\\w\\rem_magebane.nif'),\
  \$R->set({t=>'ITEX',f=>'Icon'}, 'OAAB\\w\\rem_magebane.dds')"
# worm lord is much harder, but glass spear from OAAB should be nerfed
$tes3cmd dump "${source_oaab_data_es}" --raw "${result}" --type WEAP --exact-id "ab_w_glassspear"
$tes3cmd modify "${result}" --hide-backups --type WEAP --exact-id "ab_w_glassspear" --run "\
  \$R->set({t=>'WPDT',f=>'Value'}, '1900'),\
  \$R->set({t=>'WPDT',f=>'Health'}, '290'),\
  \$R->set({t=>'WPDT',f=>'Enchantment'}, '110'),\
  \$R->set({t=>'WPDT',f=>'Chop_Max'}, '5'),\
  \$R->set({t=>'WPDT',f=>'Slash_Max'}, '5'),\
  \$R->set({t=>'WPDT',f=>'Thrust_Min'}, '7'),\
  \$R->set({t=>'WPDT',f=>'Thrust_Max'}, '39')"
$tes3cmd header "${result}" --hide-backups --update-record-count

# 04 Uvirith's Legacy
result="avp BTBGI-NE - Uvirith's Legacy.esp"
$tes3cmd dump "${source_btb_gi_necro}" --raw-with-header "${result}" --type NPC_ \
  --exact-id "ingwold"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type NPC_ --exact-id "ingwold"                      --run "\$R->set({t=>'FNAM',f=>'Name'},         'Ingwold')"
$tes3cmd modify "${result}" --hide-backups --type NPC_ --exact-id "ingwold"                      --run "\$R->append(NPC_::NPCO->new({'object',  'bk_DaedricSummoning_2a', 'count', '1'}))"
# 2022-07-22 - Add CLOT "aryongloveleft" and "aryongloveright" to Uvirith's Legacy patch(change price)
$tes3cmd dump "${source_uvirith_lega}" --raw "${result}" --type CLOT \
  --exact-id "aryongloveleft"\
  --exact-id "aryongloveright"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "aryongloveleft"               --run "\$R->set({t=>'CTDT',f=>'Value'},         '2000')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "aryongloveright"              --run "\$R->set({t=>'CTDT',f=>'Value'},         '2000')"

# 05 Tribunal Rebalance
result="avp BTBGI-NE - Tribunal Rebalance.esp"
$tes3cmd dump "${source_tribunal_reb}" --raw-with-header "${result}" --type WEAP \
  --exact-id "goblin_club" \
  --exact-id "goblin_sword"
$tes3cmd dump "${source_tribunal_reb}" --raw "${result}" --type ARMO \
  --exact-id "darkbrotherhood helm" \
  --exact-id "darkbrotherhood cuirass" \
  --exact-id "darkbrotherhood greaves" \
  --exact-id "darkbrotherhood pauldron_l" \
  --exact-id "darkbrotherhood pauldron_r" \
  --exact-id "darkbrotherhood gauntlet_l" \
  --exact-id "darkbrotherhood gauntlet_r" \
  --exact-id "darkbrotherhood boots" \
  --exact-id "goblin_shield"
$tes3cmd dump "${source_btb_gi_necro}" --raw "${result}" --type ARMO \
  --exact-id "goblin_shield_durgok_uni"
$tes3cmd dump "${source_btb_gi_necro}" --raw "${result}" --type NPC_ \
  --exact-id "king hlaalu helseth"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type WEAP --exact-id "goblin_club" --run "\
  \$R->set({t=>'WPDT',f=>'Enchantment'}, '22'), \
  \$R->set({t=>'WPDT',f=>'Flags'}, '0')"
$tes3cmd modify "${result}" --hide-backups --type WEAP --exact-id "goblin_sword" --run "\
  \$R->set({t=>'WPDT',f=>'Enchantment'}, '15'), \
  \$R->set({t=>'WPDT',f=>'Flags'}, '0')"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "darkbrotherhood helm" --run "\
  \$R->set({t=>'AODT',f=>'Weight'}, '1.5'), \
  \$R->set({t=>'AODT',f=>'Value'}, '30'), \
  \$R->set({t=>'AODT',f=>'Enchantment'}, '40'), \
  \$R->set({t=>'AODT',f=>'AR'}, '15')"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "darkbrotherhood cuirass" --run "\
  \$R->set({t=>'AODT',f=>'Health'}, '250'), \
  \$R->set({t=>'AODT',f=>'Enchantment'}, '30'), \
  \$R->set({t=>'AODT',f=>'AR'}, '15')"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "darkbrotherhood greaves" --run "\
  \$R->set({t=>'AODT',f=>'Weight'}, '4.5'), \
  \$R->set({t=>'AODT',f=>'Health'}, '200'), \
  \$R->set({t=>'AODT',f=>'Enchantment'}, '10'), \
  \$R->set({t=>'AODT',f=>'AR'}, '15')"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "darkbrotherhood pauldron_l" --run "\
  \$R->set({t=>'AODT',f=>'Weight'}, '1.5'), \
  \$R->set({t=>'AODT',f=>'Health'}, '150'), \
  \$R->set({t=>'AODT',f=>'Enchantment'}, '10'), \
  \$R->set({t=>'AODT',f=>'AR'}, '15')"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "darkbrotherhood pauldron_r" --run "\
  \$R->set({t=>'AODT',f=>'Weight'}, '1.5'), \
  \$R->set({t=>'AODT',f=>'Health'}, '150'), \
  \$R->set({t=>'AODT',f=>'Enchantment'}, '10'), \
  \$R->set({t=>'AODT',f=>'AR'}, '15')"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "darkbrotherhood gauntlet_l" --run "\
  \$R->set({t=>'AODT',f=>'Health'}, '75'), \
  \$R->set({t=>'AODT',f=>'Enchantment'}, '25'), \
  \$R->set({t=>'AODT',f=>'AR'}, '15')"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "darkbrotherhood gauntlet_r" --run "\
  \$R->set({t=>'AODT',f=>'Health'}, '75'), \
  \$R->set({t=>'AODT',f=>'Enchantment'}, '25'), \
  \$R->set({t=>'AODT',f=>'AR'}, '15')"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "darkbrotherhood boots" --run "\
  \$R->set({t=>'AODT',f=>'Weight'}, '3'), \
  \$R->set({t=>'AODT',f=>'Health'}, '150'), \
  \$R->set({t=>'AODT',f=>'Enchantment'}, '20'), \
  \$R->set({t=>'AODT',f=>'AR'}, '15')"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "goblin_shield" --run "\
  \$R->set({t=>'AODT',f=>'Health'}, '300'), \
  \$R->set({t=>'AODT',f=>'Enchantment'}, '70')"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "goblin_shield_durgok_uni" --run "\
  \$R->set({t=>'AODT',f=>'Value'}, '500')"
$tes3cmd modify "${result}" --hide-backups --type NPC_ --exact-id "king hlaalu helseth" --run "\$R->set({t=>'NPDT',f=>'Level'}, '45')"
# no longer needed
# $tes3cmd delete "${result}" --hide-backups --type NPC_ --exact-id "king hlaalu helseth" --sub-match "Model:base_anim.nif"

# 06 Bloodmoon Rebalance
result="avp BTBGI-NE - Bloodmoon Rebalance.esp"
$tes3cmd dump "${source_bloodmoon_re}" --raw-with-header "${result}" --type WEAP \
  --exact-id "bm riekling lance" \
  --exact-id "bm riekling sword_rusted"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type WEAP --exact-id "bm riekling lance" --run "\$R->set({t=>'WPDT',f=>'Enchantment'}, '25')"
$tes3cmd modify "${result}" --hide-backups --type WEAP --exact-id "bm riekling sword_rusted" --run "\$R->set({t=>'WPDT',f=>'Enchantment'}, '30')"

# 07 Beware The Sixth House
result="avp BTBGI-NE - Beware the Sixth House.esp"
$tes3cmd dump "${source_beware_sixth}" --raw-with-header "${result}" --type CREA \
  --exact-id "corprus_stalker" \
  --exact-id "corprus_stalker_fgcs" \
  --exact-id "corprus_stalker_berwen" \
  --exact-id "corprus_stalker_fyr01" \
  --exact-id "corprus_stalker_fyr02" \
  --exact-id "corprus_stalker_fyr03" \
  --exact-id "corprus_stalker_danar" \
  --exact-id "corprus_stalker_morvayn"
$tes3cmd dump "${source_btb_gi_necro}" --raw "${result}" --type SPEL \
  --exact-id "ash feast"
$tes3cmd dump "${source_btb_gi_necro}" --raw "${result}" --type CREA \
  --exact-id "corprus_lame_fyr01" \
  --exact-id "corprus_lame_fyr02" \
  --exact-id "corprus_lame_fyr03" \
  --exact-id "corprus_lame_fyr04"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "corprus_stalker" \
  --exact-id "corprus_stalker_fgcs" \
  --exact-id "corprus_stalker_berwen" \
  --exact-id "corprus_stalker_fyr01" \
  --exact-id "corprus_stalker_fyr02" \
  --exact-id "corprus_stalker_fyr03" \
  --exact-id "corprus_stalker_danar" \
  --exact-id "corprus_stalker_morvayn" --run "\$R->set({t=>'NPCS',f=>'Spell'}, 'regenerate [ability]')"
# 2022-12-03 - Comment out one command for Beware the Sixth House(fixed upstream)
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "corprus_stalker_berwen" --run "\$R->set({t=>'NPDT',f=>'Soul'}, '100')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "corprus_lame_fyr01" \
  --exact-id "corprus_lame_fyr02" \
  --exact-id "corprus_lame_fyr03" \
  --exact-id "corprus_lame_fyr04" --run "\
  \$R->set({t=>'NPDT',f=>'Lev'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '250'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '45'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '45'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '45')"

# No longer needed after Necro did the same and created necro_honorguard_en 
# # 08 Tamriel Rebuilt
# result="avp BTBGI-NE - TR_Mainland.esp"
# $tes3cmd dump "${source_btb_gi_necro}" --raw-with-header "${result}" --type ENCH --exact-id "honorguard_en"
# $tes3cmd dump "${source_btb_gi_necro}" --raw "${result}" --type WEAP --exact-id "imperial shortsword severio"
# $tes3cmd header "${result}" --hide-backups --update-record-count
# $tes3cmd modify "${result}" --hide-backups --type ENCH --exact-id "honorguard_en" --run "\$R->set({t=>'NAME',f=>'ID'}, '_honorguard_en')"
# $tes3cmd modify "${result}" --hide-backups --type WEAP --exact-id "imperial shortsword severio" --run "\$R->set({t=>'ENAM',f=>'Enchanting'}, '_honorguard_en')"
# $tes3cmd dump "${source_bloodmoon_es}" --raw "${result}" --type ENCH --exact-id "honorguard_en"
# $tes3cmd header "${result}" --hide-backups --update-record-count

# 08 Imperial Legion Expansion
result="avp BTBGI-NE - Imperial Legion Expansion.esp"
$tes3cmd dump "${source_imperial_leg}" --raw-with-header "${result}" --type CREA --exact-id "scamp_creeper"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd delete "${result}" --hide-backups --type CREA --exact-id "scamp_creeper" --sub-match "Scale:"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "scamp_creeper" --run "\$R->set({t=>'NPDT',f=>'Gold'}, '30')"
$tes3cmd dump "${source_imperial_leg}" --raw "${result}" --type ENCH --exact-id "amuletakatosh"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type ENCH --exact-id "amuletakatosh" --run "\
  \$R->set({t=>'NAME', f=>'ID'}, 'avp_amuletstendarr'), \
  \$R->set({t=>'ENDT', f=>'Type'}, '2'), \
  \$R->set({t=>'ENDT', f=>'Cost'}, '11'), \
  \$R->set({t=>'ENDT', f=>'Charge'}, '55'), \
  \$R->set({t=>'ENDT', f=>'Autocalc'}, '1'), \
  \$R->set({t=>'ENAM', f=>'Spell_Effect'}, '83'), \
  \$R->set({t=>'ENAM', f=>'Skill'}, '0'), \
  \$R->set({t=>'ENAM', f=>'Duration'}, '60'), \
  \$R->set({t=>'ENAM', f=>'Mag_Min'}, '5'), \
  \$R->set({t=>'ENAM', f=>'Mag_Max'}, '5')"
$tes3cmd dump "${source_imperial_leg}" --raw "${result}" --type CLOT --exact-id "amuletstendarr"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "amuletstendarr" --run "\$R->set({t=>'CTDT', f=>'Enchantment'}, '100')"
$tes3cmd modify "${result}" --hide-backups --type CLOT --exact-id "amuletstendarr" --run "\$R->set({t=>'ENAM', f=>'Enchanting'}, 'avp_amuletstendarr')"
$tes3cmd dump "${source_imperial_leg}" --raw "${result}" --type ENCH --match "amulet"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type ENCH --exact-id "amuletakatosh" --run "\
  \$R->set({t=>'ENDT', f=>'Type'}, '2'), \
  \$R->set({t=>'ENDT', f=>'Cost'}, '11'), \
  \$R->set({t=>'ENDT', f=>'Charge'}, '55'), \
  \$R->set({t=>'ENDT', f=>'Autocalc'}, '1'), \
  \$R->set({t=>'ENAM', f=>'Duration'}, '10')"
$tes3cmd modify "${result}" --hide-backups --type ENCH --exact-id "amuletarkay" --run "\
  \$R->set({t=>'ENDT', f=>'Type'}, '2'), \
  \$R->set({t=>'ENDT', f=>'Cost'}, '11'), \
  \$R->set({t=>'ENDT', f=>'Charge'}, '55'), \
  \$R->set({t=>'ENDT', f=>'Autocalc'}, '1'), \
  \$R->set({t=>'ENAM', f=>'Duration'}, '60')"
$tes3cmd modify "${result}" --hide-backups --type ENCH --exact-id "amuletdibella" --run "\
  \$R->set({t=>'ENDT', f=>'Type'}, '2'), \
  \$R->set({t=>'ENDT', f=>'Cost'}, '11'), \
  \$R->set({t=>'ENDT', f=>'Charge'}, '55'), \
  \$R->set({t=>'ENDT', f=>'Autocalc'}, '1'), \
  \$R->set({t=>'ENAM', f=>'Duration'}, '60'), \
  \$R->set({t=>'ENAM', f=>'Mag_Min'}, '5'), \
  \$R->set({t=>'ENAM', f=>'Mag_Max'}, '5')"
$tes3cmd modify "${result}" --hide-backups --type ENCH --exact-id "amuletjulianos" --run "\
  \$R->set({t=>'ENDT', f=>'Type'}, '2'), \
  \$R->set({t=>'ENDT', f=>'Cost'}, '11'), \
  \$R->set({t=>'ENDT', f=>'Charge'}, '55'), \
  \$R->set({t=>'ENDT', f=>'Autocalc'}, '1'), \
  \$R->set({t=>'ENAM', f=>'Duration'}, '60')"
$tes3cmd modify "${result}" --hide-backups --type ENCH --exact-id "amuletkynareth" --run "\
  \$R->set({t=>'ENDT', f=>'Type'}, '2'), \
  \$R->set({t=>'ENDT', f=>'Cost'}, '11'), \
  \$R->set({t=>'ENDT', f=>'Charge'}, '55'), \
  \$R->set({t=>'ENDT', f=>'Autocalc'}, '1'), \
  \$R->set({t=>'ENAM', f=>'Duration'}, '60')"
$tes3cmd modify "${result}" --hide-backups --type ENCH --exact-id "amuletmara" --run "\
  \$R->set({t=>'ENDT', f=>'Type'}, '2'), \
  \$R->set({t=>'ENDT', f=>'Cost'}, '11'), \
  \$R->set({t=>'ENDT', f=>'Charge'}, '55'), \
  \$R->set({t=>'ENDT', f=>'Autocalc'}, '1'), \
  \$R->set({t=>'ENAM', f=>'Duration'}, '60'), \
  \$R->set({t=>'ENAM', f=>'Mag_Min'}, '5'), \
  \$R->set({t=>'ENAM', f=>'Mag_Max'}, '5')"
$tes3cmd modify "${result}" --hide-backups --type ENCH --exact-id "amulettalos" --run "\
  \$R->set({t=>'ENDT', f=>'Type'}, '2'), \
  \$R->set({t=>'ENDT', f=>'Cost'}, '11'), \
  \$R->set({t=>'ENDT', f=>'Charge'}, '55'), \
  \$R->set({t=>'ENDT', f=>'Autocalc'}, '1'), \
  \$R->set({t=>'ENAM', f=>'Duration'}, '60')"
$tes3cmd modify "${result}" --hide-backups --type ENCH --exact-id "amuletzenithar" --run "\
  \$R->set({t=>'ENDT', f=>'Type'}, '2'), \
  \$R->set({t=>'ENDT', f=>'Cost'}, '11'), \
  \$R->set({t=>'ENDT', f=>'Charge'}, '55'), \
  \$R->set({t=>'ENDT', f=>'Autocalc'}, '1'), \
  \$R->set({t=>'ENAM', f=>'Duration'}, '60'), \
  \$R->set({t=>'ENAM', f=>'Mag_Min'}, '5'), \
  \$R->set({t=>'ENAM', f=>'Mag_Max'}, '5')"
$tes3cmd modify "${result}" --hide-backups --type ENCH --exact-id "aedricamulet01" --run "\
  \$R->set({t=>'ENDT', f=>'Type'}, '2'), \
  \$R->set({t=>'ENDT', f=>'Cost'}, '11'), \
  \$R->set({t=>'ENDT', f=>'Charge'}, '55'), \
  \$R->set({t=>'ENDT', f=>'Autocalc'}, '1'), \
  \$R->set({i=>[2], f=>'Duration'}, '10'), \
  \$R->set({i=>[3], f=>'Duration'}, '60'), \
  \$R->set({i=>[4], f=>'Duration'}, '60'), \
  \$R->set({i=>[4], f=>'Mag_Min'}, '5'), \
  \$R->set({i=>[4], f=>'Mag_Max'}, '5'), \
  \$R->set({i=>[5], f=>'Duration'}, '60'), \
  \$R->set({i=>[6], f=>'Duration'}, '60'), \
  \$R->set({i=>[6], f=>'Mag_Min'}, '5'), \
  \$R->set({i=>[6], f=>'Mag_Max'}, '5'), \
  \$R->set({i=>[7], f=>'Duration'}, '60'), \
  \$R->set({i=>[7], f=>'Mag_Min'}, '5'), \
  \$R->set({i=>[7], f=>'Mag_Max'}, '5'), \
  \$R->set({i=>[8], f=>'Duration'}, '60'), \
  \$R->set({i=>[9], f=>'Duration'}, '60'), \
  \$R->set({i=>[9], f=>'Mag_Min'}, '5'), \
  \$R->set({i=>[9], f=>'Mag_Max'}, '5')"
$tes3cmd modify "${result}" --hide-backups --type ENCH --exact-id "amuletmystara" --run "\
  \$R->set({t=>'ENDT', f=>'Type'}, '2'), \
  \$R->set({t=>'ENDT', f=>'Cost'}, '11'), \
  \$R->set({t=>'ENDT', f=>'Charge'}, '55'), \
  \$R->set({t=>'ENDT', f=>'Autocalc'}, '1'), \
  \$R->set({t=>'ENAM', f=>'Duration'}, '10')"

# 09 Better Sounds
result="avp BTBGI-NE - Better Sounds.esp"
$tes3cmd dump "${source_better_sound}" --raw-with-header "${result}" --type MGEF \
  --exact-id "14" \
  --exact-id "27"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type MGEF --exact-id "14" --run "\$R->set({t=>'MEDT',f=>'Base_Cost'}, '6')"
$tes3cmd modify "${result}" --hide-backups --type MGEF --exact-id "27" --run "\$R->set({t=>'MEDT',f=>'Base_Cost'}, '2')"

# 10 Remiros' Uniques
result="avp BTBGI-NE - Remiros' Uniques.esp"
$tes3cmd dump "${source_remiros_uniq}" --raw-with-header "${result}" --type WEAP \
  --exact-id "bm_ebonylongsword_s" \
  --exact-id "bm ice longsword_fg_unique" \
  --exact-id "warhammer_rammekald_unique" \
  --exact-id "widowmaker_unique"
$tes3cmd dump "${source_remiros_uniq}" --raw "${result}" --type ARMO \
  --exact-id "boots of blinding speed_x" \
  --exact-id "boots of blinding speed[unique]" \
  --exact-id "conoon_chodala_boots_unique" \
  --exact-id "dreugh_cuirass_ttrm"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "dreugh_cuirass_ttrm" --run "
  \$R->set({t=>'FNAM',f=>'Name'}, 'Dreugh Warlord Cuirass')"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "boots of blinding speed[unique]" --run "
  \$R->set({t=>'AODT',f=>'Value'}, '2000'), \
  \$R->set({t=>'AODT',f=>'Health'}, '1000')"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "boots of blinding speed_x" --run "
  \$R->set({t=>'AODT',f=>'Value'}, '2000'), \
  \$R->set({t=>'AODT',f=>'Health'}, '1000')"
$tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "conoon_chodala_boots_unique" --run "
  \$R->set({t=>'AODT',f=>'Value'}, '500'), \
  \$R->set({t=>'AODT',f=>'Health'}, '100'), \
  \$R->set({t=>'AODT',f=>'AR'}, '20')"
$tes3cmd modify "${result}" --hide-backups --type WEAP --exact-id "bm_ebonylongsword_s" --run "\$R->set({t=>'WPDT',f=>'Value'}, '2000')"
$tes3cmd modify "${result}" --hide-backups --type WEAP --exact-id "bm ice longsword_fg_unique" --run "\$R->set({t=>'WPDT',f=>'Value'}, '10000')"
$tes3cmd modify "${result}" --hide-backups --type WEAP \
  --exact-id "warhammer_rammekald_unique" \
  --exact-id "widowmaker_unique" \
  --run "\$R->set({t=>'WPDT',f=>'Flags'}, '0')"

# 11 Open Helmets # disabled
# result="avp BTBGI-NE - Open Helmets.esp"
# $tes3cmd dump "${source_open_helmets}" --raw-with-header "${result}" --type ARMO \
#  --exact-id "bonemold_armun-an_helm"\
#  --exact-id "bonemold_founders_helm"\
#  --exact-id "bonemold_gah-julan_helm"\
#  --exact-id "bonemold_gah-julan_hhda"\
#  --exact-id "bonemold_helm"\
#  --exact-id "cephalopod_helm"\
#  --exact-id "cephalopod_helm_htnk"\
#  --exact-id "chitin helm"\
#  --exact-id "chitin_mask_helm"\
#  --exact-id "chitin_watchman_helm"\
#  --exact-id "demon cephalopod"\
#  --exact-id "demon helm"\
#  --exact-id "demon mole crab"\
#  --exact-id "devil cephalopod helm"\
#  --exact-id "devil helm"\
#  --exact-id "devil mole crab helm"\
#  --exact-id "dust_adept_helm"\
#  --exact-id "dwemer_helm"\
#  --exact-id "fiend helm"\
#  --exact-id "helm of wounding"\
#  --exact-id "helsethguard_helmet"\
#  --exact-id "iron_helmet"\
#  --exact-id "merisan helm"\
#  --exact-id "mole_crab_helm"\
#  --exact-id "morag_tong_helm"\
#  --exact-id "netch_leather_boiled_helm"\
#  --exact-id "orcish_helm"\
#  --exact-id "velothian_helm"
# $tes3cmd header "${result}" --hide-backups --update-record-count
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "bonemold_armun-an_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '140')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "bonemold_founders_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '175')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "bonemold_gah-julan_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '140')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "bonemold_gah-julan_hhda" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '140')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "bonemold_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '135')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "cephalopod_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '450'),\
#   \$R->set({t=>'AODT',f=>'Value'}, '300'),\
#   \$R->set({t=>'AODT',f=>'AR'}, '15')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "cephalopod_helm_htnk" --run "\
#   \$R->set({t=>'AODT',f=>'Value'}, '2000'),\
#   \$R->set({t=>'AODT',f=>'AR'}, '15')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "chitin helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '50'),\
#   \$R->set({t=>'AODT',f=>'Value'}, '100')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "chitin_mask_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '50'),\
#   \$R->set({t=>'AODT',f=>'Value'}, '200'),\
#   \$R->set({t=>'AODT',f=>'Health'}, '150')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "chitin_watchman_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '55'),\
#   \$R->set({t=>'AODT',f=>'AR'}, '15'),\
#   \$R->set({t=>'AODT',f=>'Value'}, '500')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "demon cephalopod" --run "\
#   \$R->set({t=>'FNAM',f=>'Name'}, 'Demon Cephalopod Helm'),\
#   \$R->set({t=>'AODT',f=>'AR'}, '15')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "demon helm" --run "\
#   \$R->set({t=>'AODT',f=>'AR'}, '15'),\
#   \$R->set({t=>'AODT',f=>'Value'}, '750'),\
#   \$R->set({t=>'ENAM',f=>'Enchanting'}, 'BTB Demon Helm')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "demon mole crab" --run "\
#   \$R->set({t=>'FNAM',f=>'Name'}, 'Demon Mole Crab Helm'),\
#   \$R->set({t=>'AODT',f=>'AR'}, '15'),\
#   \$R->set({t=>'ENAM',f=>'Enchanting'}, 'bound shield_en')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "devil cephalopod helm" --run "\
#   \$R->set({t=>'AODT',f=>'AR'}, '15')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "devil helm" --run "\
#   \$R->set({t=>'AODT',f=>'AR'}, '15'),\
#   \$R->set({t=>'AODT',f=>'Value'}, '750')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "devil mole crab helm" --run "\
#   \$R->set({t=>'AODT',f=>'AR'}, '15')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "dust_adept_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '150'),\
#   \$R->set({t=>'AODT',f=>'Value'}, '200'),\
#   \$R->set({t=>'AODT',f=>'AR'}, '15')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "dwemer_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '375'),\
#   \$R->set({t=>'AODT',f=>'AR'}, '40')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "fiend helm" --run "\
#   \$R->set({t=>'AODT',f=>'AR'}, '15'),\
#   \$R->set({t=>'AODT',f=>'Value'}, '1000')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "helm of wounding" --run "\
#   \$R->set({t=>'FNAM',f=>'Name'}, 'Helm of Wounds'),\
#   \$R->set({t=>'AODT',f=>'AR'}, '40')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "helsethguard_helmet" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '325'),\
#   \$R->set({t=>'AODT',f=>'Value'}, '2000')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "iron_helmet" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '135'),\
#   \$R->set({t=>'AODT',f=>'Value'}, '10')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "merisan helm" --run "\
#   \$R->set({t=>'AODT',f=>'Value'}, '150')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "mole_crab_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '300'),\
#   \$R->set({t=>'AODT',f=>'Value'}, '250'),\
#   \$R->set({t=>'AODT',f=>'AR'}, '15')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "morag_tong_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '60')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "netch_leather_boiled_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '40'),\
#   \$R->set({t=>'AODT',f=>'Value'}, '150'),\
#   \$R->set({t=>'AODT',f=>'Health'}, '200')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "orcish_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Enchantment'}, '225')"
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "velothian_helm" --run "\
#   \$R->set({t=>'AODT',f=>'Value'}, '150')"

# 2022-09-07 - Remove(move to "Miscellaneous Patches")
# # 2022-07-22 - Add ARMO "bm wolf shield" from "Missing Snow Armor"(TOTSP, change enchantment and AR)
# # 12 Missing Snow Armor from TOTSP
# result="avp BTBGI-NE - Missing snow armor.esp"
# $tes3cmd dump "${source_missing_snow}" --raw-with-header "${result}" --type ARMO --exact-id "bm wolf shield"
# $tes3cmd header "${result}" --hide-backups --update-record-count
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "bm wolf shield" --run "\
#  \$R->set({t=>'AODT',f=>'Enchantment'}, '80'),\
#  \$R->set({t=>'AODT',f=>'AR'}, '20')"

# 2022-09-07 - Remove(move to "Miscellaneous Patches")
# # 2022-07-23 - Add Grandfather Frost(red colovian helm)
# # 13 Grandfather Frost
# result="avp BTBGI-NE - Grandfather Frost.esp"
# $tes3cmd dump "${source_grandf_frost}" --raw-with-header "${result}" --type ARMO --exact-id "fur_colovian_helm_red"
# $tes3cmd header "${result}" --hide-backups --update-record-count
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "fur_colovian_helm_red" --run "\
#  \$R->set({t=>'AODT',f=>'Weight'}, '0.5'),\
#  \$R->set({t=>'AODT',f=>'Enchantment'}, '35'),\
#  \$R->set({t=>'AODT',f=>'AR'}, '1')"

# 2022-09-07 - Remove(move to "Miscellaneous Patches")
# # 2022-07-23 - Add Entertainers Expanded(colovian helm)
# # 14 Entertainers Expanded
# result="avp BTBGI-NE - Entertainers Expanded.esp"
# $tes3cmd dump "${source_entert_expan}" --raw-with-header "${result}" --type ARMO --exact-id "fur_colovian_helm"
# $tes3cmd header "${result}" --hide-backups --update-record-count
# $tes3cmd modify "${result}" --hide-backups --type ARMO --exact-id "fur_colovian_helm" --run "\
#  \$R->set({t=>'AODT',f=>'Weight'}, '0.5'),\
#  \$R->set({t=>'AODT',f=>'Enchantment'}, '35'),\
#  \$R->set({t=>'AODT',f=>'AR'}, '1')"

# 2022-07-24 - Add Alchemical Hustle(Toxicity)
# 15 Alchemical Hustle(Toxicity)
result="avp BTBGI-NE - Alchemical Hustle(Toxicity).esp"
$tes3cmd dump "${source_btb_gi_necro}" --raw-with-header "${result}" --type SKIL --exact-id "16"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type SKIL --exact-id "16" --run "\
 \$R->set({t=>'DESC',f=>'Description'}, 'Alchemy identifies magical properties in mundane substances. Substances are consumed directly, or prepared as potions to provide long-lasting benefits like healing and curing disease, water-walking, magical shielding, and fortifying bodily attributes. Experts in this skill are also less susceptible to toxicity caused by heavy potion use.')"
