// ADD stan CD_STATE_NOTVALID

APPEND ~STATE.IDS~ ~0x80101FEF CD_STATE_NOTVALID~
UNLESS ~CD_STATE_NOTVALID~ 

//LOAD

LOAD_TRA ~TangledIsle/translations/%LANGUAGE%/install.tra~

//JOURNAL

ACTION_IF GAME_IS ~bg2ee eet~ THEN BEGIN
  ADD_JOURNAL @0 @1 @2 @3 @4 @5 @6 @7 @8 @9 @10 @11 @12 @13 @14 @15 @16 @17 @18 @19 @20 @21 @22 @23 @24 @25 @26 @27 @28 @29 @30 @31 @32 @33 @34 @35 @36 @37 @38 @39 @40 @41 @42 @43 @44 @45 @46  USING ~TangledIsle\Translations\%LANGUAGE%\JournalEntries.TRA~
END

ACTION_IF GAME_IS ~SOA TOB BGT~ THEN BEGIN
LOAD_TRA ~TangledIsle/translations/%LANGUAGE%/install.tra~
END

//AREA

COPY ~TangledIsle/areas~ ~override~

ACTION_IF GAME_IS ~BG2EE EET~ THEN BEGIN
  COPY ~TangledIsle/tis+pvrz~ ~override~
 END ELSE BEGIN
  COPY ~TangledIsle/tis~ ~override~
END

COPY_EXISTING ~L#NI18.are~ ~override~
SAY 0x354 @5000 /* The wooden stairs are long gone. This rope is used to reach the top level of the lighthouse, but it looks like the grate on the top is locked. */

COPY_EXISTING ~L#NI01.are~ ~override~
SAY 0x267c @5001 /* The Seven Legs Pub */
SAY 0x2740 @5002 /* The Tangled Oak Isle */


//BG2 AREA COMPATIBILITY
ACTION_IF NOT (GAME_IS ~bgee bg2ee eet~) BEGIN
	ACTION_FOR_EACH are IN
    AR0713 // L#NI05
    AR1103 // L#NI08
    AR1606 // L#NI10
    AR0707 // L#NI11
    AR1510 // L#NI17
  BEGIN
    COPY_EXISTING ~%are%.tis~ ~override~
                  ~%are%.wed~ ~override~
                  ~%are%.mos~ ~override~
                  ~%are%HT.bmp~ ~override~
                  ~%are%LM.bmp~ ~override~
                  ~%are%SR.bmp~ ~override~
  END
END

//BAM

COPY ~TangledIsle/bam-animations~ ~override~

ACTION_IF GAME_IS ~BG2EE EET~ THEN BEGIN
  COPY ~TangledIsle/bam-itemiconsee~ ~override~
  COPY ~TangledIsle/bam-descriptions~ ~override~
 END ELSE BEGIN
  COPY ~TangledIsle/bam-itemiconsnotee~ ~override~
  COPY ~TangledIsle/bam-descriptionsnotee~ ~override~
END


//EFFECTS

COPY ~TangledIsle/effects~ ~override~



//DIALOGUES

COMPILE ~TangledIsle/dialogues/L#NISTA.d~
COMPILE ~TangledIsle/dialogues/L#NIFINN.d~
COMPILE ~TangledIsle/dialogues/L#NIDRUI.d~
COMPILE ~TangledIsle/dialogues/L#NICLE.d~
COMPILE ~TangledIsle/dialogues/L#NIJAA.d~
COMPILE ~TangledIsle/dialogues/L#NIDOG.d~
COMPILE ~TangledIsle/dialogues/L#NIBAA.d~
COMPILE ~TangledIsle/dialogues/HAQUAT.d~
COMPILE ~TangledIsle/dialogues/L#NIDICC.d~
COMPILE ~TangledIsle/dialogues/L#NICBB.d~
COMPILE ~TangledIsle/dialogues/L#NISST.d~
COMPILE ~TangledIsle/dialogues/L#NIVOI.d~
COMPILE ~TangledIsle/dialogues/L#NIH01.d~
COMPILE ~TangledIsle/dialogues/L#NIH02.d~
COMPILE ~TangledIsle/dialogues/BINNKEEP.d~
COMPILE ~TangledIsle/dialogues/L#NIH03.d~
COMPILE ~TangledIsle/dialogues/L#NIBC.d~
COMPILE ~TangledIsle/dialogues/L#NITPA.d~
COMPILE ~TangledIsle/dialogues/L#NITAV.d~
COMPILE ~TangledIsle/dialogues/L#NIMF0.d~
COMPILE ~TangledIsle/dialogues/L#NINOB.d~
COMPILE ~TangledIsle/dialogues/RIBALD.d~
COMPILE ~TangledIsle/dialogues/L#NIPOP.d~
COMPILE ~TangledIsle/dialogues/L#NIOOD.d~
COMPILE ~TangledIsle/dialogues/L#NICMM.d~
COMPILE ~TangledIsle/dialogues/L#NICMF.d~
COMPILE ~TangledIsle/dialogues/L#NIFIS.d~
COMPILE ~TangledIsle/dialogues/L#NISGR.d~
COMPILE ~TangledIsle/dialogues/L#NISMC.d~
COMPILE ~TangledIsle/dialogues/L#NIMER1.d~
COMPILE ~TangledIsle/dialogues/L#NIMER2.d~
COMPILE ~TangledIsle/dialogues/L#NIXVA.d~
COMPILE ~TangledIsle/dialogues/L#NICUT.d~
COMPILE ~TangledIsle/dialogues/L#NI6CQ.d~


