#!/usr/bin/env bash
# Changelog:
# 2021-09-25
#   - Make Blighted Animals Retextured BTBGI Patch after blighed rat got changed in BTBGI - NE 2.0.8
#   - Make patch for diseased shalk, nix-hound after they got changed in BTBGI - NE 2.0.8
#
# 2021-10-16
#   - TriangleTooth's Ecology Mod now contains PFP fixes as well for Plague Bear and Wolf (same way as BTB's diseased creatures - via leveled lists)
#
# 2022-05-10
#   - Switch back to update Bloodmoon Rebalance from "Bloodmoon Rebalance - PFP" Patch as the latter is no longer required
#
# 2022-07-22
#   - Add Sobitur Facility(dahrk mezalf)
#   - Add Dwemer Rebirth Project(dreugh, centurion spider)
#
# 2022-12-03
#   - Increase ash_zombie and ash_zombie_fgaz soul value from 100 to 150 as per Beware the Sixth House v3
#   - Comment out line changing ascended_sleeper's soul value to 400 to let Beware the Sixth House v3 override it with 450
#
# Here i use "tes3cmd modify --replace" with 0.40. To be able to do this i've commented lines 8665-8667 of tes3cmd.
# Regexp validation seems to be broken already, commenting those lines just disables exit on validation error. Now --replace works, just make sure to pass correct regexps ;-)
tes3cmd="./tes3cmd"
# tempfile will be used for modifying lots of LEVC to avoid listing them all 1 by 1
tempfile_levc="tempfile_levc.esp"

# 01 Rename diseased creatures
result="avp BTBGI-NE - Creature Buffs - Merged.esp"
# $tes3cmd dump "BTBGI Creature Buffs.esp" --raw-with-header "${result}" --type CREA \
#   --exact-id "rat_plague"
# #   --exact-id "alit_blighted" \
# #   --exact-id "alit_diseased" \
# #   --exact-id "cliff racer_blighted" \
# #   --exact-id "cliff racer_diseased" \
# #   --exact-id "kagouti_blighted" \
# #   --exact-id "kagouti_diseased" \
# #   --exact-id "mudcrab-diseased" \
# #   --exact-id "nix-hound blighted" \
# #   --exact-id "rat_blighted" \
# #   --exact-id "rat_diseased" \
# #   --exact-id "shalk_blighted" \
# #   --exact-id "shalk_diseased"
# $tes3cmd dump "YANDL - Base.esp" --raw "${result}" --type CREA \
#   --exact-id "kwama forager blighted" \
#   --exact-id "kwama warrior blighted" \
#   --exact-id "kwama worker blighted" \
#   --exact-id "kwama worker diseased" \
#   --exact-id "scrib diseased"
# #   --exact-id "bm_bear_brown" \
# #   --exact-id "bm_wolf_red" \
# #   --exact-id "durzog_diseased" \
# #   --exact-id "scrib blighted"
# $tes3cmd header "${result}" --hide-backups --update-record-count
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "rat_plague"           --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Rat')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "alit_blighted"        --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Alit')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "alit_diseased"        --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Alit')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "cliff racer_blighted" --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Cliff Racer')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "cliff racer_diseased" --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Cliff Racer')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "kagouti_blighted"     --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Kagouti')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "kagouti_diseased"     --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Kagouti')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "mudcrab-diseased"     --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Mudcrab')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "nix-hound blighted"   --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Nix-Hound')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "rat_blighted"         --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Rat')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "rat_diseased"         --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Rat')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "shalk_blighted"       --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Shalk')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "shalk_diseased"       --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Shalk')"

# 02 Unique CaveRats

$tes3cmd dump "Unique_CaveRats.ESP" --raw-with-header "${result}" --type CREA
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "rat_cave_fgrh" \
  --exact-id "rat_cave_fgt" --run "\
  \$R->set({t=>'NPDT',f=>'Spd'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '30'), \
  \$R->set({t=>'NPDT',f=>'End'}, '75'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '105'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '50')"

# 03 Blighted Animals Retextured

