ACTION_IF GAME_IS ~bg2ee eet~ THEN BEGIN
    ADD_JOURNAL @100 @101 @102 @103 @104 @105 @106 @107 @108 @109 @110 @111 @112 @113 @114 @115 @116 @117 @118 @119 @120 @121 @122 @123 @124 @125 @126 @127 @128 @129

    COPY_EXISTING ~ea20.ini~ ~override~ // patch BG2EE's unused SHADOW_LARGE animation to add missing height_offset line
      REPLACE_TEXTUALLY ~walk_sound=~ // in the original game file there is a blank line between
~height_offset=100
walk_sound=~
    UNLESS ~height_offset~
    BUT_ONLY 
END


////////////////////////////////Add CD_STATE_NOTVALID state

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


////////////////////////////////AREAS

COPY ~Innershade/AREAS/ARE~ ~override~
COPY ~Innershade/AREAS/BMP~ ~override~
COPY ~Innershade/AREAS/SLH~ ~override~
COPY ~Innershade/AREAS/WED~ ~override~

ACTION_IF GAME_IS ~bg2ee eet~ THEN BEGIN
  COPY ~Innershade/EE/AREAS/TIS~    ~override~      // use v2-format TIS files
  COPY ~Innershade/EE/AREAS/PVRZ~   ~override~      // PVRZ tiles for v2 TIS files
  COPY ~Innershade/EE/AREAS/MOS~    ~override~      // use larger MOS minimap files
END ELSE BEGIN // not Enhanced Edition
  COPY ~Innershade/AREAS/TIS~       ~override~      // use v1-format TIS files
  COPY ~Innershade/AREAS/MOS~       ~override~      // use smaller MOS minimap files
END

////////////////////////////////BAMS

COPY ~Innershade/BAMS~ ~override~


////////////////////////////////PORTRAITS

COPY ~Innershade/PORTRAITS~ ~override~


////////////////////////////////CREATURES

ACTION_DEFINE_ASSOCIATIVE_ARRAY cre_array BEGIN
  // unique-id, NAME1, NAME2 => CRE file (animation ID, for reference)
  1,  1,  1  => 9xDOG.cre       // 0x7B00 WOLF
  2,  2,  2  => 9xBARD.cre      // 0x6301 THIEF_MALE_ELF
  3,  3,  3  => 9xCC.cre        // 0xC700 BOY
  4,  4,  4  => 9xCOMM1.cre     // 0xC900 PEASANT_MAN
  5,  4,  4  => 9xCOMM2.cre     // 0xC700 BOY
  6,  4,  4  => 9xCOMM3.cre     // 0xC900 PEASANT_MAN
  7,  4,  4  => 9xCOMM4.cre     // 0xC610 HARLOT_WOMAN
  8,  4,  4  => 9xCOMM5.cre     // 0xC900 PEASANT_MAN
  9,  4,  4  => 9xCOMM6.cre     // 0xC910 PEASANT_WOMAN
  10, 5,  5  => 9xDAD.cre       // 0xC900 PEASANT_MAN
  11, 6,  6  => 9xE1.cre        // 0xB300 STATIC_BOY
  12, 6,  6  => 9xE2.cre        // 0xC600 BEGGAR_MAN
  13, 6,  6  => 9xE3.cre        // 0x7702 GHAST
  14, 6,  6  => 9xE4.cre        // 0x7703 SHADOW
  15, 6,  6  => 9xE5.cre        // 0x7312 ELEMENTAL_FIRE_PURPLE
  16, 6,  6  => 9xE6.cre        // 0xB300 STATIC_BOY
  17, 7,  7  => 9xE7.cre        // 0x7F10 RAKSHASA
  18, 8,  8  => 9xEA.cre        // 0x7703 SHADOW
  19, 8,  8  => 9xEB.cre        // 0x7703 SHADOW
  20, 8,  8  => 9xEC.cre        // 0x7703 SHADOW
  21, 8,  8  => 9xED.cre        // 0x7703 SHADOW
  22, 8,  8  => 9xEE.cre        // 0x7703 SHADOW
  23, 8,  8  => 9xEF.cre        // 0x6201 MAGE_MALE_ELF
  24, 9,  9  => 9xElF.cre       // 0x6201 MAGE_MALE_ELF
  25, 10, 10 => 9xEva.cre       // 0x6110 FIGHTER_FEMALE_HUMAN
  26, 11, 11  => 9xFood.cre      // 0xC800 FAT_MAN
  27, 12, 12  => 9xGBoy.cre      // 0xC700 BOY
  28, 12, 12  => 9xOBoy.cre      // 0xC700 BOY
  29, 13, 13  => 9xGENIE.cre     // 0x7F05 DJINNI
  30, 14, 14  => 9xHeal.cre      // 0x6000 CLERIC_MALE_HUMAN
  31, 15, 15  => 9xKat.cre       // 0x6011 CLERIC_FEMALE_ELF
  32, 16, 16  => 9xMiner.cre     // 0x6100 FIGHTER_MALE_HUMAN
  33, 17, 17  => 9xOLady.cre     // 0xC910 PEASANT_WOMAN
  34, 17, 17  => 9xOLady2.cre    // 0x6110 FIGHTER_FEMALE_HUMAN
  35, 18, 18  => 9xP1.cre        // 0x6000 CLERIC_MALE_HUMAN
  36, 18, 18  => 9xP2.cre        // 0x6000 CLERIC_MALE_HUMAN
  37, 19, 19  => 9xStoryT.cre    // 0xC700 BOY
  38, 20, 20  => 9xWC.cre        // 0x6100 FIGHTER_MALE_HUMAN
  39, 21, 21  => 9xWitch.cre     // 0x4300 STATIC_SPIDER_WOMAN
  40, 21, 21  => 9xWitch2.cre    // 0x6210 MAGE_FEMALE_HUMAN