//SCRIPTS

COMPILE ~TangledIsle/scripts/L#NI01.baf~ EVAL
COMPILE ~TangledIsle/scripts/L#NI02.baf~
COMPILE ~TangledIsle/scripts/L#NI05.baf~
COMPILE ~TangledIsle/scripts/L#NI06.baf~
COMPILE ~TangledIsle/scripts/L#NI07.baf~
COMPILE ~TangledIsle/scripts/L#NI11.baf~
COMPILE ~TangledIsle/scripts/L#NI12.baf~
COMPILE ~TangledIsle/scripts/L#NI14.baf~
COMPILE ~TangledIsle/scripts/L#NI15.baf~
COMPILE ~TangledIsle/scripts/L#NI16.baf~
COMPILE ~TangledIsle/scripts/L#NI17.baf~
COMPILE ~TangledIsle/scripts/L#NI18.baf~
COMPILE ~TangledIsle/scripts/L#NIDOG.baf~
COMPILE ~TangledIsle/scripts/L#NISECR.baf~
COMPILE ~TangledIsle/scripts/L#NIBAA.baf~
COMPILE ~TangledIsle/scripts/L#NISST.baf~
COMPILE ~TangledIsle/scripts/L#NIHOU.baf~
COMPILE ~TangledIsle/scripts/L#NIVOI.baf~
COMPILE ~TangledIsle/scripts/L#NIBRI.baf~
COMPILE ~TangledIsle/scripts/L#NISCR.baf~
COMPILE ~TangledIsle/scripts/L#NIMF0.baf~
COMPILE ~TangledIsle/scripts/L#NITAV.baf~
COMPILE ~TangledIsle/scripts/L#NIOOD.baf~
COMPILE ~TangledIsle/scripts/L#NI6CQ.baf~
COMPILE ~TangledIsle/scripts/L#NICS1.baf~
COMPILE ~TangledIsle/scripts/L#NICS2.baf~
COMPILE ~TangledIsle/scripts/L#NICS3.baf~
COMPILE ~TangledIsle/scripts/L#NIMF5.baf~
COMPILE ~TangledIsle/scripts/L#NIMF6.baf~
COMPILE ~TangledIsle/scripts/L#NIMER2.baf~
COMPILE ~TangledIsle/scripts/L#NISTA.baf~

EXTEND_TOP    ~AR1200.bcs~   ~TangledIsle/scripts/AR1200.baf~
EXTEND_BOTTOM ~AR0500.bcs~   ~TangledIsle/scripts/AR0500.baf~
EXTEND_BOTTOM ~BALDUR.bcs~   ~TangledIsle/scripts/JournalEntries.baf~


//CREATURES

COPY ~TangledIsle/creatures/L#NIOOD.CRE~ ~override~
SAY NAME1 @5003 /* Angry Man */
SAY NAME2 @5003 /* Angry Man */

COPY ~TangledIsle/creatures/L#NISTA.CRE~ ~override~
SAY NAME1 @5004 /* Crow Trommoc */
SAY NAME2 @5004 /* Crow Trommoc */

COPY ~TangledIsle/creatures/L#NIFINN.CRE~ ~override~
SAY NAME1 @5005 /* Finn */
SAY NAME2 @5005 /* Finn */

COPY ~TangledIsle/creatures/L#NIDRUI.CRE~ ~override~
SAY NAME1 @5006 /* Oola */
SAY NAME2 @5006 /* Oola */