$tes3cmd dump "BTBGI Creature Buffs.esp" --raw "${result}" --type CREA \
  --exact-id "alit_blighted" \
  --exact-id "cliff racer_blighted" \
  --exact-id "kagouti_blighted" \
  --exact-id "nix-hound blighted" \
  --exact-id "rat_blighted" \
  --exact-id "rat_cave_hhte2" \
  --exact-id "shalk_blighted"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "alit_blighted"        --run "\$R->set({t=>'MODL', f=>'Model'}, 'CAB\\RC\\AlitB.nif')"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "cliff racer_blighted" --run "\$R->set({t=>'MODL', f=>'Model'}, 'CAB\\RC\\CliffRacerB.nif')"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "kagouti_blighted"     --run "\$R->set({t=>'MODL', f=>'Model'}, 'CAB\\RC\\KagoutiB.nif')"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "nix-hound blighted"   --run "\$R->set({t=>'MODL', f=>'Model'}, 'CAB\\RC\\NixHoundB.nif')"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "rat_blighted"         --run "\$R->set({t=>'MODL', f=>'Model'}, 'CAB\\RC\\ratB.nif')"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "rat_cave_hhte2"       --run "\$R->set({t=>'MODL', f=>'Model'}, 'CAB\\RC\\ratB.nif')"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "shalk_blighted"       --run "\$R->set({t=>'MODL', f=>'Model'}, 'CAB\\RC\\ShalkB.nif')"
# Rename
# $tes3cmd dump "YANDL - BlightedAnimalsRetextured.esp" --raw "${result}" --type CREA \
#  --exact-id "scrib blighted"
# $tes3cmd header "${result}" --hide-backups --update-record-count
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "alit_blighted"        --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Alit')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "cliff racer_blighted" --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Cliff Racer')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "kagouti_blighted"     --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Kagouti')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "nix-hound blighted"   --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Nix-Hound')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "rat_blighted"         --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Rat')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "rat_cave_hhte2"       --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Game Rat')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "shalk_blighted"       --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Shalk')"

# 04 Beware The Sixth House

$tes3cmd dump "avp BTBGI-NE - Beware the Sixth House.esp" --raw "${result}" --type CREA
$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=>'NPDT',f=>'Spd'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '120'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '90'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '8'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '8'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '8'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Spell_Points'}, '75'), \
  \$R->set({t=>'NPDT',f=>'Magic'}, '100'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '65'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '400'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '55')"

$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=>'Str'}, '110'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '70'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '110'), \
  \$R->set({t=>'NPDT',f=>'End'}, '110'), \
  \$R->set({t=>'NPDT',f=>'Spell_Points'}, '240'), \
  \$R->set({t=>'NPDT',f=>'Magic'}, '100'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '110'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '600'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '110'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '110')"

$tes3cmd dump "BTBGI Creature Buffs.esp" --raw "${result}" --type CREA \
  --exact-id "ash_zombie" \
  --exact-id "ash_zombie_fgaz" \
  --exact-id "corprus_lame" \
  --exact-id "corprus_lame_morvayn"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "corprus_lame" \
  --exact-id "corprus_lame_morvayn" --run "\
  \$R->set({t=>'NPDT',f=>'Lev'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Str'}, '110'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '160'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '70'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '110'), \
  \$R->set({t=>'NPDT',f=>'End'}, '110'), \
  \$R->set({t=>'NPDT',f=>'Spell_Points'}, '240'), \
  \$R->set({t=>'NPDT',f=>'Magic'}, '100'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '110'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '600'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '110'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '110'), \
  \$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'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '40')"
