#!/usr/bin/env bash
# Changelog:
# 2021-01-10
#   - Use BTB's version of Open Spells instead of Thief Experience Overhaul version
#
# 2021-07-08
#   - Split Various and Misc patches
#   - Drop  Bardic Inspiration OMW
#
# 2021-07-17
#   - Move Beware The 6th House changes into Various module
#
# 2022-02-09
#   - Add Black Hands Dagger enchantment override for Morag Tong Polished
#
# 2022-07-19
#   - Remove Religions Elaborated as no longer needed when using Religions Elaborated Lite Edition
#
# 2022-07-20
#   - Remove Rise of House Sadras as I no longer use that mod
#
# vim: nowrap
result="avp BTBGI-NE - Misc.esp"
source1="BTB's Game Improvements (Necro Edit).esp"
tes3cmd="./tes3cmd"

# 2022-07-19 - Remove Religions Elaborated as no longer needed when using Religions Elaborated Lite Edition
# Religions Elaborated
# $tes3cmd dump "${source1}" --raw-with-header "${result}" --type NPC_ \
#   --exact-id "syloria siruliulus"
# $tes3cmd modify "${result}" --hide-backups --type NPC_ \
#   --exact-id "syloria siruliulus" --run "\$R->append(NPC_::SCRI->new({'script', 'WaitOneDay'}))"

# Sotha Sil Expanded
$tes3cmd dump "${source1}" --raw-with-header "${result}" \
  --exact-id "repair_prongs" \
  --exact-id "potion_comberry_brandy_01" \
  --exact-id "ingred_wolf_pelt"

# 2022-07-20 - Remove Rise of House Sadras as I no longer use that mod
# The Rise of House Sadras
# $tes3cmd dump "${source1}" --raw "${result}" --type INGR \
#   --exact-id "ingred_rat_meat_01"

# Thief experience overhaul 
$tes3cmd dump "${source1}" --raw "${result}" --type SPEL \
  --exact-id "great open" \
  --exact-id "strong open" \
  --exact-id "wild open" \
  --exact-id "open" \
  --exact-id "ondusi's open door"
# Change: 2021-01-10 - Use BTB's version of Open Spells instead of Thief Experience Overhaul version
# "Thief Experience Overhaul 1.3b (Tribunal) (Combined).esp"
# $tes3cmd modify "${result}" --hide-backups --type SPEL --exact-id "great open"         --run "\$R->set({t=>'SPDT',f=>'Flags'}, '0')"
# $tes3cmd modify "${result}" --hide-backups --type SPEL --exact-id "strong open"        --run "\$R->set({t=>'SPDT',f=>'Flags'}, '0')"
# $tes3cmd modify "${result}" --hide-backups --type SPEL --exact-id "wild open"          --run "\$R->set({t=>'SPDT',f=>'Flags'}, '0')"
# $tes3cmd modify "${result}" --hide-backups --type SPEL --exact-id "open"               --run "\$R->set({t=>'SPDT',f=>'Flags'}, '0')"
# $tes3cmd modify "${result}" --hide-backups --type SPEL --exact-id "ondusi's open door" --run "\$R->set({t=>'SPDT',f=>'Flags'}, '0')"

# Wanderers of Solstheim
$tes3cmd dump "${source1}" --raw "${result}" --type INGR \
  --exact-id "ingred_snowwolf_pelt_unique" \
  --exact-id "ingred_snowbear_pelt_unique"

# Morag Tong Polished
$tes3cmd dump "${source1}" --raw "${result}" --type ENCH \
  --exact-id "dagger_mtas"

# Final action just in case
$tes3cmd header "${result}" --hide-backups --update-record-count

# Create dir and move files there
mkdir -v "04 Misc"
mv -v\
  "avp BTBGI-NE - Misc.esp"\
  "04 Misc"/