COPY ~TangledIsle/creatures/L#NICLE.CRE~ ~override~
SAY NAME1 @5007 /* Priestress of Umberlee */
SAY NAME2 @5007 /* Priestress of Umberlee */

COPY ~TangledIsle/creatures/L#NIJAA.CRE~ ~override~
SAY NAME1 @5008 /* Jaalv */
SAY NAME2 @5008 /* Jaalv */

COPY ~TangledIsle/creatures/L#NIJAA2.CRE~ ~override~
SAY NAME1 @5008 /* Jaalv */
SAY NAME2 @5008 /* Jaalv */

COPY ~TangledIsle/creatures/L#NIJAA3.CRE~ ~override~
SAY NAME1 @5009 /* Tyalavah */
SAY NAME2 @5009 /* Tyalavah */

COPY ~TangledIsle/creatures/L#NIDOG.CRE~ ~override~
SAY NAME1 @5010 /* Mr. Dog */
SAY NAME2 @5010 /* Mr. Dog */

COPY ~TangledIsle/creatures/L#NIBAA.CRE~ ~override~
SAY NAME1 @5011 /* Boy */
SAY NAME2 @5011 /* Boy */

COPY ~TangledIsle/creatures/L#NIDICC.CRE~ ~override~
SAY NAME1 @5012 /* Dicca */
SAY NAME2 @5012 /* Dicca */

COPY ~TangledIsle/creatures/L#NICBB.CRE~ ~override~
SAY NAME1 @5013 /* Nuna */
SAY NAME2 @5013 /* Nuna */

COPY ~TangledIsle/creatures/L#NISST.CRE~ ~override~
SAY NAME1 @5014 /* Sakara */
SAY NAME2 @5014 /* Sakara */

COPY ~TangledIsle/creatures/L#NIVOI.CRE~ ~override~
SAY NAME1 @5015 /* Voice */
SAY NAME2 @5015 /* Voice */

COPY ~TangledIsle/creatures/L#NIH01.CRE~ ~override~
SAY NAME1 @5016 /* Golden-Haired Man */
SAY NAME2 @5016 /* Golden-Haired Man */

COPY ~TangledIsle/creatures/L#NIH02.CRE~ ~override~
SAY NAME1 @5017 /* Pale Man */
SAY NAME2 @5017 /* Pale Man */

COPY ~TangledIsle/creatures/L#NISCR.CRE~ ~override~
SAY NAME1 @5018 /* Illusion */
SAY NAME2 @5018 /* Illusion */

COPY ~TangledIsle/creatures/L#NIH03.CRE~ ~override~
SAY NAME1 @5019 /* Kamma */
SAY NAME2 @5019 /* Kamma */

COPY ~TangledIsle/creatures/L#NIGOL.CRE~ ~override~
SAY NAME1 @5020 /* Faithful Golem */
SAY NAME2 @5020 /* Faithful Golem */

COPY ~TangledIsle/creatures/L#NIBC1.CRE~ ~override~
SAY NAME1 @5021 /* Hron */
SAY NAME2 @5021 /* Hron */

COPY ~TangledIsle/creatures/L#NIBC3.CRE~ ~override~
SAY NAME1 @5021 /* Hron */
SAY NAME2 @5021 /* Hron */

COPY ~TangledIsle/creatures/L#NIBC2.CRE~ ~override~
SAY NAME1 @5022 /* Miga */
SAY NAME2 @5022 /* Miga */

COPY ~TangledIsle/creatures/L#NIBC4.CRE~ ~override~
SAY NAME1 @5022 /* Miga */
SAY NAME2 @5022 /* Miga */

COPY ~TangledIsle/creatures/L#NITAV.CRE~ ~override~
SAY NAME1 @5023 /* Bartender */
SAY NAME2 @5023 /* Bartender */

COPY ~TangledIsle/creatures/L#NITPA1.CRE~ ~override~
SAY NAME1 @5024 /* Pub patron */
SAY NAME2 @5024 /* Pub patron */

COPY ~TangledIsle/creatures/L#NITPA2.CRE~ ~override~
SAY NAME1 @5024 /* Pub patron */
SAY NAME2 @5024 /* Pub patron */

COPY ~TangledIsle/creatures/L#NIMF0.CRE~ ~override~
SAY NAME1 @5025 /* Ila'thashagh */
SAY NAME2 @5025 /* Ila'thashagh */