# 2022-12-03 - Increase ash_zombie and ash_zombie_fgaz soul value from 100 to 150 as per Beware the Sixth House v3
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "ash_zombie" --run "\
  \$R->set({t=>'NPDT',f=>'Lev'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '130'), \
  \$R->set({t=>'NPDT',f=>'Soul'}, '150')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "ash_zombie_fgaz" --run "\
  \$R->set({t=>'NPDT',f=>'Lev'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '600'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Soul'}, '150')"
$tes3cmd dump "Beware the Sixth House.ESP" --raw "${result}" --type CREA \
  --exact-id "ascended_sleeper" \
  --exact-id "ash_slave"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "ash_slave" --run "\
  \$R->set({t=>'NPDT',f=>'Stealth'}, '30')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "ascended_sleeper" --run "\
  \$R->set({t=>'NPDT',f=>'Spd'}, '30')"
# 2022-12-03 - Comment out line changing ascended_sleeper's soul value to 400 to let Beware the Sixth House v3 override it with 450
# \$R->set({t=>'NPDT',f=>'Soul'}, '400')"

# 05 Tribunal Rebalance (rename only)

# $tes3cmd dump "YANDL - tribunal rebalance.esp" --raw "${result}" --type CREA
# $tes3cmd header "${result}" --hide-backups --update-record-count

# 06 Bloodmoon Rebalance (rename only)

# $tes3cmd dump "YANDL - Bloodmoon Rebalance.esp" --raw-with-header "${result}" --type CREA
# $tes3cmd header "${result}" --hide-backups --update-record-count

# 07 Tamriel Data (rename only)

# $tes3cmd dump "YANDL - Tamriel_Data.esp" --raw "${result}" --type CREA
# $tes3cmd header "${result}" --hide-backups --update-record-count
# $tes3cmd delete "${result}" --hide-backups --type CREA \
#   --exact-id "t_mw_fau_muskfds_01" \
#   --exact-id "t_mw_fau_guarfrds_01" \
#   --exact-id "t_mw_fau_guards_01"

# 08 Tamriel Rebuilt (rename only)

# $tes3cmd dump "YANDL - TR_Mainland.esp" --raw "${result}" --type CREA
# $tes3cmd header "${result}" --hide-backups --update-record-count

# 09 Sobitur Facility

$tes3cmd dump "DA_Sobitur_Facility_Clean.ESP" --raw "${result}" --type CREA --exact-id "dahrk mezalf"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "dahrk mezalf" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '70'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '45'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '180'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '75'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '70'), \
  \$R->set({t=>'NPDT',f=>'End'}, '70'), \
  \$R->set({t=>'NPDT',f=>'Magic'}, '100'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '70'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '70'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '800'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '70'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '70'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '35')"
$tes3cmd header "${result}" --hide-backups --update-record-count

# 10 DRPV1.9

# $tes3cmd dump "BTBGI Creature Buffs.esp" --raw-with-header "${result}" --type CREA --exact-id "dreugh"
$tes3cmd dump "DRPV1.9.ESP" --raw "${result}" --type CREA --exact-id "centurion_spider"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "centurion_spider" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '30'), \
  \$R->set({t=>'NPDT',f=>'End'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Spell_Points'}, '50'), \
  \$R->set({t=>'NPDT',f=>'Magic'}, '95'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '65'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '2'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '2'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '2'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '15')"
$tes3cmd header "${result}" --hide-backups --update-record-count

# 11 TriangleTooth's Ecology Mod 

$tes3cmd dump "BTBGI Creature Buffs.esp" --raw "${result}" --type CREA\
  --exact-id "guar_feral" \
  --exact-id "netch_betty" \
  --exact-id "netch_bull" \
  --exact-id "nix-hound"
#   --exact-id "dreugh"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "guar_feral"         --run "\$R->set({t=>'NAME', f=>'ID'},    'avp_btb_guar_feral')"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "avp_btb_guar_feral" --run "\$R->set({t=>'FNAM', f=>'Name'},  'Feral Guar')"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "netch_betty"        --run "\$R->set({t=>'NAME', f=>'ID'},    'avp_btb_netch_betty')"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "netch_bull"         --run "\$R->set({t=>'NAME', f=>'ID'},    'avp_btb_netch_bull')"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "nix-hound"          --run "\$R->set({t=>'NAME', f=>'ID'},    'avp_btb_nix-hound')"
$tes3cmd header "${result}" --hide-backups --update-record-count
# $tes3cmd dump "Patch for Purists.esm" --raw "${result}" --type CREA\
#   --exact-id "bm_bear_brown"\
#   --exact-id "bm_wolf_red"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "bm_bear_brown"      --run "\$R->set({t=>'FNAM', f=>'Name'},  'Bear')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "bm_wolf_red"        --run "\$R->set({t=>'FNAM', f=>'Name'},  'Wolf')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "bm_bear_brown"      --run "\$R->set({t=>'NAME', f=>'ID'},    'avp_pfp_bm_bear_brown')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "bm_wolf_red"        --run "\$R->set({t=>'NAME', f=>'ID'},    'avp_pfp_bm_wolf_red')"
$tes3cmd dump "Ttooth Ecology.esp" --raw "${result}" --type CREA\
  --exact-id "guar_feral" \
  --exact-id "netch_betty" \
  --exact-id "netch_bull" \
  --exact-id "nix-hound"
#  --exact-id "dreugh" \
$tes3cmd dump "Ttooth Ecology.esp" --raw "${result}" --type CREA\
  --exact-id "alit" \
  --exact-id "alit_diseased" \
  --exact-id "cliff racer" \
  --exact-id "cliff racer_diseased" \
  --exact-id "guar" \
  --exact-id "kagouti" \
  --exact-id "kagouti_diseased" \
  --exact-id "mudcrab" \
  --exact-id "mudcrab-diseased" \
  --exact-id "rat" \
  --exact-id "rat_diseased" \
  --exact-id "shalk" \
  --exact-id "shalk_diseased"
$tes3cmd header "${result}" --hide-backups --update-record-count
# $tes3cmd modify "${result}" --hide-backups --type CREA \
#   --exact-id "dreugh" --run "\
#   \$R->set({t=>'NPDT',f=>'Lev'}, '8'), \
#   \$R->set({t=>'NPDT',f=>'Health'}, '120'), \
#   \$R->set({t=>'NPDT',f=>'Soul'}, '75'), \
#   \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '10'), \
#   \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '10'), \
#   \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '10')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "guar_feral" --run "\
  \$R->set({t=>'NPDT',f=>'Spd'}, '65'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '100'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '45'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '65'), \
  \$R->set({t=>'NPDT',f=>'End'}, '65'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '65'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '800'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '65'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '65'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '20')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "netch_betty" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '85'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '145'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '65'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '55'), \
  \$R->set({t=>'NPDT',f=>'End'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '600'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '35')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "netch_bull" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '70'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '60'), \
  \$R->set({t=>'NPDT',f=>'End'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '600'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '20')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "nix-hound" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '45'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '55'), \
  \$R->set({t=>'NPDT',f=>'End'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '500'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '10')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "alit" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '45'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '55'), \
  \$R->set({t=>'NPDT',f=>'End'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Spell_Points'}, '85'), \
  \$R->set({t=>'NPDT',f=>'Magic'}, '85'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '45'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '500'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '3'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '3'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '3'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '12'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '12'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '12')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "alit_diseased" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '50'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '60'), \
  \$R->set({t=>'NPDT',f=>'End'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Magic'}, '100'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '50'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '15')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "cliff racer" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '75'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '55'), \
  \$R->set({t=>'NPDT',f=>'End'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Magic'}, '100'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '600'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '12'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '12'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '12')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "cliff racer_diseased" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '170'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '60'), \
  \$R->set({t=>'NPDT',f=>'End'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Magic'}, '100'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '800'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '8'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '8'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '8'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '24'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '24'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '24')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "guar" --run "\
  \$R->set({t=>'NPDT',f=>'Spd'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '60'), \
  \$R->set({t=>'NPDT',f=>'End'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '50'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '600'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '15')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "kagouti" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '95'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '50'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '35'), \
  \$R->set({t=>'NPDT',f=>'End'}, '75'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '600'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '20')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "kagouti_diseased" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '100'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '55'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '160'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '40'), \
  \$R->set({t=>'NPDT',f=>'End'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '800'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '85'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '35')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "mudcrab" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '20'), \
  \$R->set({t=>'NPDT',f=>'End'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '5')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "mudcrab-diseased" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '25'), \
  \$R->set({t=>'NPDT',f=>'End'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '8'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '8'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '8')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "rat" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '30'), \
  \$R->set({t=>'NPDT',f=>'End'}, '75'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '105'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '50'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '5')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "rat_diseased" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '35'), \
  \$R->set({t=>'NPDT',f=>'End'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '110'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '450'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '50'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '10')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "shalk" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '50'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '65'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '35'), \
  \$R->set({t=>'NPDT',f=>'End'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Spell_Points'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '20')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "shalk_diseased" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '70'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '40'), \
  \$R->set({t=>'NPDT',f=>'End'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Spell_Points'}, '75'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '500'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '25')"