END

ACTION_PHP_EACH cre_array AS strings => crefile BEGIN
  COPY ~Innershade/CREATURES/%crefile%~ ~override~
    SPRINT ref1 ( AT "strings_1" )
    SPRINT ref2 ( AT "strings_2" )
    SAY_EVALUATED NAME1              ~%ref1%~
    SAY_EVALUATED NAME2              ~%ref2%~

    READ_LONG 0x28 currentanim
    PATCH_IF (currentanim == 0x7703 && GAME_IS ~bg2ee eet~) BEGIN // SHADOW
      WRITE_LONG 0x28 0xEA20 // change animation to SHADOW_LARGE (EE-only)
    END
END

ACTION_IF GAME_IS ~bg2ee eet~ THEN BEGIN
COPY ~Innershade/msh2~ ~override~
END

COPY ~Innershade/CREATURES/9xNMP.cre~ ~override~ // Mugger with map to spawn in Waukeen's Promenade


///////////////////////////////////STORES

COPY ~Innershade/STORES/ISHEVA.sto~  ~override/ISHEVA.sto~
  SAY 0xc @22

COPY ~Innershade/STORES/ISHFOOD.sto~  ~override/ISHFOOD.sto~
  SAY 0xc @23
  
COPY ~Innershade/STORES/ISHHEAL.sto~  ~override/ISHHEAL.sto~
  SAY 0xc @24

//////////////////////////////////TEXT SCREEN

ACTION_IF GAME_IS ~bg2ee eet~ THEN BEGIN
  COPY ~Innershade/EE/TEXTSCREEN/ISHTXT.mos~  ~override~ // use larger text screen background
END ELSE BEGIN // not Enhanced Edition
  COPY ~Innershade/TEXTSCREEN/ISHTXT.mos~     ~override~ // use smaller text screen background
END

COPY ~Innershade/TEXTSCREEN/ISHTXT.2da~ ~override~
    REPLACE ~1001~ @25


/////////////////////////////////SOUNDS

ACTION_IF ("%LANGUAGE%" STR_EQ "Polski") THEN BEGIN
  COPY ~Innershade/InnerAudio/SOUNDSPolski~ ~Innershade/SOUNDS~
END
 
LAF HANDLE_AUDIO
  STR_VAR
    audio_path = ~Innershade/SOUNDS~
END

/////////////////////////////////SPELLS

COPY ~Innershade/SPELLS/ISH.spl~ ~override/ISH.spl~
  SAY NAME1 @26
  SAY NAME2 @26
  SAY UNIDENTIFIED_DESC ~This ability allows <CHARNAME> to speak with the Dream that's living inside <PRO_HIMHER>.~

COPY ~Innershade/SPELLS/ISHDE.spl~ ~override/ISHDE.spl~
  SAY NAME1 @27
  SAY NAME2 @27

COPY ~Innershade/SPELLS/ISHBAR.spl~ ~override/ISHBAR.spl~
  SAY NAME1 @28
  SAY NAME2 @28
  SAY UNIDENTIFIED_DESC ~The spell heals restores 40 Hit Points to all party members, heals poion, disease, deafness and blindness. However, once party members are healed, caster's hit points get reduced to 1 Hit Point.~
  