COPY ~TangledIsle/creatures/L#NINOB.CRE~ ~override~
SAY NAME1 @5026 /* Antisocial Noble */
SAY NAME2 @5026 /* Antisocial Noble */

COPY ~TangledIsle/creatures/L#NIPOP.CRE~ ~override~
SAY NAME1 @5027 /* Pop */
SAY NAME2 @5027 /* Pop */

COPY ~TangledIsle/creatures/L#NICMM1.CRE~ ~override~
SAY NAME1 @5028 /* Commoner */
SAY NAME2 @5028 /* Commoner */

COPY ~TangledIsle/creatures/L#NICMM2.CRE~ ~override~
SAY NAME1 @5028 /* Commoner */
SAY NAME2 @5028 /* Commoner */

COPY ~TangledIsle/creatures/L#NICMM3.CRE~ ~override~
SAY NAME1 @5028 /* Commoner */
SAY NAME2 @5028 /* Commoner */

COPY ~TangledIsle/creatures/L#NICMM4.CRE~ ~override~
SAY NAME1 @5028 /* Commoner */
SAY NAME2 @5028 /* Commoner */

COPY ~TangledIsle/creatures/L#NICMM5.CRE~ ~override~
SAY NAME1 @5028 /* Commoner */
SAY NAME2 @5028 /* Commoner */

COPY ~TangledIsle/creatures/L#NICMM6.CRE~ ~override~
SAY NAME1 @5028 /* Commoner */
SAY NAME2 @5028 /* Commoner */

COPY ~TangledIsle/creatures/L#NICMF1.CRE~ ~override~
SAY NAME1 @5043 /* Commoner */
SAY NAME2 @5043 /* Commoner */

COPY ~TangledIsle/creatures/L#NICMF2.CRE~ ~override~
SAY NAME1 @5043 /* Commoner */
SAY NAME2 @5043 /* Commoner */

COPY ~TangledIsle/creatures/L#NICMF3.CRE~ ~override~
SAY NAME1 @5043 /* Commoner */
SAY NAME2 @5043 /* Commoner */

COPY ~TangledIsle/creatures/L#NICMF4.CRE~ ~override~
SAY NAME1 @5043 /* Commoner */
SAY NAME2 @5043 /* Commoner */

COPY ~TangledIsle/creatures/L#NICMF5.CRE~ ~override~
SAY NAME1 @5043 /* Commoner */
SAY NAME2 @5043 /* Commoner */

COPY ~TangledIsle/creatures/L#NICMF6.CRE~ ~override~
SAY NAME1 @5043 /* Commoner */
SAY NAME2 @5043 /* Commoner */

COPY ~TangledIsle/creatures/L#NISGR.CRE~ ~override~
SAY NAME1 @5029 /* Sad Girl */
SAY NAME2 @5029 /* Sad Girl */

COPY ~TangledIsle/creatures/L#NIFIS.CRE~ ~override~
SAY NAME1 @5030 /* Fish Merchant */
SAY NAME2 @5030 /* Fish Merchant */

COPY ~TangledIsle/creatures/L#NISMC.CRE~ ~override~
SAY NAME1 @5031 /* Fishing Lure Merchant */
SAY NAME2 @5031 /* Fishing Lure Merchant */

COPY ~TangledIsle/creatures/L#NIMER1.CRE~ ~override~
SAY NAME1 @5032 /* Merchant */
SAY NAME2 @5032 /* Merchant */

COPY ~TangledIsle/creatures/L#NIMER2.CRE~ ~override~
SAY NAME1 @5032 /* Merchant */
SAY NAME2 @5032 /* Merchant */

COPY ~TangledIsle/creatures/L#NIXVA.CRE~ ~override~
SAY NAME1 @5033 /* Moomik */
SAY NAME2 @5033 /* Moomik */

COPY ~TangledIsle/creatures/L#NISNA.CRE~ ~override~
SAY NAME1 @5034 /* Tromblo */
SAY NAME2 @5034 /* Tromblo */

COPY ~TangledIsle/creatures/L#NICUT.CRE~ ~override~
SAY NAME1 @5035 /* Jacc Fork */
SAY NAME2 @5035 /* Jacc Fork */

COPY ~TangledIsle/creatures/L#NI6CQ.CRE~ ~override~
SAY NAME1 @5036 /* Nikt */
SAY NAME2 @5036 /* Nikt */

COPY ~TangledIsle/creatures/L#NIMF5.CRE~ ~override~
SAY NAME1 @5037 /* Uklj the Serpent of Infinity */
SAY NAME2 @5037 /* Uklj the Serpent of Infinity */