# Ttooth creatures
$tes3cmd dump "Ttooth Ecology.esp" --raw "${result}" --type CREA\
  --exact-id "ttooth_guar" \
  --exact-id "ttooth_mudcrab" \
  --exact-id "ttooth_rat" \
  --exact-id "ttooth_shalk" \
  --exact-id "ttooth_shalk_dom"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "ttooth_guar" --run "\
  \$R->set({t=>'NPDT',f=>'Spd'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '40'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '60'), \
  \$R->set({t=>'NPDT',f=>'End'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '50'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '600'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '15')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "ttooth_mudcrab" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '20'), \
  \$R->set({t=>'NPDT',f=>'End'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '5')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "ttooth_rat" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '15'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '30'), \
  \$R->set({t=>'NPDT',f=>'End'}, '75'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '105'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '50'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '5'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '5')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "ttooth_shalk" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '50'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '65'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '35'), \
  \$R->set({t=>'NPDT',f=>'End'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Spell_Points'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '20')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "ttooth_shalk_dom" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '25'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '50'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '65'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '35'), \
  \$R->set({t=>'NPDT',f=>'End'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Spell_Points'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '35'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '6'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '20')"
# LEVC
$tes3cmd dump "Morrowind.esm" --raw "${result}" --type LEVC --exact-id "in_dae_atronach_lev+2"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --sub-match "Creature_ID:"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --sub-match "Level:"
$tes3cmd modify "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --run "\
  \$R->set({t=>'NAME',f=>'ID'}, 'avp_btb_guar_feral_levc'), \
  \$R->set({t=>'INDX',f=>'Item_Count'}, '3'), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'guar_feral'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'guar_feral'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'avp_btb_guar_feral'})), \
  \$R->append(LEVC::INTV->new({'level', '1'}))"