COPY ~Innershade/SPELLS/ISHBARE.spl~ ~override/ISHBARE.spl~
  SAY NAME1 ~~
  SAY NAME2 ~~

COPY ~Innershade/SPELLS/ISHSPL1.spl~ ~override/ISHSPL1.spl~
  SAY NAME1 @29
  SAY NAME2 @29
  SAY UNIDENTIFIED_DESC ~This ability allows <CHARNAME> to change into true Dreamer's Form for 1 Turn. In such state, the caster:
- Gains 25% magic resistance
- Gains immunity to backstab
- Gains immunity to timestop
- Gains 30% immunity to all physical damage types
- Gains +2 armor class bonus
- Gains +2 strength bonus
- Gains +2 spellcasting speed~


/////////////////////////////////ITEMS

ACTION_IF GAME_IS ~bg2ee eet~ THEN BEGIN
  ACTION_IF ("%LANGUAGE%" STR_EQ "English") THEN BEGIN
   LOAD_TRA ~Innershade/Translations/English/setup_ee.tra~
  END
END

ACTION_DEFINE_ASSOCIATIVE_ARRAY itm_array BEGIN
  // unique-id, NAME1, NAME2, DESC => ITM file
  1,  30, 30, 31  => ISH0.itm
  2,  32, 32, 33  => ISHMAP.itm
  3,  34, 34, 35  => ISHF001.itm
  4,  36, 36, 37  => ISHF002.itm
  5,  38, 38, 39  => ISHF003.itm
  6,  40, 40, 41  => ISHF004.itm
  7,  42, 42, 43  => ISHF005.itm
  8,  44, 44, 45  => ISHF006.itm
  9,  46, 46, 47  => ISHF007.itm
  10, 48, 48, 49  => ISHF008.itm
  11, 50, 50, 51  => ISHF009.itm
  12, 52, 52, 53  => ISHF010.itm
  13, 54, 54, 55  => ISHELT1.itm
  14, 54, 54, 56  => ISHELT2.itm
  15, 57, 57, 58  => ISHG1.itm
  16, 59, 59, 60  => ISHP1.itm
  17, 61, 61, 62  => ISHP2.itm
  18, 63, 63, 64  => ISHWAND.itm
  19, 65, 65, 66  => ISHCHA.itm
  20, 67, 67, 68  => ISHHAM.itm
  21, 69, 69, 70  => ISHB.itm
END

ACTION_PHP_EACH itm_array AS strings => itmfile BEGIN
  COPY ~Innershade/ITEMS/%itmfile%~ ~override~
    SPRINT ref1 ( AT "strings_1" )
    SPRINT ref2 ( AT "strings_2" )
    SPRINT ref3 ( AT "strings_3" )
    SAY_EVALUATED NAME1              ~%ref1%~
    SAY_EVALUATED NAME2              ~%ref2%~
    SAY_EVALUATED IDENTIFIED_DESC    ~%ref3%~
    SAY_EVALUATED UNIDENTIFIED_DESC  ~%ref3%~
END


//////////////////////////////////MAP

COPY_EXISTING ~ribald.sto~ ~override/ribald.sto~
  ADD_STORE_ITEM ~ISHMAP~ #10 #0 #0 ~IDENTIFIED~ #1

COPY_EXISTING ~ribald2.sto~ ~override/ribald2.sto~
  ADD_STORE_ITEM ~ISHMAP~ #10 #0 #0 ~IDENTIFIED~ #1

COPY_EXISTING ~ribald3.sto~ ~override/ribald3.sto~
  ADD_STORE_ITEM ~ISHMAP~ #10 #0 #0 ~IDENTIFIED~ #1

// also add Innershade map to mugger in Athkatla Bridge District
COPY_EXISTING ~BMUGG1.cre~ ~override~
  PATCH_IF (SOURCE_SIZE > 0x2d3) THEN BEGIN
    ADD_CRE_ITEM ~ISHMAP~ #0 #0 #0 ~NONE~ ~inv~
  END


/////////////////////////////////DIALOGUES