COPY ~TangledIsle/creatures/L#NIMF6.CRE~ ~override~
SAY NAME1 @5038 /* Ukk'an the Bone of Wrath */
SAY NAME2 @5038 /* Ukk'an the Bone of Wrath */


//STORES

COPY ~TangledIsle/stores/L#nidru.sto~  ~override~
  SAY 0xc @5039 /* Tangled Oak's Village Druid */

COPY ~TangledIsle/stores/L#nicle.sto~  ~override~
  SAY 0xc @5040 /* Tangled Oak's Umberlee Temple */
  
COPY ~TangledIsle/stores/L#nidicc.sto~  ~override~
  SAY 0xc @5041 /* Dicca's Store */

COPY ~TangledIsle/stores/L#nicbb.sto~  ~override~
  SAY 0xc @5042 /* Nuna's Cheap B&B */
  
COPY ~TangledIsle/stores/L#nitav.sto~  ~override~
  SAY 0xc @5001 /* The Seven Legs Pub */  
  
COPY ~TangledIsle/stores/L#nipop.sto~  ~override~
  SAY 0xc @5027 /* Pop */  
  
COPY ~TangledIsle/stores/L#nimer1.sto~  ~override~
  SAY 0xc @5032 /* Merchant */  

COPY ~TangledIsle/stores/L#nimer2.sto~  ~override~
  SAY 0xc @5032 /* Merchant */  


/////////////////////////////////////////////////
/////////////////////////////////////////////////

// map icon index in mapicons.bam
ACTION_IF GAME_IS ~eet~ BEGIN
  ACTION_DEFINE_ASSOCIATIVE_ARRAY remapped_icons BEGIN 10 => 181 END
END ELSE ACTION_IF GAME_IS ~bg2ee~ BEGIN
  INCLUDE ~%MOD_FOLDER%/Worldmap/add_map_icons_ee.tpa~
  LAF ADD_MAP_ICONS_EE STR_VAR path_to_icons = EVAL ~%MOD_FOLDER%/Worldmap/ee/icon.bam~ patch_to_pvrz = EVAL ~%MOD_FOLDER%/Worldmap/ee~ RET new_icon_index END
  ACTION_DEFINE_ASSOCIATIVE_ARRAY remapped_icons BEGIN 10 => ~%new_icon_index%~ END
  STRING_SET 23084 @4000300 //Traveling Hours -> Hours
  STRING_SET 5684 @4000301 //Destination Unreachable -> Unreachable
END ELSE BEGIN //bg2, bgt
  INCLUDE ~%MOD_FOLDER%/Worldmap/add_map_icons.tpa~
  LAF ADD_MAP_ICONS STR_VAR path_to_icons = EVAL ~%MOD_FOLDER%/Worldmap/bg/icon.bam~ RET new_icon_index END
  ACTION_DEFINE_ASSOCIATIVE_ARRAY remapped_icons BEGIN 10 => ~%new_icon_index%~ END
END

// patch WMP using TBL files
INCLUDE ~%MOD_FOLDER%/Worldmap/add_worldmap_tbl.tpa~
LAF ADD_WORLDMAP_TBL
  INT_VAR
  verbose = 0
  inclSv = include_saves
  add_x = wmp_xCoord_SoA
  add_y = wmp_yCoord_SoA
  patch_bp_files = 1
  patch_mastarea = 1
  STR_VAR
  path_to_areas = EVAL ~%MOD_FOLDER%/Worldmap/areas_bg2.tbl~
  path_to_areas_bp = EVAL ~%MOD_FOLDER%/Worldmap/areas.tbl~
  path_to_links = EVAL ~%MOD_FOLDER%/Worldmap/links.tbl~
  path_to_trans = EVAL ~%MOD_FOLDER%/Translations/%LANGUAGE%/worldmap.tra~
  icons_table = remapped_icons
END

//ITEMS

ACTION_IF GAME_IS ~bg2 tob bgt~ THEN BEGIN
LOAD_TRA ~TangledIsle/translations/%LANGUAGE%/items.tra~
INCLUDE ~%MOD_FOLDER%/lib/items.tpa~
END

ACTION_IF GAME_IS ~bg2ee eet~ THEN BEGIN
LOAD_TRA ~TangledIsle/translations/%LANGUAGE%/items_ee.tra~
INCLUDE ~%MOD_FOLDER%/lib/items_ee.tpa~
END