$tes3cmd dump "Morrowind.esm" --raw "${result}" --type LEVC --exact-id "in_dae_atronach_lev+2"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --sub-match "Creature_ID:"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --sub-match "Level:"
$tes3cmd modify "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --run "\
  \$R->set({t=>'NAME',f=>'ID'}, 'avp_btb_netch_betty_levc'), \
  \$R->set({t=>'INDX',f=>'Item_Count'}, '3'), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'netch_betty'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'netch_betty'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'avp_btb_netch_betty'})), \
  \$R->append(LEVC::INTV->new({'level', '1'}))"
$tes3cmd dump "Morrowind.esm" --raw "${result}" --type LEVC --exact-id "in_dae_atronach_lev+2"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --sub-match "Creature_ID:"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --sub-match "Level:"
$tes3cmd modify "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --run "\
  \$R->set({t=>'NAME',f=>'ID'}, 'avp_btb_netch_bull_levc'), \
  \$R->set({t=>'INDX',f=>'Item_Count'}, '3'), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'netch_bull'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'netch_bull'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'avp_btb_netch_bull'})), \
  \$R->append(LEVC::INTV->new({'level', '1'}))"
$tes3cmd dump "Morrowind.esm" --raw "${result}" --type LEVC --exact-id "in_dae_atronach_lev+2"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --sub-match "Creature_ID:"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --sub-match "Level:"
$tes3cmd modify "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --run "\
  \$R->set({t=>'NAME',f=>'ID'}, 'avp_btb_nix-hound_levc'), \
  \$R->set({t=>'INDX',f=>'Item_Count'}, '3'), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'nix-hound'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'nix-hound'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'avp_btb_nix-hound'})), \
  \$R->append(LEVC::INTV->new({'level', '1'}))"