COMPILE ~Innershade/DIALOGUES/9xAppend.d~
        ~Innershade/DIALOGUES/9xBard.d~
        ~Innershade/DIALOGUES/9xCC.d~
        ~Innershade/DIALOGUES/9xCOMM.d~
        ~Innershade/DIALOGUES/9xElF.d~
        ~Innershade/DIALOGUES/9xENEMY.d~
        ~Innershade/DIALOGUES/9xEva.d~
        ~Innershade/DIALOGUES/9xFood.d~
        ~Innershade/DIALOGUES/9xGBoy.d~
        ~Innershade/DIALOGUES/9xGenie.d~
        ~Innershade/DIALOGUES/9xHeal.d~
        ~Innershade/DIALOGUES/9xKat.d~
        ~Innershade/DIALOGUES/9xMiner.d~
        ~Innershade/DIALOGUES/9xOBoy.d~
        ~Innershade/DIALOGUES/9xOLady.d~
        ~Innershade/DIALOGUES/9xOLady2.d~
        ~Innershade/DIALOGUES/9xP1.d~
        ~Innershade/DIALOGUES/9xP2.d~
        ~Innershade/DIALOGUES/9xPiece.d~
        ~Innershade/DIALOGUES/9xPlayer.d~
        ~Innershade/DIALOGUES/9xPPG.d~
        ~Innershade/DIALOGUES/9xStoryT.d~
        ~Innershade/DIALOGUES/9xWC.d~
        ~Innershade/DIALOGUES/9xWitch.d~
        ~Innershade/DIALOGUES/9xDog.d~


//////////////////////////////////SCRIPTS

COMPILE EVALUATE_BUFFER ~Innershade/SCRIPTS/9xEA.baf~
        ~Innershade/SCRIPTS/9xEB.baf~
        ~Innershade/SCRIPTS/9xEC.baf~
        ~Innershade/SCRIPTS/9xED.baf~
        ~Innershade/SCRIPTS/9xEE.baf~
        ~Innershade/SCRIPTS/9xEnemy.baf~
        ~Innershade/SCRIPTS/9xISH.baf~
        ~Innershade/SCRIPTS/9xWitch.baf~
        ~Innershade/SCRIPTS/ARISH1.baf~
        ~Innershade/SCRIPTS/ARISH2.baf~
        ~Innershade/SCRIPTS/ARISH3.baf~
        ~Innershade/SCRIPTS/ARISH4.baf~
        ~Innershade/SCRIPTS/ARISH5.baf~
        ~Innershade/SCRIPTS/ARISH6.baf~
        ~Innershade/SCRIPTS/ARISH7.baf~
        ~Innershade/SCRIPTS/ARISH8.baf~
        ~Innershade/SCRIPTS/ARISH9.baf~
        ~Innershade/SCRIPTS/9xDOG.baf~

EXTEND_TOP   ~AR1513.bcs~   ~Innershade/SCRIPTS/AR1513.baf~
EXTEND_TOP   ~AR0700.bcs~   ~Innershade/SCRIPTS/AR0700.baf~
EXTEND_TOP   ~AR4500.bcs~   ~Innershade/SCRIPTS/AR4500.baf~
EXTEND_TOP   ~Baldur.bcs~   ~Innershade/SCRIPTS/PlayerEX.baf~ EVALUATE_BUFFER
EXTEND_TOP   ~Baldur25.bcs~ ~Innershade/SCRIPTS/PlayerEX.baf~ EVALUATE_BUFFER


//////////////////////////////////BIOWARE NPC TALKS

COMPILE ~Innershade/DIALOGUES/9xAPPEND.d~

EXTEND_TOP      ~AR1513.bcs~   ~Innershade/SCRIPTS/AddAR1513.baf~
EXTEND_TOP      ~ARISH1.bcs~   ~Innershade/SCRIPTS/AddARISH1.baf~
EXTEND_TOP      ~ARISH2.bcs~   ~Innershade/SCRIPTS/AddARISH2.baf~
EXTEND_BOTTOM   ~ARISH6.bcs~   ~Innershade/SCRIPTS/AddARISH6.baf~
EXTEND_TOP      ~ARISH7.bcs~   ~Innershade/SCRIPTS/AddARISH7.baf~
EXTEND_TOP      ~ARISH8.bcs~   ~Innershade/SCRIPTS/AddARISH8.baf~
EXTEND_TOP      ~YOSHIMO.bcs~  ~Innershade/SCRIPTS/YOSHIMO.baf~


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

// map icon index in mapicons.bam
ACTION_IF GAME_IS ~eet~ BEGIN
  ACTION_DEFINE_ASSOCIATIVE_ARRAY remapped_icons BEGIN 9 => 176 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 9 => ~%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 9 => ~%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


// end of main component