$tes3cmd dump "Morrowind.esm" --raw "${result}" --type LEVC --exact-id "in_dae_atronach_lev+2"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --sub-match "Creature_ID:"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --sub-match "Level:"
$tes3cmd modify "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --run "\
  \$R->set({t=>'NAME',f=>'ID'}, 'avp_pfp_bm_bear_brown_levc'), \
  \$R->set({t=>'INDX',f=>'Item_Count'}, '3'), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'bm_bear_brown'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'bm_bear_brown'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'avp_pfp_bm_bear_brown'})), \
  \$R->append(LEVC::INTV->new({'level', '1'}))"
$tes3cmd dump "Morrowind.esm" --raw "${result}" --type LEVC --exact-id "in_dae_atronach_lev+2"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --sub-match "Creature_ID:"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --sub-match "Level:"
$tes3cmd modify "${result}" --hide-backups --type LEVC --exact-id "in_dae_atronach_lev+2" --run "\
  \$R->set({t=>'NAME',f=>'ID'}, 'avp_pfp_bm_wolf_red_levc'), \
  \$R->set({t=>'INDX',f=>'Item_Count'}, '3'), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'bm_wolf_red'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'bm_wolf_red'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'avp_pfp_bm_wolf_red'})), \
  \$R->append(LEVC::INTV->new({'level', '1'}))"
$tes3cmd dump "Ttooth Ecology.esp" --raw-with-header "${tempfile_levc}" --type LEVC --match "netch_bull|netch_betty|guar_feral|nix-hound"
$tes3cmd dump "Morrowind.esm" --raw "${tempfile_levc}" --type LEVC \
  --exact-id "ex_ascadianisles_sleep" \
  --exact-id "ex_azurascoast_sleep" \
  --exact-id "ex_bittercoast_sleep" \
  --exact-id "ex_grazelands_sleep" \
  --exact-id "ex_molagmar_sleep" \
  --exact-id "ex_westgash_sleep" \
  --exact-id "ex_wild_all_sleep" \
  --exact-id "in_cave_nix_lev+0" \
  --exact-id "in_cave_nix_lev+2" \
  --exact-id "in_cave_nix_lev-1"
$tes3cmd modify "${tempfile_levc}" --hide-backups --type LEVC --match "_ID:guar_feral"           --replace '/^guar_feral$/avp_btb_guar_feral_levc/'
$tes3cmd modify "${tempfile_levc}" --hide-backups --type LEVC --match "_ID:netch_betty"          --replace '/^netch_betty$/avp_btb_netch_betty_levc/'
$tes3cmd modify "${tempfile_levc}" --hide-backups --type LEVC --match "_ID:netch_bull"           --replace '/^netch_bull$/avp_btb_netch_bull_levc/'
$tes3cmd modify "${tempfile_levc}" --hide-backups --type LEVC --match "_ID:nix-hound"            --replace '/^nix-hound$/avp_btb_nix-hound_levc/'
$tes3cmd dump "Bloodmoon.esm" --raw "${tempfile_levc}" --type LEVC --match "bm_bear_brown|bm_wolf_red"
$tes3cmd modify "${tempfile_levc}" --hide-backups --type LEVC --match "_ID:BM_bear_brown"         --replace '/^BM_bear_brown$/avp_pfp_bm_bear_brown_levc/'
$tes3cmd modify "${tempfile_levc}" --hide-backups --type LEVC --match "_ID:BM_wolf_red"           --replace '/^BM_wolf_red$/avp_pfp_bm_wolf_red_levc/'
$tes3cmd dump "${tempfile_levc}" --raw "${result}" --type LEVC
rm "${tempfile_levc}"
$tes3cmd header "${result}" --hide-backups --update-record-count
# Rename
# $tes3cmd dump "Ttooth Ecology.esp" --raw "${result}" --type CREA\
#  --exact-id "ttooth_wolf_red_pup"\
#  --exact-id "ttooth_bear_brown_cub"
# #  --exact-id "bm_bear_brown"\
# #  --exact-id "bm_wolf_red"
# $tes3cmd header "${result}" --hide-backups --update-record-count
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "shalk_diseased"        --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Shalk')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "cliff racer_diseased"  --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Cliff Racer')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "alit_diseased"         --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Alit')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "kagouti_diseased"      --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Kagouti')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "rat_diseased"          --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Rat')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "mudcrab-diseased"      --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Mudcrab')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "ttooth_wolf_red_pup"   --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Wolf Pup')"
# $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "ttooth_bear_brown_cub" --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Bear Cub')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "bm_bear_brown"         --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Bear')"
# # $tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "bm_wolf_red"           --run "\$R->set({t=>'FNAM', f=>'Name'}, 'Wolf')"

# 12 TriangleTooth's Ecology Mod - Bloodmoon Rebalance (rename only)

# $tes3cmd dump "Bloodmoon Rebalance - PFP.esp" --raw "${result}" --type CREA\
$tes3cmd dump "Bloodmoon Rebalance.esp" --raw "${result}" --type CREA\
  --exact-id "bm_bear_brown"\
  --exact-id "bm_wolf_red"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "bm_bear_brown"      --run "\$R->set({t=>'NAME', f=>'ID'},    'avp_pfp_bm_bear_brown')"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "bm_wolf_red"        --run "\$R->set({t=>'NAME', f=>'ID'},    'avp_pfp_bm_wolf_red')"
# $tes3cmd dump "YANDL - Ttooth Ecology - BMR Patch.esp" --raw "${result}" --type CREA
$tes3cmd header "${result}" --hide-backups --update-record-count

# 13 TriangleTooth's Ecology Mod - Tamriel Rebuilt

$tes3cmd dump "Tamriel_Data.esm" --raw-with-header "${tempfile_levc}" --type LEVC --match "netch_bull|netch_betty|guar_feral|nix-hound"
$tes3cmd modify "${tempfile_levc}" --hide-backups --type LEVC --match "_ID:guar_feral"           --replace '/^guar_feral$/avp_btb_guar_feral_levc/'
$tes3cmd modify "${tempfile_levc}" --hide-backups --type LEVC --match "_ID:netch_betty"          --replace '/^netch_betty$/avp_btb_netch_betty_levc/'
$tes3cmd modify "${tempfile_levc}" --hide-backups --type LEVC --match "_ID:netch_bull"           --replace '/^netch_bull$/avp_btb_netch_bull_levc/'
$tes3cmd modify "${tempfile_levc}" --hide-backups --type LEVC --match "_ID:nix-hound"            --replace '/^nix-hound$/avp_btb_nix-hound_levc/'
$tes3cmd dump "${tempfile_levc}" --raw "${result}" --type LEVC
rm "${tempfile_levc}"
# Rename
# $tes3cmd dump "YANDL - Ttooth Ecology - TR Patch.esp" --raw "${result}" --type CREA
$tes3cmd header "${result}" --hide-backups --update-record-count

# 14 abot Waterlife

$tes3cmd dump "BTBGI Creature Buffs.esp" --raw "${result}" --type CREA \
  --exact-id "dreugh"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "dreugh" --run "\
  \$R->set({t=>'NPDT',f=>'Lev'}, '8'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '120'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '10')"
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "dreugh" --run "\$R->set({t=>'NAME', f=>'ID'}, 'avp_btb_dreugh')"
$tes3cmd dump "BTB's Game Improvements (Necro Edit).esp" --raw "${result}" --type CREA \
  --exact-id "slaughterfish_small"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type CREA --exact-id "slaughterfish_small"   --run "\$R->set({t=>'NAME', f=>'ID'}, 'avp_btb_slfish_small')"
$tes3cmd dump "abotWaterLife.esm" --raw "${result}" --type CREA \
  --exact-id "dreugh" \
  --exact-id "slaughterfish_small"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "dreugh" --run "\
  \$R->set({t=>'NPDT',f=>'Str'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Spd'}, '70'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '75'), \
  \$R->set({t=>'NPDT',f=>'Combat'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Int'}, '60'), \
  \$R->set({t=>'NPDT',f=>'End'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Spell_Points'}, '100'), \
  \$R->set({t=>'NPDT',f=>'Wil'}, '80'), \
  \$R->set({t=>'NPDT',f=>'Per'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Fatigue'}, '600'), \
  \$R->set({t=>'NPDT',f=>'Stealth'}, '30'), \
  \$R->set({t=>'NPDT',f=>'Agi'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Lck'}, '60'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_1'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_2'}, '20'), \
  \$R->set({t=>'NPDT',f=>'Attack_Max_3'}, '20')"
$tes3cmd modify "${result}" --hide-backups --type CREA \
  --exact-id "dreugh" --run "\
  \$R->set({t=>'NPDT',f=>'Lev'}, '8'), \
  \$R->set({t=>'NPDT',f=>'Health'}, '120'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_1'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_2'}, '10'), \
  \$R->set({t=>'NPDT',f=>'Attack_Min_3'}, '10')"
$tes3cmd dump "Morrowind.esm" --raw "${result}" --type LEVC \
  --exact-id "h2o_all_lev+0"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "h2o_all_lev+0" --sub-match "Creature_ID:"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "h2o_all_lev+0" --sub-match "Level:"
$tes3cmd modify "${result}" --hide-backups --type LEVC --exact-id "h2o_all_lev+0" --run "\
  \$R->set({t=>'NAME',f=>'ID'}, 'avp_abot_btb_dreugh_levc'), \
  \$R->set({t=>'NNAM',f=>'Chance_None'}, '0'), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'dreugh'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'dreugh'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'avp_btb_dreugh'})), \
  \$R->append(LEVC::INTV->new({'level', '1'}))"
$tes3cmd dump "Morrowind.esm" --raw "${result}" --type LEVC \
  --exact-id "h2o_all_lev+0"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "h2o_all_lev+0" --sub-match "Creature_ID:"
$tes3cmd delete "${result}" --hide-backups --type LEVC --exact-id "h2o_all_lev+0" --sub-match "Level:"
$tes3cmd modify "${result}" --hide-backups --type LEVC --exact-id "h2o_all_lev+0" --run "\
  \$R->set({t=>'NAME',f=>'ID'}, 'avp_abot_btb_slfish_small_levc'), \
  \$R->set({t=>'NNAM',f=>'Chance_None'}, '0'), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'Slaughterfish_Small'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'Slaughterfish_Small'})), \
  \$R->append(LEVC::INTV->new({'level', '1'})), \
  \$R->append(LEVC::CNAM->new({'creature_id', 'avp_btb_slfish_small'})), \
  \$R->append(LEVC::INTV->new({'level', '1'}))"
$tes3cmd dump "Morrowind.esm" --raw "${result}" --type LEVC \
  --exact-id "h2o_all_lev+2" \
  --exact-id "h2o_all_lev+0" \
  --exact-id "h2o_all_lev-2" \
  --exact-id "h2o_slaughterfish"
$tes3cmd header "${result}" --hide-backups --update-record-count
$tes3cmd modify "${result}" --hide-backups --type LEVC \
  --exact-id "h2o_all_lev+0" \
  --exact-id "h2o_all_lev-2" --run "\
  \$R->set({i=>[6],f=>'Creature_ID'}, 'avp_abot_btb_slfish_small_levc'), \
  \$R->set({i=>[8],f=>'Creature_ID'}, 'avp_abot_btb_dreugh_levc')"
$tes3cmd modify "${result}" --hide-backups --type LEVC \
  --exact-id "h2o_all_lev+2" --run "\
  \$R->set({i=>[4],f=>'Creature_ID'}, 'avp_abot_btb_slfish_small_levc'), \
  \$R->set({i=>[8],f=>'Creature_ID'}, 'avp_abot_btb_dreugh_levc')"
$tes3cmd modify "${result}" --hide-backups --type LEVC \
  --exact-id "h2o_slaughterfish" --run "\
  \$R->set({i=>[4],f=>'Creature_ID'}, 'avp_abot_btb_slfish_small_levc')"

# Create directory structure and move files there
mkdir -pv "08 Creature Buffs - Merged"
mv -v "avp BTBGI-NE - Creature Buffs - Merged.esp" "08 Creature Buffs - Merged"/
