BACKUP ~CtB/backup~

AUTHOR ~Charles Bisson, King Diamond (revision)~  NO_IF_EVAL_BUG

VERSION ~1.13~

AUTO_TRA ~CtB/Language/%s~

LANGUAGE ~English~
	 ~english~
	 ~CtB/Language/English/wsetup.tra~
         ~CtB/Language/English/script.tra~
LANGUAGE ~Russian~
	 ~russian~
	 ~CtB/Language/Russian/wsetup.tra~
         ~CtB/Language/Russian/script.tra~
LANGUAGE ~French~
	 ~french~
	 ~CtB/Language/French/wsetup.tra~
         ~CtB/Language/French/script.tra~
LANGUAGE ~Italian~
	 ~italian~
	 ~CtB/Language/Italian/wsetup.tra~
         ~CtB/Language/Italian/script.tra~
LANGUAGE ~German~
	 ~german~
	 ~CtB/Language/German/wsetup.tra~
         ~CtB/Language/German/script.tra~

LANGUAGE ~Castellano (clan REO)~
	 ~Spanish~
	 ~CtB/Language/Spanish/wsetup.tra~
         ~CtB/Language/Spanish/script.tra~


BEGIN ~Check The Bodies~

COPY + ~Setup-CtB.exe~ ~WeiDU.exe~
COPY + ~Setup-CtB.exe~ ~Setup-CtB-Chores.exe~
COPY + ~chitin.key~ ~CtB/chitin.ctb~
COPY_LARGE + ~dialog.tlk~ ~CtB/dialog.ctb~
MKDIR ~CtB/over.bak~
COPY_LARGE + ~override~ ~CtB/over.bak~
MKDIR ~CTB-ARE~
MKDIR ~CTB-BCS~
MKDIR ~CTB-BAM~
MKDIR ~CTB-CRE~
MKDIR ~CTB-ITM~
MKDIR ~CTB-MOS~
MKDIR ~CTB-RULE~
MKDIR ~CTB-TIS1~
MKDIR ~CTB-TIS2~
MKDIR ~CTB-TIS3~
MKDIR ~CTB-WAV~
MKDIR ~CTBDLG~

COPY ~CtB/WED~     ~override~
COPY ~CtB/MOS~     ~override~
COPY ~CtB/bitmaps~ ~override~

//Substitute the SoA button prompt string  ************************************
COPY_EXISTING + ~CtB/title.tr~ ~CtB/title.tra~
 SPRINT bgt " "
 SPRINT tdd ""
 SPRINT sos ""
 SPRINT ts  ""
 SPRINT nej ""
 SPRINT ctb ""
 SPRINT bp  ""
 SPRINT rot ""
 SPRINT separator ""
 PATCH_IF (FILE_EXISTS ~data/BG1ARE.BIF~) BEGIN
   SPRINT bgt ~ Baldur's Gate<TM> and the Tales of the Sword Coast<TM> or play ~
 END
 PATCH_IF (FILE_EXISTS ~data/TS-RULE.BIF~) BEGIN
   SPRINT ts ~"Tortured Souls"~
   SPRINT separator ", "
 END
 PATCH_IF (FILE_EXISTS ~data/TDD-RULE.BIF~) BEGIN
   SPRINT tdd ~%separator%"The Darkest Day"~
   SPRINT separator ", "
 END
 PATCH_IF (FILE_EXISTS ~data/SOS-RULE.BIF~) BEGIN
   SPRINT sos ~%separator%"Shadows Over Soubar"~
   SPRINT separator ", "
 END
 PATCH_IF ((FILE_EXISTS_IN_GAME ~Bag02NeJ.ITM~) OR (FILE_EXISTS_IN_GAME ~EyeBite.itm~)) BEGIN
   SPRINT nej ~%separator%"Neverending Journey"~
   SPRINT separator ", "
 END
 PATCH_IF (FILE_EXISTS ~data/BP-RULE.BIF~) BEGIN
   SPRINT bp ~%separator%"Big Picture"~
   SPRINT separator ", "
 END
 PATCH_IF (FILE_EXISTS ~data/ROT-RULE.BIF~) BEGIN
   SPRINT rot ~%separator%"Region Of Terror"~
   SPRINT separator ", "
 END
 SPRINT ctb ~%separator%"Check The Bodies"~
 SPRINT separator ", "
 SPRINT separator2 " with the new expansion(s): "
 SPRINT str "Play%bgt%Shadows of Amn<TM>%separator2%%ts%%tdd%%sos%%nej%%bp%%ctb%%rot%"
 REPLACE_TEXTUALLY ~game prompt~ "%str%"

 STRING_SET ~73245~ @123456789 USING ~CtB/title.tra~
///////////////////////////////////////////////////////////////////////////////

//***********************************************************
//  RULESETS
//***********************************************************
PRINT ~Patching rulesets (2DA, IDS)...~

COPY ~CtB/RULE~    ~override~

COPY_EXISTING ~SPELL.IDS~        ~override~
 REPLACE_TEXTUALLY ~2302 WIZARD_DISPEL_MAGIC~      ~2302 WIZARD_REMOVE_MAGIC~
APPEND ~SPELL.IDS~ ~2326 WIZARD_DISPEL_MAGIC~
 UNLESS ~2326 WIZARD_DISPEL_MAGIC~

APPEND ~SPELL.IDS~ ~3510 CB_ENCHANT_SWORD~
 UNLESS ~CB_ENCHANT_SWORD~
APPEND ~SPELL.IDS~ ~3511 CB_ENCHANT_DAGGER~
 UNLESS ~CB_ENCHANT_DAGGER~
APPEND ~SPELL.IDS~ ~3512 CB_ENCHANT_AXE~
 UNLESS ~CB_ENCHANT_AXE~
APPEND ~SPELL.IDS~ ~3513 CB_ENCHANT_HALBERD~
 UNLESS ~CB_ENCHANT_HALBERD~

APPEND ~SPELL.IDS~ ~2140 WIZARD_EAGLES_SPLENDOR~
 UNLESS ~WIZARD_EAGLES_SPLENDOR~
APPEND ~SPELL.IDS~ ~2240 WIZARD_DECASTAVE~
 UNLESS ~WIZARD_DECASTAVE~
APPEND ~SPELL.IDS~ ~2540 WIZARD_BALL_LIGHTNING~
 UNLESS ~WIZARD_BALL_LIGHTNING~
APPEND ~SPELL.IDS~ ~2541 WIZARD_LUTZAENS_FREQUENT_JAUNT~
 UNLESS ~WIZARD_LUTZAENS_FREQUENT_JAUNT~
APPEND ~SPELL.IDS~ ~2640 WIZARD_DARTS_OF_BONE~
 UNLESS ~WIZARD_DARTS_OF_BONE~

//exist in TDD, but not WIZARD spells
APPEND ~SPELL.IDS~ ~2643 WIZARD_TROLLISH_FORTITUDE~           //SPPR752
 UNLESS ~WIZARD_TROLLISH_FORTITUDE~
APPEND ~SPELL.IDS~ ~2642 WIZARD_LICH_TOUCH~                   //sprb004 - UNUSED by TDD
 UNLESS ~WIZARD_LICH_TOUCH~
/////////////////////////////////////////////////////////////////////

APPEND ~SPELL.IDS~ ~2060 WIZARD_HAKESHAR_EFFECTS_5~
 UNLESS ~WIZARD_HAKESHAR_EFFECTS_5~
APPEND ~SPELL.IDS~ ~2061 WIZARD_HAKESHAR_EFFECTS_7~
 UNLESS ~WIZARD_HAKESHAR_EFFECTS_7~
APPEND ~SPELL.IDS~ ~2062 WIZARD_HAKESHAR_EFFECTS_9~
 UNLESS ~WIZARD_HAKESHAR_EFFECTS_9~
APPEND ~SPELL.IDS~ ~2063 WIZARD_COWLED_VD~
 UNLESS ~WIZARD_COWLED_VD~
APPEND ~SPELL.IDS~ ~3514 WIZARD_ADVANCED_ALCHEMY~
 UNLESS ~WIZARD_ADVANCED_ALCHEMY~
APPEND ~SPELL.IDS~ ~3515 CB_ADV_ENCHANT_SWORD~
 UNLESS ~CB_ADV_ENCHANT_SWORD~
APPEND ~SPELL.IDS~ ~3516 CB_ADV_ENCHANT_DAGGER~
 UNLESS ~CB_ADV_ENCHANT_DAGGER~
//APPEND ~SPELL.IDS~ ~3517 CB_ADV_ENCHANT_AXE~      - was NeJ2 incompatibility
// UNLESS ~CB_ADV_ENCHANT_AXE~
//APPEND ~SPELL.IDS~ ~3518 CB_ADV_ENCHANT_HALBERD~  - was NeJ2 incompatibility
// UNLESS ~CB_ADV_ENCHANT_HALBERD~
APPEND ~SPELL.IDS~ ~2360 CB_ELMINSTERS_LIGHTNING~
 UNLESS ~CB_ELMINSTERS_LIGHTNING~

ACTION_IF NOT FILE_EXISTS ~data/TDD-RULE.BIF~     //TDD compatibility
THEN BEGIN
APPEND ~SPELL.IDS~
~2227 WIZARD_CATS_GRACE
2440 WIZARD_MORDENKAINENS_FORCE_MISSILES
2627 WIZARD_ANTIMAGIC_FIELD
2823 WIZARD_IRON_BODY
2824 WIZARD_MIND_BLANK~

/*APPEND ~SPELL.IDS~ ~2241 WIZARD_CATS_GRACE~
 UNLESS ~WIZARD_CATS_GRACE~
APPEND ~SPELL.IDS~ ~2840 WIZARD_IRON_BODY~                   
 UNLESS ~WIZARD_IRON_BODY~
APPEND ~SPELL.IDS~ ~2841 CB_WIZARD_MIND_BLANK~
 UNLESS ~CB_WIZARD_MIND_BLANK~
APPEND ~SPELL.IDS~ ~2641 WIZARD_ANTIMAGIC_FIELD~
 UNLESS ~WIZARD_ANTIMAGIC_FIELD~
*/END



APPEND ~GTIMES.IDS~ ~6 ONE_ROUND~         UNLESS ~ONE_ROUND~
APPEND ~GTIMES.IDS~ ~12 TWO_ROUNDS~       UNLESS ~TWO_ROUNDS~
APPEND ~GTIMES.IDS~ ~18 THREE_ROUNDS~     UNLESS ~THREE_ROUNDS~
APPEND ~GTIMES.IDS~ ~24 FOUR_ROUNDS~      UNLESS ~FOUR_ROUNDS~
APPEND ~GTIMES.IDS~ ~30 FIVE_ROUNDS~      UNLESS ~FIVE_ROUNDS~
APPEND ~GTIMES.IDS~ ~36 SIX_ROUNDS~       UNLESS ~SIX_ROUNDS~
APPEND ~GTIMES.IDS~ ~42 SEVEN_ROUNDS~     UNLESS ~SEVEN_ROUNDS~
APPEND ~GTIMES.IDS~ ~48 EIGHT_ROUNDS~     UNLESS ~EIGHT_ROUNDS~
APPEND ~GTIMES.IDS~ ~54 NINE_ROUNDS~      UNLESS ~NINE_ROUNDS~
APPEND ~GTIMES.IDS~ ~60 TEN_ROUNDS~       UNLESS ~TEN_ROUNDS~
APPEND ~GTIMES.IDS~ ~60 ONE_TURN~         UNLESS ~ONE_TURN~
APPEND ~GTIMES.IDS~ ~120 TWO_TURNS~       UNLESS ~TWO_TURNS~
APPEND ~GTIMES.IDS~ ~180 THREE_TURNS~     UNLESS ~THREE_TURNS~
APPEND ~GTIMES.IDS~ ~240 FOUR_TURNS~      UNLESS ~FOUR_TURNS~
APPEND ~GTIMES.IDS~ ~300 FIVE_TURNS~      UNLESS ~FIVE_TURNS~
APPEND ~GTIMES.IDS~ ~300 ONE_HOUR~        UNLESS ~ONE_HOUR~
APPEND ~GTIMES.IDS~ ~360 SIX_TURNS~       UNLESS ~SIX_TURNS~
APPEND ~GTIMES.IDS~ ~420 SEVEN_TURNS~     UNLESS ~SEVEN_TURNS~
APPEND ~GTIMES.IDS~ ~480 EIGHT_TURNS~     UNLESS ~EIGHT_TURNS~
APPEND ~GTIMES.IDS~ ~540 NINE_TURNS~      UNLESS ~NINE_TURNS~
APPEND ~GTIMES.IDS~ ~600 TEN_TURNS~       UNLESS ~TEN_TURNS~
APPEND ~GTIMES.IDS~ ~600 TWO_HOURS~       UNLESS ~TWO_HOURS~
APPEND ~GTIMES.IDS~ ~900 FIFTEEN_TURNS~   UNLESS ~FIFTEEN_TURNS~
APPEND ~GTIMES.IDS~ ~900 THREE_HOURS~     UNLESS ~THREE_HOURS~
APPEND ~GTIMES.IDS~ ~1200 FOUR_HOURS~     UNLESS ~FOUR_HOURS~
APPEND ~GTIMES.IDS~ ~1500 FIVE_HOURS~     UNLESS ~FIVE_HOURS~
APPEND ~GTIMES.IDS~ ~1800 SIX_HOURS~      UNLESS ~SIX_HOURS~
APPEND ~GTIMES.IDS~ ~2100 SEVEN_HOURS~    UNLESS ~SEVEN_HOURS~
APPEND ~GTIMES.IDS~ ~2400 EIGHT_HOURS~    UNLESS ~EIGHT_HOURS~
APPEND ~GTIMES.IDS~ ~2700 NINE_HOURS~     UNLESS ~NINE_HOURS~
APPEND ~GTIMES.IDS~ ~3000 TEN_HOURS~      UNLESS ~TEN_HOURS~
APPEND ~GTIMES.IDS~ ~3300 ELEVEN_HOURS~   UNLESS ~ELEVEN_HOURS~
APPEND ~GTIMES.IDS~ ~3600 TWELVE_HOURS~   UNLESS ~TWELVE_HOURS~


//KIT.IDS (by Idobek - thanks!!!)
COPY_EXISTING ~KIT.IDS~ ~override~
  REPLACE_TEXTUALLY ~0x00004000~ ~0x4000~ // TRUECLASS/MAGESCHOOL_GENERALIST
  REPLACE_TEXTUALLY ~0x00000040~ ~0x0040~ // MAGESCHOOL_ABJURER
  REPLACE_TEXTUALLY ~0x00000080~ ~0x0080~ // MAGESCHOOL_CONJURER
  REPLACE_TEXTUALLY ~0x00000100~ ~0x0100~ // MAGESCHOOL_DIVINER
  REPLACE_TEXTUALLY ~0x00000200~ ~0x0200~ // MAGESCHOOL_ENCHANTER
  REPLACE_TEXTUALLY ~0x00000400~ ~0x0400~ // MAGESCHOOL_ILLUSIONIST
  REPLACE_TEXTUALLY ~0x00000800~ ~0x0800~ // MAGESCHOOL_INVOKER
  REPLACE_TEXTUALLY ~0x00001000~ ~0x1000~ // MAGESCHOOL_NECROMANCER
  REPLACE_TEXTUALLY ~0x00002000~ ~0x2000~ // MAGESCHOOL_TRANSMUTER
  REPLACE_TEXTUALLY ~0x00000001~ ~0x4001~ // BERSERKER
  REPLACE_TEXTUALLY ~0x00000002~ ~0x4002~ // WIZARDSLAYER
  REPLACE_TEXTUALLY ~0x00000004~ ~0x4003~ // KENSAI
  REPLACE_TEXTUALLY ~0x00000008~ ~0x4004~ // CAVALIER
  REPLACE_TEXTUALLY ~0x00000010~ ~0x4005~ // INQUISITOR
  REPLACE_TEXTUALLY ~0x00000020~ ~0x4006~ // UNDEADHUNTER
  REPLACE_TEXTUALLY ~0x00008000~ ~0x4007~ // FERALAN
  REPLACE_TEXTUALLY ~0x00010000~ ~0x4008~ // STALKER
  REPLACE_TEXTUALLY ~0x00020000~ ~0x4009~ // BEASTMASTER
  REPLACE_TEXTUALLY ~0x00040000~ ~0x400A~ // ASSASIN
  REPLACE_TEXTUALLY ~0x00080000~ ~0x400B~ // BOUNTYHUNTER
  REPLACE_TEXTUALLY ~0x00100000~ ~0x400C~ // SWASHBUCKLER
  REPLACE_TEXTUALLY ~0x00200000~ ~0x400D~ // BLADE
  REPLACE_TEXTUALLY ~0x00400000~ ~0x400E~ // JESTER
  REPLACE_TEXTUALLY ~0x00800000~ ~0x400F~ // SKALD
  REPLACE_TEXTUALLY ~0x01000000~ ~0x4013~ // GODTALOS
  REPLACE_TEXTUALLY ~0x02000000~ ~0x4014~ // GODHELM
  REPLACE_TEXTUALLY ~0x04000000~ ~0x4015~ // GODLATHANDER
  REPLACE_TEXTUALLY ~0x08000000~ ~0x4010~ // TOTEMIC
  REPLACE_TEXTUALLY ~0x10000000~ ~0x4011~ // SHAPESHIFTER
  REPLACE_TEXTUALLY ~0x20000000~ ~0x4012~ // BEASTFRIEND
  REPLACE_TEXTUALLY ~0x40000000~ ~0x401F~ // BARBARIAN
BUT_ONLY_IF_IT_CHANGES


APPEND ~SHOUTIDS.IDS~ ~2 LEAVE2~ UNLESS ~LEAVE2~
APPEND ~SHOUTIDS.IDS~ ~66 DEAD_MEAT~ UNLESS ~DEAD_MEAT~
APPEND ~SHOUTIDS.IDS~ ~68 ALERT_68~ UNLESS ~ALERT_68~
APPEND ~SHOUTIDS.IDS~ ~69 ALERT_69~ UNLESS ~ALERT_69~
APPEND ~SHOUTIDS.IDS~ ~79 ALERT_79~ UNLESS ~ALERT_79~
APPEND ~SHOUTIDS.IDS~ ~80 RETREAT_80~ UNLESS ~RETREAT_80~
APPEND ~SHOUTIDS.IDS~ ~82 RALLY_TO_ME_82~ UNLESS ~RALLY_TO_ME_82~
APPEND ~SHOUTIDS.IDS~ ~83 HEALME_83~ UNLESS ~HEALME_83~
APPEND ~SHOUTIDS.IDS~ ~84 IM_BLIND~ UNLESS ~IM_BLIND~
APPEND ~SHOUTIDS.IDS~ ~89 ALERT_89~ UNLESS ~ALERT_89~
APPEND ~SHOUTIDS.IDS~ ~99 ALERT_99~ UNLESS ~ALERT_99~
APPEND ~SHOUTIDS.IDS~ ~100 ALERT_100~ UNLESS ~ALERT_100~
APPEND ~SHOUTIDS.IDS~ ~101 ALERT_101~  UNLESS ~ALERT_101~
APPEND ~SHOUTIDS.IDS~ ~111 INCOMING_111~ UNLESS ~INCOMING_111~
APPEND ~SHOUTIDS.IDS~ ~115 ALERT_115~ UNLESS ~ALERT_115~
APPEND ~SHOUTIDS.IDS~ ~116 ALERT_116~ UNLESS ~ALERT_116~
APPEND ~SHOUTIDS.IDS~ ~121 MDK_SHOUT_121~ UNLESS ~MDK_SHOUT_121~
APPEND ~SHOUTIDS.IDS~ ~122 MDK_SHOUT_122~ UNLESS ~MDK_SHOUT_122~
APPEND ~SHOUTIDS.IDS~ ~151 ALERT_151~ UNLESS ~ALERT_151~
APPEND ~SHOUTIDS.IDS~ ~152 ALERT_152~ UNLESS ~ALERT_152~
APPEND ~SHOUTIDS.IDS~ ~153 HP_LT_20_ASSIST~ UNLESS ~HP_LT_20_ASSIST~
APPEND ~SHOUTIDS.IDS~ ~154 INCOMING_154~ UNLESS ~INCOMING_154~
APPEND ~SHOUTIDS.IDS~ ~155 INCOMING_155~ UNLESS ~INCOMING_155~
APPEND ~SHOUTIDS.IDS~ ~156 UNDER_ATTACK~ UNLESS ~UNDER_ATTACK~
APPEND ~SHOUTIDS.IDS~ ~199 ALERT_199~ UNLESS ~ALERT_199~
APPEND ~SHOUTIDS.IDS~ ~200 POISONED_200~ UNLESS ~POISONED_200~


ACTION_IF FILE_EXISTS ~script compiler/AICOMPILE.exe~
THEN BEGIN
COPY_EXISTING   ~SPELL.IDS~    ~script compiler~
                ~SHOUTIDS.IDS~ ~script compiler~
                ~KIT.IDS~      ~script compiler~
                ~GTIMES.IDS~   ~script compiler~
END
//****************************************************

APPEND ~ITEMDIAL.2DA~
~CB2HCONV      5689   CBC8CONV
CBLSCONV      5689   CBC8CONV
CBDGCONV      5689   CBC8CONV
CBMSCONV      5689   CBC8CONV
CBLSCONV      5689   CBC8CONV
CBMALMGE      5689   CBMALMGE
CBMOONP1      5689   CBMOONDG
CBMOONP2      5689   CBMOONDG
CBMOONP3      5689   CBMOONDG
CBMOONP4      5689   CBMOONDG
CBMOONP5      5689   CBMOONDG
CBMOONP6      5689   CBMOONDG
CBMONP1B      5689   CBMOONDG
CBMONP1C      5689   CBMOONDG
CBMONP1D      5689   CBMOONDG
CBMONP2B      5689   CBMOONDG
CBMONP2C      5689   CBMOONDG
CBMONP2D      5689   CBMOONDG
CBMONP3B      5689   CBMOONDG
CBMONP3C      5689   CBMOONDG
CBMONP3D      5689   CBMOONDG
CBMONP4B      5689   CBMOONDG
CBMONP4C      5689   CBMOONDG
CBMONP4D      5689   CBMOONDG
CBMONP5B      5689   CBMOONDG
CBMONP5C      5689   CBMOONDG
CBMONP5D      5689   CBMOONDG
CBMONP6B      5689   CBMOONDG
CBMONP6C      5689   CBMOONDG
CBMONP6D      5689   CBMOONDG~

APPEND ~MASTAREA.2DA~
~AR3520  value
AR3534  value
AR3540  value
AR3570  value
AR3585  value
AR3587  value
AR3588  value
AR3597  value
AR3610  value
AR3611  value
AR3613  value
AR3675  value
AR3535  value
AR3594  value
AR3595  value~


PRINT ~Dealing with TOOLTIP.2DA ...~

COPY_EXISTING ~TOOLTIP.2DA~ ~override~
 SET required_columns = 10
 SET rows=2
 SET rows_prev=0
 SET col_cnt=0
 WHILE "%rows%">1 BEGIN
   col_cnt = col_cnt + 1
   rows_prev = rows
   COUNT_2DA_ROWS col_cnt rows
 END
 col_cnt = col_cnt - 1
 SET ccc = col_cnt - 1

 PATCH_IF 1 BEGIN
   SPRINT str_add ""
   SPRINT str "%ccc%"
   FOR(cnt="%col_cnt%"; cnt<="%required_columns%"; cnt+=1) BEGIN
     SPRINT str "%str%"^"          %cnt%"
     SPRINT str_add "%str_add%"^"         -1"
   END

   READ_2DA_ENTRY 0 0 3 "test"
   PATCH_IF( "%test%"=1 ) BEGIN
     SET_2DA_ENTRY 0 0 3 "0                  1"
   END

   PATCH_IF("%ccc%"<"%required_columns%") BEGIN
     SET_2DA_ENTRY 0 ccc ccc "%str%"

     FOR(j=1; j<="%rows_prev%"; j+=1) BEGIN
       READ_2DA_ENTRY j ccc col_cnt "last"
       SPRINT str "%last%"^"%str_add%"
       SET_2DA_ENTRY j ccc col_cnt "%str%"
     END
   END
 END
BUT_ONLY_IF_IT_CHANGES

APPEND ~TOOLTIP.2DA~
~CBWTNI3a          12048        12072       13073      07571      25934      32393      25960      25944      7783       23358kkkkkk
CBMALR1a          26799        26465       20935      20853      23726      40271      29743      29744      -1         -1kkkkkk
CBMALR2a          k80146        38596       2445       25633      -1         -1         -1         -1         -1         -1kkkkkk
CBMALR4a          k80147        k80148       k80149      -1         -1         -1         -1         -1         -1         -1kkkkkk
CBMALR6a          k80150        k80151       -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBCWSTFF          k80152        12017       -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBMTDGME          k80153        12016       -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBCHAUNT          k80154        -1          -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBCYRICx          22185        12072       49073      -1         -1         -1         -1         -1         -1         -1kkkkkk
CB2HCONV          k650007        7619        -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBBK7521          12089        -1          -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBBK7526          12121        -1          -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBBK7534          12083        -1          -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBBK7535          k253        -1          -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBBK7537          12108        -1          -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBBK7538          12090        -1          -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBDGCONV          k650007        7619        -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBDRDSWD          k650284        12094       12026      8786       k32      -1         -1         -1         -1         -1kkkkkk
CBGEMSEE          25633        -1          -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBHLD001          25937        12021       -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBHLD002          25875        -1          -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBLSCONV          k650007        7619        -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBMSCONV          k650007        7619        -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBNRTSTF          k650451        12089       -1         -1         -1         -1         -1         -1         -1         -1kkkkkk
CBXTLTcc          12116        -1          -1         -1         -1         -1         -1         -1         -1         -1kkkkkk~

COPY_EXISTING ~TOOLTIP.2DA~ ~override~
 //******** number of items in appended rows ***
 SET present_cols = 11
 //*********************************************
 SET rows=2
 SET rows_prev=0
 SET col_cnt=0
 WHILE "%rows%">1 BEGIN
   col_cnt = col_cnt + 1
   rows_prev = rows
   COUNT_2DA_ROWS col_cnt rows
 END
 col_cnt = col_cnt - 1
 SET ccc = col_cnt - 1

 SPRINT str_add ""
 FOR(cnt="%present_cols%"; cnt<"%col_cnt%"; cnt+=1) BEGIN
   SPRINT str_add "%str_add%"^"         -1"
 END
 REPLACE_TEXTUALLY ~kkkkkk~ "%str_add%"
 REPLACE ~k80146~  @146
 REPLACE ~k80147~  @147
 REPLACE ~k80148~  @148
 REPLACE ~k80149~  @149
 REPLACE ~k80150~  @150
 REPLACE ~k80151~  @151
 REPLACE ~k80152~  @650271
 REPLACE ~k80153~  @153
 REPLACE ~k80154~  @661025
 REPLACE ~k650007~ @650007
 REPLACE ~k253~    @253
 REPLACE ~k650284~ @650284
 REPLACE ~k32~     @32
 REPLACE ~k650451~ @650451

COPY_EXISTING tooltip.2da override
  SET_2DA_ENTRY 0 0 3 ~ ~
BUT_ONLY_IF_IT_CHANGES

APPEND ~TRACKING.2DA~
~AR3534     450500
AR3535     450501
AR3585     450502
AR3587     450502
AR3588     450502
AR3610     450505
AR3611     450505
AR3613     450505~

COPY_EXISTING ~TRACKING.2DA~ ~override~
 REPLACE ~450500~ @650683
 REPLACE ~450501~ @650684
 REPLACE ~450502~ @650685
 REPLACE ~450505~ @650688

COPY ~CtB/2da/append/CBCO8SCR.2DA~ ~override~
 REPLACE ~99999999~ @650697
COPY ~CtB/2da/append/CBLAWLVR.2DA~ ~override~
 REPLACE ~99999999~ @650698
COPY ~CtB/2da/append/CBHEXSCR.2DA~ ~override~
 REPLACE ~99999999~ @650699

COPY ~CtB/2da/copy~ ~override~

//***********************************************************
//  Graphics
//***********************************************************
PRINT ~Installing game graphics and effects...~

COPY ~CtB/gui_/bam~ ~override~
COPY ~CtB/gui_/mos~ ~override~
COPY ~CtB/effects~  ~override~
COPY ~CtB/portrait~ ~override~

//***********************************************************
//  Animations
//***********************************************************
PRINT ~Correcting animations...~

//freeing MGO3 slot for a Bugbear 1
COPY_EXISTING ~ICGOB04.cre~         ~override~
              ~FSHORDE1.cre~        ~override~
 WRITE_LONG 0x28  0xE400   //IC_GOBLIN_AXE instead of IC_GOBLINELITE_AXE
BUT_ONLY_IF_IT_CHANGES

//freeing MMY2 slot for a Bugbear 2
COPY_EXISTING ~ICMYC02.cre~         ~override~
 WRITE_LONG 0x28  0xE600   //IC_MYCONID instead of IC_MYCONID2
BUT_ONLY_IF_IT_CHANGES



ACTION_IF FILE_EXISTS_IN_GAME ~TT0025.ARE~  // NEJ2 compatibility
THEN BEGIN
 COPY_EXISTING ~GOBLINSP.CRE~      ~override~
               ~TUPUNG.CRE~        ~override~
               ~TUPUNGCS.CRE~      ~override~
               ~WEENOG.CRE~        ~override~
  WRITE_LONG 0x28  0xE400   //IC_GOBLIN_AXE instead of IC_GOBLINELITE_AXE
 BUT_ONLY_IF_IT_CHANGES

 COPY_EXISTING ~MHISA1.bam~   ~override/MBFIA1.bam~      //it's necessary to execute before CtB BAMs copied over
               ~MHISA1E.bam~  ~override/MBFIA1E.bam~
               ~MHISA2.bam~   ~override/MBFIA2.bam~
               ~MHISA2E.bam~  ~override/MBFIA2E.bam~
               ~MHISDE.bam~   ~override/MBFIDE.bam~
               ~MHISDEE.bam~  ~override/MBFIDEE.bam~
               ~MHISGH.bam~   ~override/MBFIGH.bam~
               ~MHISGHE.bam~  ~override/MBFIGHE.bam~
               ~MHISGU.bam~   ~override/MBFIGU.bam~
               ~MHISGUE.bam~  ~override/MBFIGUE.bam~
               ~MHISSC.bam~   ~override/MBFISC.bam~
               ~MHISSCE.bam~  ~override/MBFISCE.bam~
               ~MHISSD.bam~   ~override/MBFISD.bam~
               ~MHISSDE.bam~  ~override/MBFISDE.bam~
               ~MHISSL.bam~   ~override/MBFISL.bam~
               ~MHISSLE.bam~  ~override/MBFISLE.bam~
               ~MHISTW.bam~   ~override/MBFITW.bam~
               ~MHISTWE.bam~  ~override/MBFITWE.bam~
               ~MHISWK.bam~   ~override/MBFIWK.bam~
               ~MHISWKE.bam~  ~override/MBFIWKE.bam~
               ~MHIS.2da~     ~override/MBFI.2da~

 COPY_EXISTING ~RDUNDEAD.CRE~   ~override~
               ~RDUNDEA2.CRE~   ~override~
               ~RDUNDEA3.CRE~   ~override~
               ~RDUNDEA4.CRE~   ~override~
               ~DOOMGUAR.CRE~   ~override~
  WRITE_LONG 0x28  0xE210   //IC_BEETLE_FIRE instead of IC_HISTACHII
 BUT_ONLY_IF_IT_CHANGES

 COPY_EXISTING ~WIGHCOLD.CRE~   ~override~
               ~WRAITH01.CRE~   ~override~
               ~ZOMBIE01.CRE~   ~override~
  WRITE_LONG 0x28  0xEC10   //IC_WIGHT2 instead of IC_WIGHT
 BUT_ONLY_IF_IT_CHANGES

END
ELSE BEGIN
END


ACTION_IF NOT FILE_EXISTS ~data/ROT-RULE.BIF~     // Compatibility with RoT
THEN BEGIN
  COPY ~CtB/Compat/anim/MTIC~ ~override~   //Red Harpy
  COPY ~CtB/Compat/anim/MZO2~ ~override~   //Black Harpy - RoT's Samurai has a higher priority
END


PRINT ~Installing new animations...~

COPY ~CtB/cbcrean1~ ~override~
COPY ~CtB/cbcrean2~ ~override~
COPY ~CtB/cbcrean4~ ~override~


//***************************************************************
//  AREAS - before scripts to avoid unnecessary WeiDU warnings
//***************************************************************
PRINT ~Installing new areas...~

COPY ~CtB/ctbareas/nostring~ ~override~

COPY ~CtB/ctbareas/translate/AR3530.ARE~ ~override~
  SAY 0x968 @187

COPY ~CtB/ctbareas/translate/AR3531.ARE~ ~override~
  SAY 0x2618 @188
  SAY 0x8204 @650693
  SAY 0x8238 @650694
  SAY 0x826c @650695
  SAY 0x82a0 @650696

COPY ~CtB/ctbareas/translate/AR3532.ARE~ ~override~
  SAY 0x1894 @189
  SAY 0x281c @660100

COPY ~CtB/ctbareas/translate/AR3534.ARE~ ~override~
  SAY 0xbd4 @190
  SAY 0x16f4 @660302
  SAY 0x1728 @660301

COPY ~CtB/ctbareas/translate/AR3540.ARE~ ~override~
  SAY 0x068c @660001
  SAY 0x0690 @660001
  SAY 0x0694 @660002
  SAY 0x0698 @660002

COPY ~CtB/ctbareas/translate/AR3541.ARE~ ~override~
  SAY 0x2558 @660003
  SAY 0x3194 @660001
  SAY 0x3198 @660001
  SAY 0x319c @660002
  SAY 0x31a0 @660002

COPY ~CtB/ctbareas/translate/AR3542.ARE~ ~override~
  SAY 0x3c38 @660001
  SAY 0x3c3c @660001
  SAY 0x3c40 @660002
  SAY 0x3c44 @660002

COPY ~CtB/ctbareas/translate/AR3543.ARE~ ~override~
  SAY 0x578c @660001
  SAY 0x5790 @660001
  SAY 0x5794 @660002
  SAY 0x5798 @660002

COPY ~CtB/ctbareas/translate/AR3544.ARE~ ~override~
  SAY 0x5278 @660001
  SAY 0x527c @660001
  SAY 0x5280 @660002
  SAY 0x5284 @660002

COPY ~CtB/ctbareas/translate/AR3545.ARE~ ~override~
  SAY 0x17e4 @660001
  SAY 0x17e8 @660001
  SAY 0x17ec @660002
  SAY 0x17f0 @660002

COPY ~CtB/ctbareas/translate/AR3546.ARE~ ~override~
  SAY 0x1184 @660001
  SAY 0x1188 @660001
  SAY 0x118c @660002
  SAY 0x1190 @660002

COPY ~CtB/ctbareas/translate/AR3547.ARE~ ~override~
  SAY 0xcd0  @660004
  SAY 0xff0  @70005
  SAY 0x1d00 @660001
  SAY 0x1d04 @660001
  SAY 0x1d08 @660002
  SAY 0x1d0c @660002

COPY ~CtB/ctbareas/translate/AR3548.ARE~ ~override~
  SAY 0x0cf8 @660001
  SAY 0x0cfc @660001
  SAY 0x0d00 @660002
  SAY 0x0d04 @660002

COPY ~CtB/ctbareas/translate/AR3549.ARE~ ~override~
  SAY 0x0ed0 @660001
  SAY 0x0ed4 @660001
  SAY 0x0ed8 @660002
  SAY 0x0edc @660002

COPY ~CtB/ctbareas/translate/AR3550.ARE~ ~override~
  SAY 0x0ae0 @660001
  SAY 0x0ae4 @660001
  SAY 0x0ae8 @660002
  SAY 0x0aec @660002

COPY ~CtB/ctbareas/translate/AR3551.ARE~ ~override~
  SAY 0x17b8 @660003
  SAY 0x2030 @660001
  SAY 0x2034 @660001
  SAY 0x2038 @660002
  SAY 0x203c @660002

COPY ~CtB/ctbareas/translate/AR3552.ARE~ ~override~
  SAY 0x1930 @660001
  SAY 0x1934 @660001
  SAY 0x1938 @660002
  SAY 0x193c @660002

COPY ~CtB/ctbareas/translate/AR3553.ARE~ ~override~
  SAY 0x149c @660005
  SAY 0x1874 @660001
  SAY 0x1878 @660001
  SAY 0x187c @660002
  SAY 0x1880 @660002

COPY ~CtB/ctbareas/translate/AR3554.ARE~ ~override~
  SAY 0x1234 @660005
  SAY 0x12fc @660005
  SAY 0x176c @660001
  SAY 0x1770 @660001
  SAY 0x1774 @660002
  SAY 0x1778 @660002

COPY ~CtB/ctbareas/translate/AR3556.ARE~ ~override~
  SAY 0x1690 @660001
  SAY 0x1694 @660001
  SAY 0x1698 @660002
  SAY 0x169c @660002

COPY ~CtB/ctbareas/translate/AR3557.ARE~ ~override~
  SAY 0x0a40 @660001
  SAY 0x0a44 @660001
  SAY 0x0a48 @660002
  SAY 0x0a4c @660002

COPY ~CtB/ctbareas/translate/AR3558.ARE~ ~override~
  SAY 0x0af8 @660001
  SAY 0x0afc @660001
  SAY 0x0b00 @660002
  SAY 0x0b04 @660002

COPY ~CtB/ctbareas/translate/AR3559.ARE~ ~override~
  SAY 0x1a24 @660001
  SAY 0x1a28 @660001
  SAY 0x1a2c @660002
  SAY 0x1a30 @660002

COPY ~CtB/ctbareas/translate/AR3565.ARE~ ~override~
  SAY 0x244 @191
  SAY 0x308 @192

COPY ~CtB/ctbareas/translate/AR3575.ARE~ ~override~
  SAY 0x3b0c @193
  SAY 0x3bd0 @194
  SAY 0x3c94 @194
  SAY 0x3d58 @194
  SAY 0x76b4 @700194

COPY ~CtB/ctbareas/translate/AR3580.ARE~ ~override~
  SAY 0x313c @651013
  SAY 0x3200 @651014
  SAY 0x32c4 @651015
  SAY 0x3388 @651016
  SAY 0x344c @651017

COPY ~CtB/ctbareas/translate/AR3588.ARE~ ~override~
  SAY 0x38f8 @197
  SAY 0x39bc @197
  SAY 0x3a80 @197
  SAY 0x3b44 @197
  SAY 0x3c08 @197
  SAY 0x3ccc @197
  SAY 0x3d90 @197

COPY ~CtB/ctbareas/translate/AR3594.ARE~ ~override~
  SAY 0x249c @197

COPY ~CtB/ctbareas/translate/AR3610.ARE~ ~override~
  SAY 0x1a80 @205
  SAY 0x1b44 @206
  SAY 0x1c08 @207
  SAY 0x1ccc @208
  SAY 0x669c @236
  SAY 0x66d0 @237
  SAY 0x6704 @238

COPY ~CtB/ctbareas/translate/AR3611.ARE~ ~override~
  SAY 0x5040 @238
  SAY 0x5074 @239
  SAY 0x3800 @70000

COPY ~CtB/ctbareas/translate/AR3613.ARE~ ~override~
  SAY 0x3f44 @238
  SAY 0x3f78 @240

COPY ~CtB/ctbareas/translate/AR3625.ARE~ ~override~
  SAY 0x464 @209

COPY ~CtB/ctbareas/translate/AR3626.ARE~ ~override~
  SAY 0x464 @209

COPY ~CtB/ctbareas/translate/AR3631.ARE~ ~override~
  SAY 0x638 @211

COPY ~CtB/ctbareas/translate/AR3635.ARE~ ~override~
  SAY 0x574 @212

COPY ~CtB/ctbareas/translate/AR3636.ARE~ ~override~
  SAY 0x354 @213

COPY ~CtB/ctbareas/translate/AR3637.ARE~ ~override~
 SAY 0x1034 @767213

COPY ~CtB/ctbareas/translate/AR3638.ARE~ ~override~
  SAY 0xbd4 @214

COPY ~CtB/ctbareas/translate/AR3641.ARE~ ~override~
  SAY 0x794 @215

COPY ~CtB/ctbareas/translate/AR3643.ARE~ ~override~
  SAY 0xb10 @70001

COPY ~CtB/ctbareas/translate/AR3647.ARE~ ~override~
  SAY 0x354 @216

COPY ~CtB/ctbareas/translate/AR3649.ARE~ ~override~
  SAY 0x464 @209

COPY ~CtB/ctbareas/translate/CB3661.ARE~ ~override~
  SAY 0x013b4 @661003
  SAY 0x013b8 @661003
  SAY 0x013bc @661003
  SAY 0x013c0 @661003
  SAY 0x013c4 @661003
  SAY 0x013c8 @661003
  SAY 0x013cc @661003
  SAY 0x013d0 @661003
  SAY 0x013d4 @661003
  SAY 0x013d8 @661003

COPY ~CtB/ctbareas/translate/CB3662.ARE~ ~override~
  SAY 0x0a24 @661003
  SAY 0x0a28 @661003
  SAY 0x0a2c @661003
  SAY 0x0a30 @661003
  SAY 0x0a34 @661003
  SAY 0x0a38 @661003
  SAY 0x0a3c @661003
  SAY 0x0a40 @661003
  SAY 0x0a44 @661003
  SAY 0x0a48 @661003

COPY ~CtB/ctbareas/translate/CB3663.ARE~ ~override~
  SAY 0x01914 @661003
  SAY 0x01918 @661003
  SAY 0x0191c @661003
  SAY 0x01920 @661003
  SAY 0x01924 @661003
  SAY 0x01928 @661003
  SAY 0x0192c @661003
  SAY 0x01930 @661003
  SAY 0x01934 @661003
  SAY 0x01938 @661003

COPY ~CtB/ctbareas/translate/CB3664.ARE~ ~override~
  SAY 0x0159c @661003
  SAY 0x015a0 @661003
  SAY 0x015a4 @661003
  SAY 0x015a8 @661003
  SAY 0x015ac @661003
  SAY 0x015b0 @661003
  SAY 0x015b4 @661003
  SAY 0x015b8 @661003
  SAY 0x015bc @661003
  SAY 0x015c0 @661003

COPY ~CtB/ctbareas/translate/CB3665.ARE~ ~override~
  SAY 0x01628 @661001
  SAY 0x2fe8 @661003
  SAY 0x2fec @661003
  SAY 0x2ff0 @661003
  SAY 0x2ff4 @661003
  SAY 0x2ff8 @661003
  SAY 0x2ffc @661003
  SAY 0x3000 @661003
  SAY 0x3004 @661003
  SAY 0x3008 @661003
  SAY 0x300c @661003

COPY ~CtB/ctbareas/translate/CB3666.ARE~ ~override~
  SAY 0x0948 @661003
  SAY 0x094c @661003
  SAY 0x0950 @661003
  SAY 0x0954 @661003
  SAY 0x0958 @661003
  SAY 0x095c @661003
  SAY 0x0960 @661003
  SAY 0x0964 @661003
  SAY 0x0968 @661003
  SAY 0x096c @661003

COPY ~CtB/ctbareas/translate/CB3667.ARE~ ~override~
  SAY 0x0a00 @661002
  SAY 0x47cc @661003
  SAY 0x47d0 @661003
  SAY 0x47d4 @661003
  SAY 0x47d8 @661003
  SAY 0x47dc @661003
  SAY 0x47e0 @661003
  SAY 0x47e4 @661003
  SAY 0x47e8 @661003
  SAY 0x47ec @661003
  SAY 0x47f0 @661003

COPY ~CtB/ctbareas/translate/CB3668.ARE~ ~override~
  SAY 0x0ccc @661003
  SAY 0x0cd0 @661003
  SAY 0x0cd4 @661003
  SAY 0x0cd8 @661003
  SAY 0x0cdc @661003
  SAY 0x0ce0 @661003
  SAY 0x0ce4 @661003
  SAY 0x0ce8 @661003
  SAY 0x0cec @661003
  SAY 0x0cf0 @661003


//***********************************************************
//  Dialogues and scripts
//***********************************************************
PRINT ~Patching original BG2 scripts...~

EXTEND_TOP ~Baldur.BCS~ ~CtB/scripts/append/aptp1BLD.BAF~
EXTEND_TOP ~Baldur.BCS~ ~CtB/scripts/append/aptp2BLD.BAF~
EXTEND_TOP ~DRIZZSHT.bcs~ ~CtB/scripts/append/DRIZZSHT.BAF~
EXTEND_TOP ~SGUARD2.bcs~ ~CtB/scripts/append/SGUARD2.BAF~
EXTEND_TOP ~SGUARD3.bcs~ ~CtB/scripts/append/SGUARD3.BAF~

EXTEND_TOP    ~AR0020.bcs~ ~CtB/scripts/append/aptp0020.BAF~
EXTEND_BOTTOM ~AR0204.bcs~ ~CtB/scripts/append/apbt0204.BAF~

COPY_EXISTING ~AR0300.bcs~ ~override~
 REPLACE_BCS_BLOCK ~CtB/scripts/append/rbbO0300.bcs~ ~CtB/scripts/append/rbbN0300.bcs~
EXTEND_TOP ~AR0300.bcs~ ~CtB/scripts/append/aptp0300.BAF~

EXTEND_BOTTOM ~AR0308.bcs~ ~CtB/scripts/append/apbt0308.BAF~
EXTEND_TOP    ~AR0311.bcs~ ~CtB/scripts/append/aptp0311.BAF~

EXTEND_TOP    ~AR0319.bcs~ ~CtB/scripts/append/tAR0319.baf~   //fix

EXTEND_TOP    ~AR0334.bcs~ ~CtB/scripts/append/aptp0334.BAF~
EXTEND_BOTTOM ~AR0334.bcs~ ~CtB/scripts/append/apbt0334.BAF~

EXTEND_BOTTOM ~AR0400.bcs~ ~CtB/scripts/append/aptp0400.BAF~  //was EXT_TOP
EXTEND_BOTTOM ~AR0404.bcs~ ~CtB/scripts/append/apbt0404.BAF~
EXTEND_TOP    ~AR0406.bcs~ ~CtB/scripts/append/aptp0406.BAF~

// bonus merchant
ACTION_IF NOT ((FILE_EXISTS ~data/TS-RULE.BIF~) OR (FILE_EXISTS ~data/TDD-RULE.BIF~)) THEN 
BEGIN
  EXTEND_BOTTOM ~AR0406.bcs~ ~CtB/scripts/append/apbt0406.BAF~ //WMART1
END
EXTEND_BOTTOM ~AR1100.BCS~ ~CtB/scripts/append/apbt1100.BAF~   // Fix lost Pissman encounter (Barlot)-Hoppy
EXTEND_BOTTOM ~PREY.BCS~ ~CtB/scripts/append/apbtprey.BAF~    //Only fix for druid staff component for class quest-Hoppy
EXTEND_TOP    ~AR0500.bcs~ ~CtB/scripts/append/aptp0500.BAF~
EXTEND_TOP    ~AR0510.bcs~ ~CtB/scripts/append/aptp0510.BAF~
EXTEND_TOP    ~AR0700.bcs~ ~CtB/scripts/append/aptp0700.BAF~
EXTEND_TOP    ~AR0705.bcs~ ~CtB/scripts/append/aptp0705.BAF~
EXTEND_TOP    ~AR0709.bcs~ ~CtB/scripts/append/aptp0709.BAF~
EXTEND_TOP    ~AR0800.bcs~ ~CtB/scripts/append/aptp0800.BAF~
EXTEND_TOP    ~AR0809.bcs~ ~CtB/scripts/append/aptp0809.BAF~
EXTEND_TOP    ~AR0900.bcs~ ~CtB/scripts/append/aptp0900.BAF~
EXTEND_TOP    ~AR0901.bcs~ ~CtB/scripts/append/aptp0901.BAF~

EXTEND_TOP    ~AR0902.bcs~ ~CtB/scripts/append/aptp0902.BAF~
EXTEND_BOTTOM ~AR0902.bcs~ ~CtB/scripts/append/apbt0902.BAF~

EXTEND_BOTTOM ~AR0903.bcs~ ~CtB/scripts/append/apbt0903.BAF~
EXTEND_BOTTOM ~AR0906.bcs~ ~CtB/scripts/append/apbt0906.BAF~
EXTEND_BOTTOM ~AR0907.bcs~ ~CtB/scripts/append/apbt0907.BAF~
EXTEND_TOP    ~AR1000.bcs~ ~CtB/scripts/append/aptp1000.BAF~
EXTEND_BOTTOM ~AR1002.bcs~ ~CtB/scripts/append/apbt1002.BAF~

EXTEND_TOP    ~AR1006.bcs~ ~CtB/scripts/append/aptp1006.BAF~
EXTEND_BOTTOM ~AR1006.bcs~ ~CtB/scripts/append/apbt1006.BAF~

EXTEND_TOP    ~AR1106.bcs~ ~CtB/scripts/append/aptp1106.BAF~

EXTEND_TOP    ~AR1200.bcs~ ~CtB/scripts/append/aptp1200.BAF~
EXTEND_BOTTOM ~AR1200.bcs~ ~CtB/scripts/append/apbt1200.BAF~

EXTEND_BOTTOM ~AR1202.bcs~ ~CtB/scripts/append/apbt1202.BAF~
EXTEND_BOTTOM ~AR1300.bcs~ ~CtB/scripts/append/apbt1300.BAF~
EXTEND_BOTTOM ~AR1304.bcs~ ~CtB/scripts/append/apbt1304.BAF~
EXTEND_BOTTOM ~AR1400.bcs~ ~CtB/scripts/append/apbt1400.BAF~
EXTEND_TOP   ~AR1401.bcs~ ~CtB/scripts/append/aptp1401.BAF~
EXTEND_BOTTOM ~AR1404.bcs~ ~CtB/scripts/append/apbt1404.BAF~
EXTEND_BOTTOM ~AR1700.bcs~ ~CtB/scripts/append/apbt1700.BAF~
EXTEND_BOTTOM ~AR1900.bcs~ ~CtB/scripts/append/apbt1900.BAF~
EXTEND_BOTTOM ~AR2000.bcs~ ~CtB/scripts/append/apbt2000.BAF~
EXTEND_BOTTOM ~AR2008.bcs~ ~CtB/scripts/append/apbt2008.BAF~
EXTEND_TOP    ~AR2200.bcs~ ~CtB/scripts/append/aptp2200.BAF~
EXTEND_TOP    ~AR2201.bcs~ ~CtB/scripts/append/aptp2201.BAF~
EXTEND_TOP    ~AR2202.bcs~ ~CtB/scripts/append/aptp2202.BAF~
EXTEND_TOP    ~AR2203.bcs~ ~CtB/scripts/append/aptp2203.BAF~
EXTEND_BOTTOM ~AR2205.bcs~ ~CtB/scripts/append/apbt2205.BAF~
EXTEND_BOTTOM ~AR2402.bcs~ ~CtB/scripts/append/apbt2402.BAF~
EXTEND_BOTTOM ~AR2600.bcs~ ~CtB/scripts/append/apbt2600.BAF~
EXTEND_BOTTOM ~AR6101.bcs~ ~CtB/scripts/append/apbt6101.BAF~
EXTEND_BOTTOM ~AR6104.bcs~ ~CtB/scripts/append/apbt6104.BAF~
EXTEND_TOP    ~AR6105.bcs~ ~CtB/scripts/append/aptp6105.BAF~
EXTEND_TOP    ~AR6106.bcs~ ~CtB/scripts/append/aptp6106.BAF~     //added

COPY_EXISTING ~AR2500.bcs~ ~override~
REPLACE_BCS_BLOCK ~CtB/scripts/append/oAR2500.baf~ ~CtB/scripts/append/nAR2500.baf~     //Chapter fix by BWP

EXTEND_TOP    ~AR2500.bcs~ ~CtB/scripts/append/aptp2500.BAF~   //Other part of Chapter 6 fix

COPY_EXISTING ~ar0700.bcs~ ~override~       //fix
              ~ar0300.bcs~ ~override~
              ~ar0400.bcs~ ~override~
              ~ar0500.bcs~ ~override~
              ~ar0900.bcs~ ~override~
 DECOMPILE_BCS_TO_BAF
 REPLACE_TEXTUALLY ~OnCreation()~ ~~
 COMPILE_BAF_TO_BCS

//**************************************************************************
//**************************************************************************
PRINT ~Installing new scripts...~

COMPILE ~CtB/scripts/ctb~
  USING ~CtB/%s/script.tra~
//**************************************************************************
//**************************************************************************
PRINT ~Installing dialogues...~

// Install DLG
COMPILE ~CtB/dialogs/translate~

COMPILE ~CtB/dialogs/app&ext/APPAR.D~
COMPILE ~CtB/dialogs/app&ext/BINNKEEP.D~
COMPILE ~CtB/dialogs/app&ext/BODHI.D~
COMPILE ~CtB/dialogs/app&ext/CECHALLE.D~

COMPILE ~CtB/dialogs/app&ext/FFRECEP.D~
COPY_EXISTING ~FFRECEP.DLG~ ~override~
 WRITE_BYTE 0x30 0 //makes FFRECEP.DLG a pausing dialog - KD: was 2

COMPILE ~CtB/dialogs/app&ext/FIRKRA01.D~
COMPILE ~CtB/dialogs/app&ext/GAELAN.D~
COMPILE ~CtB/dialogs/app&ext/HLSKULL.D~
COMPILE ~CtB/dialogs/app&ext/MGTEOS01.D~
COMPILE ~CtB/dialogs/app&ext/PPUMB01.D~
COMPILE ~CtB/dialogs/app&ext/SBUTLER.D~
COMPILE ~CtB/dialogs/app&ext/SCJERLIA.D~
COMPILE ~CtB/dialogs/app&ext/SCOOK.D~
COMPILE ~CtB/dialogs/app&ext/SGUARD1.D~
COMPILE ~CtB/dialogs/app&ext/SGUARD2.D~
COMPILE ~CtB/dialogs/app&ext/SGUARD3.D~
COMPILE ~CtB/dialogs/app&ext/VAELASA.D~
COMPILE ~CtB/dialogs/app&ext/WMART2.D~
COMPILE ~CtB/dialogs/app&ext/WSMITH01.D~

//***********************************************************
//  Creatures
//***********************************************************
PRINT ~Patching original BG2 creatures...~

COPY_EXISTING ~ARGRIM.CRE~   ~override~
              ~BODYG2.CRE~   ~override~
              ~BYLANNA.CRE~  ~override~
              ~CIVAMNG1.CRE~ ~override~
              ~CIVFRUS1.CRE~ ~override~
              ~CIVIL01.CRE~  ~override~
              ~CIVIL02.CRE~  ~override~
              ~CIVIL03.CRE~  ~override~
              ~CLERK01.CRE~  ~override~
              ~COUNSEC.CRE~  ~override~
              ~HABREGA.CRE~  ~override~
              ~LLARSH.CRE~   ~override~
  WRITE_ASCII 0x260  ~CBXTGBDS~   //General script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~CORGEIG.CRE~ ~override~
              ~CORNEIL.CRE~ ~override~
              ~TOLGER.CRE~  ~override~
  WRITE_ASCII 0x258  ~CBXTGBDS~   //Race script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~BEARBR.CRE~ ~override~
  WRITE_ASCII 0x280  ~BEARBR~ #8  //DV
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~BERINVAR.CRE~ ~override~
              ~HSPECTR1.CRE~ ~override~
              ~HSPECTR2.CRE~ ~override~
              ~HSPECTR3.CRE~ ~override~
              ~MERONIA.CRE~  ~override~
              ~PACE.CRE~     ~override~
              ~TERMER01.CRE~ ~override~
              ~TERMER03.CRE~ ~override~
              ~TERMER04.CRE~ ~override~
              ~TERMER05.CRE~ ~override~
  WRITE_ASCII 0x260  ~CBXTHSDS~   //General script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~C6SQUIRE.CRE~ ~override~
              ~HEARTG1.CRE~  ~override~
              ~HEARTG2.CRE~  ~override~
              ~HEARTG3.CRE~  ~override~
              ~HEARTG4.CRE~  ~override~
              ~HMELVIN.CRE~  ~override~
              ~HPRELATE.CRE~ ~override~
  WRITE_ASCII 0x260  ~CBXTRSDS~   //General script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~CATPAN01.CRE~ ~override~
  WRITE_ASCII 0x280  ~CATPAN01~   //DV
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~COWLD.CRE~    ~override~
              ~COWLED01.CRE~ ~override~
              ~CSCOWL1.CRE~  ~override~
              ~CSCOWL2.CRE~  ~override~
              ~CSCOWL3.CRE~  ~override~
              ~CSCOWL4.CRE~  ~override~
              ~CSCOWL5.CRE~  ~override~
              ~CSCOWL6.CRE~  ~override~
              ~CSCOWL7.CRE~  ~override~
              ~CSCOWL8.CRE~  ~override~
              ~CSCOWL9.CRE~  ~override~
  WRITE_ASCII 0x258  ~CBSCCWNM~   //Race script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~DEER01.CRE~ ~override~
  WRITE_ASCII 0x280  ~DEER01~   //DV
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~DAWNMAS.CRE~ ~override~
              ~LATLARA.CRE~ ~override~
              ~SCSAIN.CRE~  ~override~
  WRITE_ASCII 0x260  ~DAWNMAS~   //General script - non-existing!
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~FFRECEP.CRE~ ~override~
  WRITE_ASCII 0x248  ~~ #8        //Override script
  WRITE_ASCII 0x250  ~CBFFRECP~   //Class script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~FFUSHER1.CRE~ ~override~
              ~FFUSHER2.CRE~ ~override~
  WRITE_ASCII 0x250  ~CBFFUSHA~   //Class script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~FIRWLF01.CRE~ ~override~
              ~FIRWLF02.CRE~ ~override~
  WRITE_ASCII 0x268  ~CBMALDES~   //Default script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~HLKETTA.CRE~  ~override~
              ~HLKETTA2.CRE~ ~override~
              ~HLMAFER.CRE~  ~override~
              ~HLSION.CRE~   ~override~
              ~HLSTAL.CRE~   ~override~
  WRITE_ASCII 0x260  ~HLKETTA2~   //General script - non-existing!
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~ICYUAN01.CRE~ ~override~
              ~ICYUAN02.CRE~ ~override~
              ~ICYUAN03.CRE~ ~override~
              ~ICYUAN04.CRE~ ~override~
              ~ICYUAN05.CRE~ ~override~
              ~KPSHAM01.CRE~ ~override~
              ~KPYUAN01.CRE~ ~override~
  WRITE_ASCII 0x280  ~YUANTI~ #8  //DV
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~KAYL1.CRE~ ~override~
  WRITE_ASCII 0x268  ~CBXTRSDS~   //Default script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~RSKEL01.CRE~ ~override~
  WRITE_ASCII 0x258  ~CBMALDES~   //Race script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~SBUTLER.CRE~ ~override~
  WRITE_ASCII 0x250  ~SGUARD~  #8  //Class script
  WRITE_ASCII 0x280  ~SBUTLER~ #8  //DV
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~SCOOK.CRE~   ~override~
  WRITE_ASCII 0x250  ~SGUARD~ #8  //Class script
  WRITE_ASCII 0x280  ~SCOOK~ #8  //DV
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~SCBUTLER.CRE~ ~override~
              ~SCLJYSS.CRE~  ~override~
              ~SCQAR.CRE~    ~override~
              ~SCSARLES.CRE~ ~override~
  WRITE_ASCII 0x260  ~CBXTJEDS~   //General script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~SGUARD1.CRE~ ~override~
              ~SGUARD2.CRE~ ~override~
  WRITE_ASCII 0x250  ~~ #8        //Class script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~SHAWOL01.CRE~ ~override~
              ~SHAWOL02.CRE~ ~override~
  WRITE_ASCII 0x260  ~CBMALDES~   //General script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~SKELWA02.CRE~ ~override~
  WRITE_ASCII 0x248  ~CBMALDES~   //Override script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~SQUIRL.CRE~ ~override~
  WRITE_ASCII 0x280  ~SQUIRL~ #8  //DV
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~TERMER02.CRE~ ~override~
  WRITE_ASCII 0x258  ~CBXTHSDS~   //Race script
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~WSMITH01.CRE~ ~override~
  WRITE_ASCII 0x258  ~WSMITH01~   //Race script
BUT_ONLY_IF_IT_CHANGES


COPY_EXISTING ~REFIGH01.CRE~       ~override~
 READ_LONG  0x2a0  "known_spells_offset"
 READ_LONG  0x2a4  "known_spells_num"
 READ_LONG  0x2a8  "spell_memorization_offset"
 READ_LONG  0x2ac  "spell_memorization_num"
 READ_LONG  0x2b0  "spell_memorized_offset"
 READ_LONG  0x2b4  "spell_memorized_num"
 READ_LONG  0x2b8  "item_slots_offset"
 READ_LONG  0x2bc  "items_offset"
 READ_LONG  0x2c0  "items_num"
 READ_LONG  0x2c4  "effects_offset"
 READ_LONG  0x2c8  "effects_num"
 SET exists=0
 FOR( cnt=0; cnt<"%items_num%"; cnt=cnt+1 ) BEGIN       //items loop
   READ_ASCII ("%items_offset%"+0x14*cnt)  "name"
   PATCH_IF ( ("%name%" STRING_COMPARE_CASE "CBCLKSCP")=0 ) BEGIN
     SET exists=1
   END
 END
 PATCH_IF( exists=0 ) BEGIN
   SET offset = "%items_offset%" + 0x14*"%items_num%"
   INSERT_BYTES offset            0x14
   WRITE_ASCII  offset            ~CBCLKSCP~
   WRITE_LONG   0x2c0    "%items_num%"+1

   SET "info_ext"=0x14
   PATCH_IF ("%known_spells_offset%">="%items_offset%") BEGIN
     "known_spells_offset"="%known_spells_offset%"+"%info_ext%"
     WRITE_LONG  0x2a0 "%known_spells_offset%"
   END
   PATCH_IF ("%spell_memorization_offset%">="%items_offset%") BEGIN
     "spell_memorization_offset"="%spell_memorization_offset%"+"%info_ext%"
     WRITE_LONG  0x2a8  "%spell_memorization_offset%"
   END
   PATCH_IF ("%spell_memorized_offset%">="%items_offset%") BEGIN
     "spell_memorized_offset"="%spell_memorized_offset%"+"%info_ext%"
     WRITE_LONG  0x2b0  "%spell_memorized_offset%"
   END
   PATCH_IF ("%item_slots_offset%">="%items_offset%") BEGIN
     "item_slots_offset"="%item_slots_offset%"+"%info_ext%"
     WRITE_LONG  0x2b8  "%item_slots_offset%"
   END
   PATCH_IF ("%effects_offset%">="%items_offset%") BEGIN
     "effects_offset"="%effects_offset%"+"%info_ext%"
     WRITE_LONG  0x2c4  "%effects_offset%"
   END
   SET offset = "%item_slots_offset%" + 2*17    //cloak slot
   WRITE_SHORT offset "%items_num%"             //equip item
 END
BUT_ONLY_IF_IT_CHANGES


COPY_EXISTING ~SCJERLIA.CRE~       ~override~
 READ_LONG  0x2a0  "known_spells_offset"
 READ_LONG  0x2a4  "known_spells_num"
 READ_LONG  0x2a8  "spell_memorization_offset"
 READ_LONG  0x2ac  "spell_memorization_num"
 READ_LONG  0x2b0  "spell_memorized_offset"
 READ_LONG  0x2b4  "spell_memorized_num"
 READ_LONG  0x2b8  "item_slots_offset"
 READ_LONG  0x2bc  "items_offset"
 READ_LONG  0x2c0  "items_num"
 READ_LONG  0x2c4  "effects_offset"
 READ_LONG  0x2c8  "effects_num"
 SET exists=0
 FOR( cnt=0; cnt<"%items_num%"; cnt=cnt+1 ) BEGIN       //items loop
   READ_ASCII ("%items_offset%"+0x14*cnt)  "name"
   PATCH_IF ( ("%name%" STRING_COMPARE_CASE "CBRNGMTL")=0 ) BEGIN
     SET exists=1
   END
 END
 PATCH_IF( exists=0 ) BEGIN
   SET offset = "%items_offset%" + 0x14*"%items_num%"
   INSERT_BYTES offset            0x14
   WRITE_ASCII  offset            ~CBRNGMTL~
   WRITE_LONG   0x2c0    "%items_num%"+1

   SET "info_ext"=0x14
   PATCH_IF ("%known_spells_offset%">="%items_offset%") BEGIN
     "known_spells_offset"="%known_spells_offset%"+"%info_ext%"
     WRITE_LONG  0x2a0 "%known_spells_offset%"
   END
   PATCH_IF ("%spell_memorization_offset%">="%items_offset%") BEGIN
     "spell_memorization_offset"="%spell_memorization_offset%"+"%info_ext%"
     WRITE_LONG  0x2a8  "%spell_memorization_offset%"
   END
   PATCH_IF ("%spell_memorized_offset%">="%items_offset%") BEGIN
     "spell_memorized_offset"="%spell_memorized_offset%"+"%info_ext%"
     WRITE_LONG  0x2b0  "%spell_memorized_offset%"
   END
   PATCH_IF ("%item_slots_offset%">="%items_offset%") BEGIN
     "item_slots_offset"="%item_slots_offset%"+"%info_ext%"
     WRITE_LONG  0x2b8  "%item_slots_offset%"
   END
   PATCH_IF ("%effects_offset%">="%items_offset%") BEGIN
     "effects_offset"="%effects_offset%"+"%info_ext%"
     WRITE_LONG  0x2c4  "%effects_offset%"
   END
   SET offset = "%item_slots_offset%" + 2*22    //inv 2 slot
   WRITE_SHORT offset "%items_num%"             //equip item
 END
BUT_ONLY_IF_IT_CHANGES

//ZILFGT01.CRE is a "cutscene-only" creature, so we can overwrite it


PRINT ~Installing new creatures...~
//DKNIGHT soundset
STRING_SET ~23804~ @559136
STRING_SET ~23805~ @559137
STRING_SET ~23806~ @559138
STRING_SET ~23807~ @559139
STRING_SET ~23808~ @559140
STRING_SET ~23810~ @559275
STRING_SET ~23811~ @559276
STRING_SET ~23812~ @559277
STRING_SET ~23813~ @559278

COPY ~CtB/creature/nostring~ ~override~

COPY ~CtB/creature/translate/CB3545XB.CRE~ ~override~ SAY NAME1 @1    SAY NAME2 @1
COPY ~CtB/creature/translate/CB3547BL.CRE~ ~override~ SAY NAME1 @2    SAY NAME2 @2
COPY ~CtB/creature/translate/CB363501.CRE~ ~override~ SAY NAME1 @3    SAY NAME2 @3
COPY ~CtB/creature/translate/CB3647HB.CRE~ ~override~ SAY NAME1 @4    SAY NAME2 @4
COPY ~CtB/creature/translate/CB3650DW.CRE~ ~override~ SAY NAME1 @5    SAY NAME2 @5
COPY ~CtB/creature/translate/CB510BRD.CRE~ ~override~ SAY NAME1 @7    SAY NAME2 @7
COPY ~CtB/creature/translate/CB513REL.CRE~ ~override~ SAY NAME1 @8    SAY NAME2 @8
COPY ~CtB/creature/translate/CB585RNG.CRE~ ~override~ SAY NAME1 @9    SAY NAME2 @9
COPY ~CtB/creature/translate/CB595BLB.CRE~ ~override~ SAY NAME1 @10    SAY NAME2 @10
COPY ~CtB/creature/translate/CB595BRB.CRE~ ~override~ SAY NAME1 @11    SAY NAME2 @11
COPY ~CtB/creature/translate/CB595DRB.CRE~ ~override~ SAY NAME1 @12    SAY NAME2 @12
COPY ~CtB/creature/translate/CB595GRB.CRE~ ~override~ SAY NAME1 @13    SAY NAME2 @13
COPY ~CtB/creature/translate/CB597RIR.CRE~ ~override~ SAY NAME1 @14    SAY NAME2 @14
COPY ~CtB/creature/translate/CB597RIS.CRE~ ~override~ SAY NAME1 @14    SAY NAME2 @14
COPY ~CtB/creature/translate/CB642BAR.CRE~ ~override~ SAY NAME1 @15    SAY NAME2 @15
COPY ~CtB/creature/translate/CBAMLADY.CRE~ ~override~ SAY NAME1 @16    SAY NAME2 @16
COPY ~CtB/creature/translate/CBARKSLV.CRE~ ~override~ SAY NAME1 @17    SAY NAME2 @17
COPY ~CtB/creature/translate/CBAVRVLA.CRE~ ~override~ SAY NAME1 @18    SAY NAME2 @18
COPY ~CtB/creature/translate/CBAVRVLB.CRE~ ~override~ SAY NAME1 @18    SAY NAME2 @18
COPY ~CtB/creature/translate/CBAVRVLC.CRE~ ~override~ SAY NAME1 @18    SAY NAME2 @18
COPY ~CtB/creature/translate/CBAVRVLD.CRE~ ~override~ SAY NAME1 @18    SAY NAME2 @18
COPY ~CtB/creature/translate/CBAVRVLE.CRE~ ~override~ SAY NAME1 @18    SAY NAME2 @18
COPY ~CtB/creature/translate/CBAVRVLF.CRE~ ~override~ SAY NAME1 @18    SAY NAME2 @18
COPY ~CtB/creature/translate/CBAVRVLG.CRE~ ~override~ SAY NAME1 @18    SAY NAME2 @18
COPY ~CtB/creature/translate/CBAVRVLH.CRE~ ~override~ SAY NAME1 @18    SAY NAME2 @18
COPY ~CtB/creature/translate/CBAVRVLI.CRE~ ~override~ SAY NAME1 @18    SAY NAME2 @18
COPY ~CtB/creature/translate/CBAVRVLJ.CRE~ ~override~ SAY NAME1 @18    SAY NAME2 @18
COPY ~CtB/creature/translate/CBAVRVLK.CRE~ ~override~ SAY NAME1 @18    SAY NAME2 @18
COPY ~CtB/creature/translate/CBAVRVLM.CRE~ ~override~ SAY NAME1 @18    SAY NAME2 @18
COPY ~CtB/creature/translate/CBBDAW01.CRE~ ~override~ SAY NAME1 @19    SAY NAME2 @20
COPY ~CtB/creature/translate/CBBDHELP.CRE~ ~override~ SAY NAME1 @19    SAY NAME2 @20
COPY ~CtB/creature/translate/CBBYRN03.CRE~ ~override~ SAY NAME1 @21    SAY NAME2 @21
COPY ~CtB/creature/translate/CBBYRN66.CRE~ ~override~ SAY NAME1 @21    SAY NAME2 @21
COPY ~CtB/creature/translate/CBC8CTC2.CRE~ ~override~ SAY NAME1 @22    SAY NAME2 @22
COPY ~CtB/creature/translate/CBC8CTC3.CRE~ ~override~ SAY NAME1 @22    SAY NAME2 @22
COPY ~CtB/creature/translate/CBC8CTD3.CRE~ ~override~ SAY NAME1 @23    SAY NAME2 @23
COPY ~CtB/creature/translate/CBC8CTF1.CRE~ ~override~ SAY NAME1 @24    SAY NAME2 @24
COPY ~CtB/creature/translate/CBC8CTF2.CRE~ ~override~ SAY NAME1 @24    SAY NAME2 @24
COPY ~CtB/creature/translate/CBC8CTF3.CRE~ ~override~ SAY NAME1 @24    SAY NAME2 @24
COPY ~CtB/creature/translate/CBC8CTL2.CRE~ ~override~ SAY NAME1 @25    SAY NAME2 @25
COPY ~CtB/creature/translate/CBC8CTL3.CRE~ ~override~ SAY NAME1 @25    SAY NAME2 @25
COPY ~CtB/creature/translate/CBC8CTL4.CRE~ ~override~ SAY NAME1 @25    SAY NAME2 @25
COPY ~CtB/creature/translate/CBC8CTM1.CRE~ ~override~ SAY NAME1 @26    SAY NAME2 @26
COPY ~CtB/creature/translate/CBC8CTM2.CRE~ ~override~ SAY NAME1 @26    SAY NAME2 @26
COPY ~CtB/creature/translate/CBC8CTM3.CRE~ ~override~ SAY NAME1 @26    SAY NAME2 @26
COPY ~CtB/creature/translate/CBC8CTU3.CRE~ ~override~ SAY NAME1 @27    SAY NAME2 @27
COPY ~CtB/creature/translate/CBC8CTZA.CRE~ ~override~ SAY NAME1 @28    SAY NAME2 @28
COPY ~CtB/creature/translate/CBC8CTZL.CRE~ ~override~ SAY NAME1 @29    SAY NAME2 @29
COPY ~CtB/creature/translate/CBCEEB01.CRE~ ~override~ SAY NAME1 @30    SAY NAME2 @30
COPY ~CtB/creature/translate/CBDNCSWD.CRE~ ~override~ SAY NAME1 @32    SAY NAME2 @32
COPY ~CtB/creature/translate/CBDRIFAL.CRE~ ~override~ SAY NAME1 @33    SAY NAME2 @33
COPY ~CtB/creature/translate/CBDRIFML.CRE~ ~override~ SAY NAME1 @34    SAY NAME2 @34
COPY ~CtB/creature/translate/CBDRIFSL.CRE~ ~override~ SAY NAME1 @34    SAY NAME2 @34
COPY ~CtB/creature/translate/CBDRIMML.CRE~ ~override~ SAY NAME1 @33    SAY NAME2 @33
COPY ~CtB/creature/translate/CBDRIMSL.CRE~ ~override~ SAY NAME1 @33    SAY NAME2 @33
COPY ~CtB/creature/translate/CBELEDI1.CRE~ ~override~ SAY NAME1 @35    SAY NAME2 @35
COPY ~CtB/creature/translate/CBELEDI2.CRE~ ~override~ SAY NAME1 @36    SAY NAME2 @36
COPY ~CtB/creature/translate/CBGONAST.CRE~ ~override~ SAY NAME1 @37    SAY NAME2 @37
COPY ~CtB/creature/translate/CBGRDYUN.CRE~ ~override~ SAY NAME1 @38    SAY NAME2 @38
COPY ~CtB/creature/translate/CBHARPY1.CRE~ ~override~ SAY NAME1 @39    SAY NAME2 @39
COPY ~CtB/creature/translate/CBHARPYa.CRE~ ~override~ SAY NAME1 @39    SAY NAME2 @39
COPY ~CtB/creature/translate/CBHARPYb.CRE~ ~override~ SAY NAME1 @39    SAY NAME2 @39
COPY ~CtB/creature/translate/CBHARPYc.CRE~ ~override~ SAY NAME1 @39    SAY NAME2 @39
COPY ~CtB/creature/translate/CBHARPYd.CRE~ ~override~ SAY NAME1 @39    SAY NAME2 @39
COPY ~CtB/creature/translate/CBHARPY2.CRE~ ~override~ SAY NAME1 @39    SAY NAME2 @39
COPY ~CtB/creature/translate/CBHARPYw.CRE~ ~override~ SAY NAME1 @39    SAY NAME2 @39
COPY ~CtB/creature/translate/CBHARPYx.CRE~ ~override~ SAY NAME1 @39    SAY NAME2 @39
COPY ~CtB/creature/translate/CBHARPYy.CRE~ ~override~ SAY NAME1 @39    SAY NAME2 @39
COPY ~CtB/creature/translate/CBHARPYz.CRE~ ~override~ SAY NAME1 @39    SAY NAME2 @39
COPY ~CtB/creature/translate/CBHL3627.CRE~ ~override~ SAY NAME1 @40    SAY NAME2 @40
COPY ~CtB/creature/translate/CBHL3631.CRE~ ~override~ SAY NAME1 @41    SAY NAME2 @41
COPY ~CtB/creature/translate/CBHL3634.CRE~ ~override~ SAY NAME1 @40    SAY NAME2 @40
COPY ~CtB/creature/translate/CBHLDYT1.CRE~ ~override~ SAY NAME1 @38    SAY NAME2 @38
COPY ~CtB/creature/translate/CBHLDYT2.CRE~ ~override~ SAY NAME1 @42    SAY NAME2 @42
COPY ~CtB/creature/translate/CBHLDYT3.CRE~ ~override~ SAY NAME1 @43    SAY NAME2 @43
COPY ~CtB/creature/translate/CBHLDYT4.CRE~ ~override~ SAY NAME1 @44    SAY NAME2 @44
COPY ~CtB/creature/translate/CBHLVLNT.CRE~ ~override~ SAY NAME1 @45    SAY NAME2 @45
COPY ~CtB/creature/translate/CBHREDWN.CRE~ ~override~ SAY NAME1 @46    SAY NAME2 @46
COPY ~CtB/creature/translate/CBLSLNDA.CRE~ ~override~ SAY NAME1 @47    SAY NAME2 @47
COPY ~CtB/creature/translate/CBMALMGE.CRE~ ~override~ SAY NAME1 @35    SAY NAME2 @35
COPY ~CtB/creature/translate/CBMALR1.CRE~ ~override~ SAY NAME1 @36    SAY NAME2 @36
COPY ~CtB/creature/translate/CBMALR5A.CRE~ ~override~ SAY NAME1 @48    SAY NAME2 @48
COPY ~CtB/creature/translate/CBMALR6.CRE~ ~override~ SAY NAME1 @49    SAY NAME2 @49
COPY ~CtB/creature/translate/CBMALR7.CRE~ ~override~ SAY NAME1 @50    SAY NAME2 @50
COPY ~CtB/creature/translate/CBMALR8.CRE~ ~override~ SAY NAME1 @50    SAY NAME2 @50
COPY ~CtB/creature/translate/CBMALRDM.CRE~ ~override~ SAY NAME1 @51    SAY NAME2 @51
COPY ~CtB/creature/translate/CBMANARB.CRE~ ~override~ SAY NAME1 @52    SAY NAME2 @52
COPY ~CtB/creature/translate/CBMASTVP.CRE~ ~override~ SAY NAME1 @53    SAY NAME2 @53
COPY ~CtB/creature/translate/CBMONDRP.CRE~ ~override~ SAY NAME1 @55    SAY NAME2 @55
COPY ~CtB/creature/translate/CBMYSTP1.CRE~ ~override~ SAY NAME1 @56    SAY NAME2 @56
COPY ~CtB/creature/translate/CBMYSTP2.CRE~ ~override~ SAY NAME1 @555556    SAY NAME2 @555556
COPY ~CtB/creature/translate/CBMYSTP3.CRE~ ~override~ SAY NAME1 @56    SAY NAME2 @56
COPY ~CtB/creature/translate/CBMYSTP4.CRE~ ~override~ SAY NAME1 @56    SAY NAME2 @56
COPY ~CtB/creature/translate/CBNRT001.CRE~ ~override~ SAY NAME1 @57    SAY NAME2 @57
COPY ~CtB/creature/translate/CBNRT002.CRE~ ~override~ SAY NAME1 @57    SAY NAME2 @57
COPY ~CtB/creature/translate/CBNRT003.CRE~ ~override~ SAY NAME1 @57    SAY NAME2 @57
COPY ~CtB/creature/translate/CBNRT004.CRE~ ~override~ SAY NAME1 @57    SAY NAME2 @57
COPY ~CtB/creature/translate/CBNRT005.CRE~ ~override~ SAY NAME1 @57    SAY NAME2 @57
COPY ~CtB/creature/translate/CBNRT010.CRE~ ~override~ SAY NAME1 @57    SAY NAME2 @57
COPY ~CtB/creature/translate/CBNRT020.CRE~ ~override~ SAY NAME1 @58    SAY NAME2 @58
COPY ~CtB/creature/translate/CBNRT025.CRE~ ~override~ SAY NAME1 @58    SAY NAME2 @58
COPY ~CtB/creature/translate/CBNRTLU1.CRE~ ~override~ SAY NAME1 @59    SAY NAME2 @59
COPY ~CtB/creature/translate/CBNRTLUS.CRE~ ~override~ SAY NAME1 @60    SAY NAME2 @60
COPY ~CtB/creature/translate/CBOWEN03.CRE~ ~override~ SAY NAME1 @61    SAY NAME2 @61
COPY ~CtB/creature/translate/CBOWEN66.CRE~ ~override~ SAY NAME1 @61    SAY NAME2 @61
COPY ~CtB/creature/translate/CBP1ACT1.CRE~ ~override~ SAY NAME1 @62    SAY NAME2 @62
COPY ~CtB/creature/translate/CBP1ACT2.CRE~ ~override~ SAY NAME1 @63    SAY NAME2 @63
COPY ~CtB/creature/translate/CBP1ACT3.CRE~ ~override~ SAY NAME1 @64    SAY NAME2 @64
COPY ~CtB/creature/translate/CBP1ACT4.CRE~ ~override~ SAY NAME1 @65    SAY NAME2 @65
COPY ~CtB/creature/translate/CBP1ACT5.CRE~ ~override~ SAY NAME1 @66    SAY NAME2 @66
COPY ~CtB/creature/translate/CBP1ACT6.CRE~ ~override~ SAY NAME1 @67    SAY NAME2 @67
COPY ~CtB/creature/translate/CBP2ACT1.CRE~ ~override~ SAY NAME1 @68    SAY NAME2 @68
COPY ~CtB/creature/translate/CBP2ACT2.CRE~ ~override~ SAY NAME1 @69    SAY NAME2 @69
COPY ~CtB/creature/translate/CBP2ACT3.CRE~ ~override~ SAY NAME1 @70    SAY NAME2 @70
COPY ~CtB/creature/translate/CBP2ACT4.CRE~ ~override~ SAY NAME1 @71    SAY NAME2 @71
COPY ~CtB/creature/translate/CBP2ACT5.CRE~ ~override~ SAY NAME1 @72    SAY NAME2 @72
COPY ~CtB/creature/translate/CBP2ACT6.CRE~ ~override~ SAY NAME1 @73    SAY NAME2 @73
COPY ~CtB/creature/translate/CBP2ACT7.CRE~ ~override~ SAY NAME1 @74    SAY NAME2 @74
COPY ~CtB/creature/translate/CBPISSMN.CRE~ ~override~ SAY NAME1 @75    SAY NAME2 @75
COPY ~CtB/creature/translate/CBRNCBOY.CRE~ ~override~ SAY NAME1 @76    SAY NAME2 @76
COPY ~CtB/creature/translate/CBRNCBVP.CRE~ ~override~ SAY NAME1 @76    SAY NAME2 @76
COPY ~CtB/creature/translate/CBRNCGRL.CRE~ ~override~ SAY NAME1 @77    SAY NAME2 @77
COPY ~CtB/creature/translate/CBRNCGVP.CRE~ ~override~ SAY NAME1 @77    SAY NAME2 @77
COPY ~CtB/creature/translate/CBRNCHER.CRE~ ~override~ SAY NAME1 @78    SAY NAME2 @78
COPY ~CtB/creature/translate/CBRNCMAN.CRE~ ~override~ SAY NAME1 @79    SAY NAME2 @79
COPY ~CtB/creature/translate/CBRNCMVP.CRE~ ~override~ SAY NAME1 @79    SAY NAME2 @79
COPY ~CtB/creature/translate/CBRNCWFE.CRE~ ~override~ SAY NAME1 @80    SAY NAME2 @80
COPY ~CtB/creature/translate/CBRNCWVP.CRE~ ~override~ SAY NAME1 @80    SAY NAME2 @80
COPY ~CtB/creature/translate/CBRYBERG.CRE~ ~override~ SAY NAME1 @81    SAY NAME2 @81
COPY ~CtB/creature/translate/CBRYBREL.CRE~ ~override~ SAY NAME1 @82    SAY NAME2 @82
COPY ~CtB/creature/translate/CBSCHOOK.CRE~ ~override~ SAY NAME1 @83    SAY NAME2 @83
COPY ~CtB/creature/translate/CBSEACPT.CRE~ ~override~ SAY NAME1 @84    SAY NAME2 @84
COPY ~CtB/creature/translate/CBSELIMS.CRE~ ~override~ SAY NAME1 @85    SAY NAME2 @85
COPY ~CtB/creature/translate/CBSFMESS.CRE~ ~override~ SAY NAME1 @86    SAY NAME2 @86
COPY ~CtB/creature/translate/CBSMHRSE.CRE~ ~override~ SAY NAME1 @87    SAY NAME2 @87
COPY ~CtB/creature/translate/CBSMTRGT.CRE~ ~override~ SAY NAME1 @88    SAY NAME2 @88
COPY ~CtB/creature/translate/CBSPKDED.CRE~ ~override~ SAY NAME1 @89    SAY NAME2 @89
COPY ~CtB/creature/translate/CBSTTFLW.CRE~ ~override~ SAY NAME1 @90    SAY NAME2 @90
COPY ~CtB/creature/translate/CBTARDTH.CRE~ ~override~ SAY NAME1 @91    SAY NAME2 @91
COPY ~CtB/creature/translate/CBTAXCOL.CRE~ ~override~ SAY NAME1 @92    SAY NAME2 @92
COPY ~CtB/creature/translate/CBTREANT.CRE~ ~override~ SAY NAME1 @93    SAY NAME2 @93
COPY ~CtB/creature/translate/CBXTTHEF.CRE~ ~override~ SAY NAME1 @94    SAY NAME2 @94
COPY ~CtB/creature/translate/CBYBGIR1.CRE~ ~override~ SAY NAME1 @35    SAY NAME2 @35
COPY ~CtB/creature/translate/CBYT4446.CRE~ ~override~ SAY NAME1 @38    SAY NAME2 @38
COPY ~CtB/creature/translate/CBYT4447.CRE~ ~override~ SAY NAME1 @38    SAY NAME2 @38
COPY ~CtB/creature/translate/CBZOMB01.CRE~ ~override~ SAY NAME1 @95    SAY NAME2 @95
COPY ~CtB/creature/translate/CBZOMBD1.CRE~ ~override~ SAY NAME1 @95    SAY NAME2 @95
COPY ~CtB/creature/translate/CBZOMB02.CRE~ ~override~ SAY NAME1 @96    SAY NAME2 @96
COPY ~CtB/creature/translate/CBZOMBD2.CRE~ ~override~ SAY NAME1 @96    SAY NAME2 @96
COPY ~CtB/creature/translate/CBZOMB03.CRE~ ~override~ SAY NAME1 @97    SAY NAME2 @97
COPY ~CtB/creature/translate/CBZOMB05.CRE~ ~override~ SAY NAME1 @97    SAY NAME2 @97
COPY ~CtB/creature/translate/CBZOMB07.CRE~ ~override~ SAY NAME1 @97    SAY NAME2 @97
COPY ~CtB/creature/translate/CBZOMB04.CRE~ ~override~ SAY NAME1 @98    SAY NAME2 @98
COPY ~CtB/creature/translate/CBZOMB06.CRE~ ~override~ SAY NAME1 @98    SAY NAME2 @98
COPY ~CtB/creature/translate/CBZOMB08.CRE~ ~override~ SAY NAME1 @98    SAY NAME2 @98
COPY ~CtB/creature/translate/CBZOMB09.CRE~ ~override~ SAY NAME1 @98    SAY NAME2 @98
COPY ~CtB/creature/translate/CBZOMB10.CRE~ ~override~ SAY NAME1 @98    SAY NAME2 @98
COPY ~CtB/creature/translate/CBZOMB11.CRE~ ~override~ SAY NAME1 @98    SAY NAME2 @98
COPY ~CtB/creature/translate/CBZOMB12.CRE~ ~override~ SAY NAME1 @98    SAY NAME2 @98
COPY ~CtB/creature/translate/CBZOMB13.CRE~ ~override~ SAY NAME1 @98    SAY NAME2 @98
COPY ~CtB/creature/translate/CBZOMB0A.CRE~ ~override~ SAY NAME1 @99    SAY NAME2 @99
COPY ~CtB/creature/translate/CBZOMB0B.CRE~ ~override~ SAY NAME1 @99    SAY NAME2 @99
COPY ~CtB/creature/translate/CBZOMB0C.CRE~ ~override~ SAY NAME1 @99    SAY NAME2 @99
COPY ~CtB/creature/translate/CBBGBER1.CRE~ ~override~ SAY NAME1 @650670 SAY NAME2 @650670
COPY ~CtB/creature/translate/CBBGBERa.CRE~ ~override~ SAY NAME1 @650670 SAY NAME2 @650670
COPY ~CtB/creature/translate/CBBGBERb.CRE~ ~override~ SAY NAME1 @650670 SAY NAME2 @650670
COPY ~CtB/creature/translate/CBBGBERc.CRE~ ~override~ SAY NAME1 @650670 SAY NAME2 @650670
COPY ~CtB/creature/translate/CBBGBERd.CRE~ ~override~ SAY NAME1 @650670 SAY NAME2 @650670
COPY ~CtB/creature/translate/CBBGBER2.CRE~ ~override~ SAY NAME1 @650670 SAY NAME2 @650670
COPY ~CtB/creature/translate/CBBGBERw.CRE~ ~override~ SAY NAME1 @650670 SAY NAME2 @650670
COPY ~CtB/creature/translate/CBBGBERx.CRE~ ~override~ SAY NAME1 @650670 SAY NAME2 @650670
COPY ~CtB/creature/translate/CBBGBERy.CRE~ ~override~ SAY NAME1 @650670 SAY NAME2 @650670
COPY ~CtB/creature/translate/CBBGBERz.CRE~ ~override~ SAY NAME1 @650670 SAY NAME2 @650670
COPY ~CtB/creature/translate/CB901SCK.CRE~ ~override~ SAY NAME1 @650691 SAY NAME2 @650691
COPY ~CtB/creature/translate/CBREDDRG.CRE~ ~override~ SAY NAME1 @661006 SAY NAME2 @661006
COPY ~CtB/creature/translate/CBBLKDRG.CRE~ ~override~ SAY NAME1 @661007 SAY NAME2 @661007
COPY ~CtB/creature/translate/CBGRNDRG.CRE~ ~override~ SAY NAME1 @661008 SAY NAME2 @661008
COPY ~CtB/creature/translate/CBYELDRG.CRE~ ~override~ SAY NAME1 @661009 SAY NAME2 @661009

COPY ~CtB/creature/translate/RYNNPC06.CRE~ ~override~
     ~CtB/creature/translate/RYNNPC11.CRE~ ~override~
     ~CtB/creature/translate/RYNNPC15.CRE~ ~override~
     ~CtB/creature/translate/RYNNPC19.CRE~ ~override~
  SAY NAME1             @100
  SAY NAME2             @100
  SAY INITIAL_MEETING   @101
  SAY MORALE            @102
  SAY UNHAPPY_ANNOYED   @103
  SAY UNHAPPY_SERIOUS   @104
  SAY UNHAPPY_BREAKING  @103
  SAY LEADER            @105
  SAY TIRED             @106
  SAY BORED             @107
  SAY BATTLE_CRY1       @108
  SAY BATTLE_CRY2       @109
  SAY BATTLE_CRY3       @110
  SAY BATTLE_CRY4       @111
  SAY BATTLE_CRY5       @112
  SAY DAMAGE            @113
  SAY DYING             @114
  SAY HURT              @115
  SAY SELECT_COMMON1    @116
  SAY SELECT_COMMON2    @117
  SAY SELECT_COMMON3    @118
  SAY SELECT_COMMON4    @119
  SAY SELECT_COMMON5    @120
  SAY SELECT_COMMON6    @121
  SAY SELECT_ACTION1    @122
  SAY SELECT_ACTION2    @123
  SAY SELECT_ACTION3    @124
  SAY REACT_TO_DIE_GENERAL    @125
  SAY REACT_TO_DIE_SPECIFIC    @126
  SAY CRITICAL_HIT      @127
  SAY EXISTANCE5        @128

COPY ~CtB/creature/translate/CBLNIGHT.CRE~ ~override/CBLNIGHT.CRE~ SAY NAME1 @129    SAY NAME2 @129
COPY ~CtB/creature/translate/CBMANVER.CRE~ ~override/CBMANVER.CRE~ SAY NAME1 @130    SAY NAME2 @130
COPY ~CtB/creature/translate/CBELHOE.CRE~ ~override/CBELHOE.CRE~ SAY NAME1 @131    SAY NAME2 @131
COPY ~CtB/creature/translate/CBDEANOH.CRE~ ~override/CBDEANOH.CRE~ SAY NAME1 @132    SAY NAME2 @132
COPY ~CtB/creature/translate/CBMINTO.CRE~ ~override/CBMINTO.CRE~ SAY NAME1 @133    SAY NAME2 @133
COPY ~CtB/creature/translate/CBP3ACT1.CRE~ ~override/CBP3ACT1.CRE~ SAY NAME1 @660006 SAY NAME2 @660006
COPY ~CtB/creature/translate/CBP3ACT2.CRE~ ~override/CBP3ACT2.CRE~ SAY NAME1 @660007 SAY NAME2 @660007
COPY ~CtB/creature/translate/CBP3ACT3.CRE~ ~override/CBP3ACT3.CRE~ SAY NAME1 @660008 SAY NAME2 @660008
COPY ~CtB/creature/translate/CBP3ACT4.CRE~ ~override/CBP3ACT4.CRE~ SAY NAME1 @660009 SAY NAME2 @660009
COPY ~CtB/creature/translate/CBP3ACT5.CRE~ ~override/CBP3ACT5.CRE~ SAY NAME1 @660010 SAY NAME2 @660010
COPY ~CtB/creature/translate/CBP3ACT6.CRE~ ~override/CBP3ACT6.CRE~ SAY NAME1 @660011 SAY NAME2 @660011
COPY ~CtB/creature/translate/CBP3ACT7.CRE~ ~override/CBP3ACT7.CRE~ SAY NAME1 @660012 SAY NAME2 @660012
COPY ~CtB/creature/translate/CBP4ACT1.CRE~ ~override/CBP4ACT1.CRE~ SAY NAME1 @660013 SAY NAME2 @660013
COPY ~CtB/creature/translate/CBP4ACT2.CRE~ ~override/CBP4ACT2.CRE~ SAY NAME1 @660014 SAY NAME2 @660014
COPY ~CtB/creature/translate/CBP4ACT3.CRE~ ~override/CBP4ACT3.CRE~ SAY NAME1 @660015 SAY NAME2 @660015
COPY ~CtB/creature/translate/CBP4ACT4.CRE~ ~override/CBP4ACT4.CRE~ SAY NAME1 @660016 SAY NAME2 @660016
COPY ~CtB/creature/translate/CBP4ACT5.CRE~ ~override/CBP4ACT5.CRE~ SAY NAME1 @660017 SAY NAME2 @660017
COPY ~CtB/creature/translate/CBP4ACT6.CRE~ ~override/CBP4ACT6.CRE~ SAY NAME1 @660018 SAY NAME2 @660018
COPY ~CtB/creature/translate/CBP4ACT7.CRE~ ~override/CBP4ACT7.CRE~ SAY NAME1 @660019 SAY NAME2 @660019
COPY ~CtB/creature/translate/CBP4ACT8.CRE~ ~override/CBP4ACT8.CRE~ SAY NAME1 @660020 SAY NAME2 @660020
COPY ~CtB/creature/translate/CBP4ACT9.CRE~ ~override/CBP4ACT9.CRE~ SAY NAME1 @660021 SAY NAME2 @660021
COPY ~CtB/creature/translate/CBP4ACTa.CRE~ ~override/CBP4ACTa.CRE~ SAY NAME1 @660021 SAY NAME2 @660021
COPY ~CtB/creature/translate/CBP4ACTb.CRE~ ~override/CBP4ACTb.CRE~ SAY NAME1 @660021 SAY NAME2 @660021
COPY ~CtB/creature/translate/CBP4ACTc.CRE~ ~override/CBP4ACTc.CRE~ SAY NAME1 @660021 SAY NAME2 @660021
COPY ~CtB/creature/translate/CBP4ACTd.CRE~ ~override/CBP4ACTd.CRE~ SAY NAME1 @660021 SAY NAME2 @660021
COPY ~CtB/creature/translate/CBP4ACTe.CRE~ ~override/CBP4ACTe.CRE~ SAY NAME1 @660022 SAY NAME2 @660022
COPY ~CtB/creature/translate/CB368DRG.CRE~ ~override/CB368DRG.CRE~ SAY NAME1 @661004 SAY NAME2 @661004
COPY ~CtB/creature/translate/CBUNDEAD.CRE~ ~override/CBUNDEAD.CRE~ SAY NAME1 @661005 SAY NAME2 @661005

COPY_EXISTING ~TEMSUP.CRE~ ~override/TEMSUP.CRE~
  WRITE_ASCII 0x0448 ~CBWAUKEE~

COPY ~CtB/creature/translate/t#mdomo.cre~ ~override~
 SAY NAME1 ~Majordomo~
 SAY NAME2 ~Majordomo~

//***********************************************************
//  Spells
//***********************************************************
PRINT ~Patching original BG2 spells...~

COPY_EXISTING ~SPWI951.SPL~ ~override~
 READ_LONG  0x64 "ability_offset"
 READ_SHORT 0x68 "abil_cnt"
 READ_LONG  0x6a "eff_offset"
 FOR( cnt=0; cnt<"%abil_cnt%"; cnt=cnt+1 ) BEGIN
   READ_BYTE ("%ability_offset%"+cnt*0x28)  "type"
   PATCH_IF("%type%"=1) BEGIN                                      //Melee
     READ_SHORT ("%ability_offset%"+0x28*cnt+0x1e)  eff_cnt
     READ_SHORT ("%ability_offset%"+0x28*cnt+0x20)  eff_idx
     FOR( cnt2=0; cnt2<eff_cnt; cnt2=cnt2+1 ) BEGIN
       READ_SHORT ("%eff_offset%"+0x30*(cnt2+eff_idx))  "eff_type"
       PATCH_IF( "%eff_type%" = 67 ) BEGIN                       //Summon creature
         WRITE_ASCII ("%eff_offset%"+0x30*(cnt2+eff_idx)+0x14) ~CBJELLMU~
       END
       PATCH_IF( "%eff_type%" = 151 ) BEGIN                       //Replace Self -> Summon creature
         WRITE_SHORT ("%eff_offset%"+0x30*(cnt2+eff_idx))      67
         WRITE_BYTE  ("%eff_offset%"+0x30*(cnt2+eff_idx)+2)    1
         WRITE_LONG  ("%eff_offset%"+0x30*(cnt2+eff_idx)+0x0e) 0
         WRITE_ASCII ("%eff_offset%"+0x30*(cnt2+eff_idx)+0x14) ~CBJELLMU~
       END
     END
   END
 END
BUT_ONLY_IF_IT_CHANGES

//***********************************************************
//***********************************************************
PRINT ~Installing new spells...~

COPY ~CtB/spells/nostring~ ~override~

COPY ~CtB/spells/translate/CB587TDR.SPL~ ~override~
  SAY NAME1 @245
COPY ~CtB/spells/translate/CB587TGC.SPL~ ~override~
  SAY NAME1 @246
COPY ~CtB/spells/translate/CB587THL.SPL~ ~override~
  SAY NAME1  @247
COPY ~CtB/spells/translate/CBBARDBT.SPL~ ~override~
  SAY NAME1  @248
COPY ~CtB/spells/translate/CBBARDCT.SPL~ ~override~
  SAY NAME1  @250
  SAY UNIDENTIFIED_DESC @251
COPY ~CtB/spells/translate/CBBARDCU.SPL~ ~override~
  SAY 0x18e  @252
COPY ~CtB/spells/translate/CBBK7535.SPL~ ~override~
  SAY NAME1  @253
COPY ~CtB/spells/translate/CBC8LSXP.SPL~ ~override~
  SAY 0x9e @254
COPY ~CtB/spells/translate/CBCWTHAa.SPL~ ~override~
  SAY NAME1  @255
COPY ~CtB/spells/translate/CBCWTHAb.SPL~ ~override~
  SAY NAME1  @256
COPY ~CtB/spells/translate/CBCWTHAC.SPL~ ~override~
  SAY NAME1  @257
COPY ~CtB/spells/translate/CBCWTHAD.SPL~ ~override~
  SAY NAME1  @258
COPY ~CtB/spells/translate/CBCWTHAE.SPL~ ~override~
  SAY NAME1  @259
COPY ~CtB/spells/translate/CBCWTHAF.SPL~ ~override~
  SAY NAME1  @260
COPY ~CtB/spells/translate/CBCWTHE2.SPL~ ~override~
  SAY NAME1 @261
COPY ~CtB/spells/translate/CBCWTHE4.SPL~ ~override~
  SAY NAME1  @262
COPY ~CtB/spells/translate/CBMALR5a.SPL~ ~override~
  SAY NAME1  @263
  SAY UNIDENTIFIED_DESC @264
COPY ~CtB/spells/translate/CBRNGTV2.SPL~ ~override~
  SAY NAME1  @265
COPY ~CtB/spells/translate/CBSPKDED.SPL~ ~override~
  SAY NAME1  @267
  SAY UNIDENTIFIED_DESC @268
COPY ~CtB/spells/translate/CBWTNI1a.SPL~ ~override~
  SAY 0xce @295
COPY ~CtB/spells/translate/CBWTNI1c.SPL~ ~override~
  SAY 0xce @296
COPY ~CtB/spells/translate/CBWTNI1d.SPL~ ~override~
  SAY 0xce @297
COPY ~CtB/spells/translate/CBWTNI1e.SPL~ ~override~
  SAY 0xce  @298
COPY ~CtB/spells/translate/CBWTNI1g.SPL~ ~override~
  SAY 0xfe @299
COPY ~CtB/spells/translate/CBWTNI1h.SPL~ ~override~
  SAY 0xce @300
COPY ~CtB/spells/translate/CBWTNI1i.SPL~ ~override~
  SAY 0xce  @301
COPY ~CtB/spells/translate/SPIN510.SPL~ ~override~
  SAY NAME1  @302
COPY ~CtB/spells/translate/SPIN511.SPL~ ~override~
  SAY NAME1  @303
COPY ~CtB/spells/translate/SPIN512.SPL~ ~override~
  SAY NAME1  @304
COPY ~CtB/spells/translate/SPIN513.SPL~ ~override~
  SAY NAME1  @305
COPY ~CtB/spells/translate/SPIN514.SPL~ ~override~
  SAY NAME1  @306
  SAY UNIDENTIFIED_DESC @307
COPY ~CtB/spells/translate/SPIN515.SPL~ ~override~
  SAY NAME1  @308
COPY ~CtB/spells/translate/SPIN516.SPL~ ~override~
  SAY NAME1  @309
COPY ~CtB/spells/translate/SPIN517T.SPL~ ~override~      //SPIN517 - was NeJ2 incompatible
  SAY NAME1  @310
COPY ~CtB/spells/translate/SPIN518T.SPL~ ~override~      //SPIN518 - was NeJ2 incompatible
  SAY NAME1  @311

COPY ~CtB/spells/translate/SPWI063.SPL~ ~override~
  SAY 0x15e @343
  
COPY ~CtB/spells/translate/SPWI240.SPL~ ~override~
  SAY NAME1  @346
  SAY UNIDENTIFIED_DESC @347
COPY ~CtB/spells/translate/SPWI540.SPL~ ~override~
  SAY NAME1  @352
  SAY UNIDENTIFIED_DESC @353
COPY ~CtB/spells/translate/SPWI541.SPL~ ~override~
  SAY NAME1  @354
  SAY UNIDENTIFIED_DESC @355
COPY ~CtB/spells/translate/CBWT7g20.SPL~ ~override~
  SAY NAME1 @354
COPY ~CtB/spells/translate/SPWI640.SPL~ ~override~
  SAY NAME1  @356
  SAY UNIDENTIFIED_DESC @357
COPY ~CtB/spells/translate/SPWI642.SPL~ ~override~
  SAY NAME1  @360
  SAY UNIDENTIFIED_DESC @361
COPY ~CtB/spells/translate/SPWI643.SPL~ ~override~
  SAY NAME1  @362
  SAY UNIDENTIFIED_DESC @363

//ACTION_IF NOT FILE_EXISTS ~data/TDD-RULE.BIF~     //TDD compatibility
//THEN BEGIN
//spells are identical to TDD but have much better icons
//so we can just overwrite them
COPY ~CtB/Compat/TDD/SPWI227.SPL~ ~override~
  SAY NAME1  @348
  SAY UNIDENTIFIED_DESC @349
COPY ~CtB/Compat/TDD/SPWI440.SPL~ ~override~
  SAY NAME1  @350
  SAY UNIDENTIFIED_DESC @351
COPY ~CtB/Compat/TDD/SPWI627.SPL~ ~override~
  SAY NAME1  @358
  SAY UNIDENTIFIED_DESC @359
COPY ~CtB/Compat/TDD/SPWI823.SPL~ ~override~
  SAY NAME1  @366
  SAY UNIDENTIFIED_DESC @367
COPY ~CtB/Compat/TDD/SPWI824.SPL~ ~override~
  SAY NAME1  @364
  SAY UNIDENTIFIED_DESC @365
//END

ACTION_IF NOT FILE_EXISTS ~data/ROT-RULE.BIF~     //ROT compatibility
THEN BEGIN
  COPY ~CtB/Compat/RoT/SPWI140.SPL~ ~override~
    SAY NAME1  @344
    SAY UNIDENTIFIED_DESC @345

  COPY ~CtB/Compat/RoT/BAM~ ~override~
END

//***********************************************************
//  Items
//***********************************************************
PRINT ~Installing new items...~

COPY ~CtB/items/nostring~ ~override~

COPY ~CtB/items/translate/CB2HAXE3.ITM~ ~override~
  SAY NAME2 @650005
  SAY DESC @650006
COPY ~CtB/items/translate/CB2HCONV.ITM~ ~override~
  SAY NAME2 @650007
  SAY DESC @650008
COPY ~CtB/items/translate/CB357526.ITM~ ~override~
  SAY NAME2 @650009
  SAY DESC  @650010
COPY ~CtB/items/translate/CB3597ST.ITM~ ~override~
  SAY NAME2 @650011
  SAY DESC @650012
COPY ~CtB/items/translate/CB3647Ha.ITM~ ~override~
  SAY NAME1 @650013
  SAY NAME2 @650013
  SAY UNIDENTIFIED_DESC @650014
  SAY DESC @650014
COPY ~CtB/items/translate/CB3647Hb.ITM~ ~override~
  SAY NAME1 @650015
  SAY NAME2 @650015
  SAY UNIDENTIFIED_DESC @650016
  SAY DESC @650016
COPY ~CtB/items/translate/CB3647Hc.ITM~ ~override~
  SAY NAME1 @650017
  SAY NAME2 @650017
  SAY UNIDENTIFIED_DESC @650018
  SAY DESC @650018
COPY ~CtB/items/translate/CB3647Hd.ITM~ ~override~
  SAY NAME1 @650019
  SAY NAME2 @650019
  SAY UNIDENTIFIED_DESC @650020
  SAY DESC @650020
COPY ~CtB/items/translate/CB3647He.ITM~ ~override~
  SAY NAME1 @650021
  SAY NAME2 @650021
  SAY UNIDENTIFIED_DESC @650022
  SAY DESC @650022
COPY ~CtB/items/translate/CB3647Hf.ITM~ ~override~
  SAY NAME1 @650023
  SAY NAME2 @650023
  SAY UNIDENTIFIED_DESC @650024
  SAY DESC @650024
COPY ~CtB/items/translate/CB3647Hg.ITM~ ~override~
  SAY NAME1 @650025
  SAY NAME2 @650025
  SAY UNIDENTIFIED_DESC @650026
  SAY DESC @650026
COPY ~CtB/items/translate/CB3647Hh.ITM~ ~override~
  SAY NAME1 @650027
  SAY NAME2 @650027
  SAY UNIDENTIFIED_DESC @650028
  SAY DESC @650028
COPY ~CtB/items/translate/CB3647Hi.ITM~ ~override~
  SAY NAME1 @650029
  SAY NAME2 @650029
  SAY UNIDENTIFIED_DESC @650030
  SAY DESC @650030
COPY ~CtB/items/translate/CB3647Hj.ITM~ ~override~
  SAY NAME1 @650031
  SAY NAME2 @650031
  SAY UNIDENTIFIED_DESC @650032
  SAY DESC @650032
COPY ~CtB/items/translate/CB3647Hk.ITM~ ~override~
  SAY NAME1 @650033
  SAY NAME2 @650033
  SAY UNIDENTIFIED_DESC @650034
  SAY DESC @650034
COPY ~CtB/items/translate/CB3647Hl.ITM~ ~override~
  SAY NAME1 @650035
  SAY NAME2 @650035
  SAY UNIDENTIFIED_DESC @650036
  SAY DESC @650036
COPY ~CtB/items/translate/CB3647Hm.ITM~ ~override~
  SAY NAME1 @650039
  SAY NAME2 @650039
  SAY UNIDENTIFIED_DESC @650040
  SAY DESC @650040
COPY ~CtB/items/translate/CB3647Hn.ITM~ ~override~
  SAY NAME1 @650041
  SAY NAME2 @650041
  SAY UNIDENTIFIED_DESC @650042
  SAY DESC @650042
COPY ~CtB/items/translate/CB3647Ho.ITM~ ~override~
  SAY NAME1 @650043
  SAY NAME2 @650043
  SAY UNIDENTIFIED_DESC @650044
  SAY DESC @650044
COPY ~CtB/items/translate/CB3647Hp.ITM~ ~override~
  SAY NAME1 @650045
  SAY NAME2 @650045
  SAY UNIDENTIFIED_DESC @650046
  SAY DESC @650046
COPY ~CtB/items/translate/CB3647M0.ITM~ ~override~
  SAY NAME2 @650037
  SAY DESC @650038
COPY ~CtB/items/translate/CB3647M1.ITM~ ~override~
  SAY NAME2 @650037
  SAY DESC @650038
COPY ~CtB/items/translate/CB3647M2.ITM~ ~override~
  SAY NAME2 @650037
  SAY DESC @650038
COPY ~CtB/items/translate/CB3647M3.ITM~ ~override~
  SAY NAME2 @650037
  SAY DESC @650038
COPY ~CtB/items/translate/CB3647M4.ITM~ ~override~
  SAY NAME2 @650037
  SAY DESC @650038
  SAY 0x1ce @650047
  SAY 0x1fe @650048
  SAY 0x22e @650049
  SAY 0x25e @650050
  SAY 0x28e @650051
COPY ~CtB/items/translate/CB3647M5.ITM~ ~override~
  SAY NAME2 @650037
  SAY DESC @650038
COPY ~CtB/items/translate/CB3647M6.ITM~ ~override~
  SAY NAME2 @650037
  SAY DESC @650038
COPY ~CtB/items/translate/CB3647M7.ITM~ ~override~
  SAY NAME2 @650037
  SAY DESC @650038
COPY ~CtB/items/translate/CB3647M8.ITM~ ~override~
  SAY NAME2 @650037
  SAY DESC @650038
COPY ~CtB/items/translate/CB3647M9.ITM~ ~override~
  SAY NAME2 @650037
  SAY DESC @650038
COPY ~CtB/items/translate/CB502D1D.ITM~ ~override~
  SAY NAME1 @650052
  SAY NAME2 @650052
  SAY UNIDENTIFIED_DESC @650053
  SAY DESC @650053
COPY ~CtB/items/translate/CB502D1H.ITM~ ~override~
  SAY NAME1 @650054
  SAY NAME2 @650054
  SAY UNIDENTIFIED_DESC @650055
  SAY DESC @650055
COPY ~CtB/items/translate/CB502D1N.ITM~ ~override~
  SAY NAME1 @650056
  SAY NAME2 @650056
  SAY UNIDENTIFIED_DESC @650057
  SAY DESC @650057
COPY ~CtB/items/translate/CB502D1P.ITM~ ~override~
  SAY NAME1 @650058
  SAY NAME2 @650058
  SAY UNIDENTIFIED_DESC @650059
  SAY DESC @650059
COPY ~CtB/items/translate/CB502D1S.ITM~ ~override~
  SAY NAME1 @650061
  SAY NAME2 @650061
  SAY UNIDENTIFIED_DESC @650062
  SAY DESC @650062
COPY ~CtB/items/translate/CB502D2B.ITM~ ~override~
  SAY NAME1 @650063
  SAY NAME2 @650063
  SAY UNIDENTIFIED_DESC @650064
  SAY DESC @650064
COPY ~CtB/items/translate/CB502D2D.ITM~ ~override~
  SAY NAME1 @650066
  SAY NAME2 @650066
  SAY UNIDENTIFIED_DESC @650067
  SAY DESC @650067
COPY ~CtB/items/translate/CB502D2N.ITM~ ~override~
  SAY NAME1 @650068
  SAY NAME2 @650068
  SAY UNIDENTIFIED_DESC @650069
  SAY DESC @650069
COPY ~CtB/items/translate/CB502D2T.ITM~ ~override~
  SAY NAME1 @650070
  SAY NAME2 @650070
  SAY UNIDENTIFIED_DESC @650071
  SAY DESC @650071
COPY ~CtB/items/translate/CB502D3D.ITM~ ~override~
  SAY NAME1 @650072
  SAY NAME2 @650072
  SAY UNIDENTIFIED_DESC @650073
  SAY DESC @650073
COPY ~CtB/items/translate/CB502D3G.ITM~ ~override~
  SAY NAME1 @650074
  SAY NAME2 @650074
  SAY UNIDENTIFIED_DESC @650075
  SAY DESC @650075
COPY ~CtB/items/translate/CB502D3N.ITM~ ~override~
  SAY NAME1 @650076
  SAY NAME2 @650076
  SAY UNIDENTIFIED_DESC @650077
  SAY DESC @650077
COPY ~CtB/items/translate/CB502D3U.ITM~ ~override~
  SAY NAME1 @650078
  SAY NAME2 @650078
  SAY UNIDENTIFIED_DESC @650079
  SAY DESC @650079
COPY ~CtB/items/translate/CB502D4F.ITM~ ~override~
  SAY NAME1 @650080
  SAY NAME2 @650080
  SAY UNIDENTIFIED_DESC @650081
  SAY DESC @650081
COPY ~CtB/items/translate/CB502D4G.ITM~ ~override~
  SAY NAME1 @650082
  SAY NAME2 @650082
  SAY UNIDENTIFIED_DESC @650083
  SAY DESC @650083
COPY ~CtB/items/translate/CB502D4H.ITM~ ~override~
  SAY NAME1 @650084
  SAY NAME2 @650084
  SAY UNIDENTIFIED_DESC @650085
  SAY DESC @650085
COPY ~CtB/items/translate/CB502D4N.ITM~ ~override~
  SAY NAME1 @650086
  SAY NAME2 @650086
  SAY UNIDENTIFIED_DESC @650087
  SAY DESC @650087
COPY ~CtB/items/translate/CB502D5B.ITM~ ~override~
  SAY NAME1 @650088
  SAY NAME2 @650088
  SAY UNIDENTIFIED_DESC @650089
  SAY DESC @650089
COPY ~CtB/items/translate/CB502D5N.ITM~ ~override~
  SAY NAME1 @650090
  SAY NAME2 @650090
  SAY UNIDENTIFIED_DESC @650091
  SAY DESC @650091
COPY ~CtB/items/translate/CB502D5O.ITM~ ~override~
  SAY NAME1 @650092
  SAY NAME2 @650092
  SAY UNIDENTIFIED_DESC @650093
  SAY DESC @650093
COPY ~CtB/items/translate/CB502D5P.ITM~ ~override~
  SAY NAME1 @650095
  SAY NAME2 @650095
  SAY UNIDENTIFIED_DESC @650096
  SAY DESC @650096
COPY ~CtB/items/translate/CB50ROPE.ITM~ ~override~
  SAY NAME1 @650097
  SAY NAME2 @650097
  SAY UNIDENTIFIED_DESC @650098
  SAY DESC @650098
COPY ~CtB/items/translate/CB513REL.ITM~ ~override~
  SAY NAME1 @650099
  SAY NAME2 @650099
  SAY UNIDENTIFIED_DESC @650100
  SAY DESC @650100
COPY ~CtB/items/translate/CB587SED.ITM~ ~override~
  SAY NAME1 @650101
  SAY NAME2 @650101
  SAY UNIDENTIFIED_DESC @650102
  SAY DESC @650102
COPY ~CtB/items/translate/CBAMCAKE.ITM~ ~override~
  SAY NAME1 @650103
  SAY NAME2 @650103
  SAY UNIDENTIFIED_DESC @650104
  SAY DESC @650104
  SAY 0xae @650105
COPY ~CtB/items/translate/CBAROWP3.ITM~ ~override~
  SAY NAME2 @650001
  SAY DESC @650108
COPY ~CtB/items/translate/CBAROWP4.ITM~ ~override~
  SAY NAME2 @650109
  SAY DESC @650110
COPY ~CtB/items/translate/CBBDARMR.ITM~ ~override~
  SAY NAME2 @650111
  SAY UNIDENTIFIED_DESC @650112
  SAY DESC @650113
COPY ~CtB/items/translate/CBBDSCLE.ITM~ ~override~
  SAY NAME1 @650114
  SAY NAME2 @650114
  SAY UNIDENTIFIED_DESC @650116
  SAY DESC @650116
COPY ~CtB/items/translate/CBBDTOTH.ITM~ ~override~
  SAY NAME1 @650117
  SAY NAME2 @650118
  SAY UNIDENTIFIED_DESC @650119
  SAY DESC @650120
  SAY 0x13e @650121
COPY ~CtB/items/translate/CBBK7501.ITM~ ~override~
  SAY NAME2 @650122
  SAY UNIDENTIFIED_DESC @650123
  SAY DESC @650123
COPY ~CtB/items/translate/CBBK7502.ITM~ ~override~
  SAY NAME1 @650124
  SAY NAME2 @650124
  SAY UNIDENTIFIED_DESC @650125
  SAY DESC @650125
COPY ~CtB/items/translate/CBBK7503.ITM~ ~override~
  SAY NAME1 @650126
  SAY NAME2 @650126
  SAY UNIDENTIFIED_DESC @650127
  SAY DESC @650127
COPY ~CtB/items/translate/CBBK7504.ITM~ ~override~
  SAY NAME1 @650128
  SAY NAME2 @650128
  SAY UNIDENTIFIED_DESC @650129
  SAY DESC @650129
COPY ~CtB/items/translate/CBBK7505.ITM~ ~override~
  SAY NAME1 @650130
  SAY NAME2 @650130
  SAY UNIDENTIFIED_DESC @650131
  SAY DESC @650131
COPY ~CtB/items/translate/CBBK7506.ITM~ ~override~
  SAY NAME1 @650132
  SAY NAME2 @650132
  SAY UNIDENTIFIED_DESC @650133
  SAY DESC @650133
COPY ~CtB/items/translate/CBBK7507.ITM~ ~override~
  SAY NAME1 @650134
  SAY NAME2 @650134
  SAY UNIDENTIFIED_DESC @650135
  SAY DESC @650135
COPY ~CtB/items/translate/CBBK7508.ITM~ ~override~
  SAY NAME1 @650136
  SAY NAME2 @650136
  SAY UNIDENTIFIED_DESC @650137
  SAY DESC @650137
COPY ~CtB/items/translate/CBBK7509.ITM~ ~override~
  SAY NAME1 @650138
  SAY NAME2 @650138
  SAY UNIDENTIFIED_DESC @650139
  SAY DESC @650139
COPY ~CtB/items/translate/CBBK7510.ITM~ ~override~
  SAY NAME1 @650140
  SAY NAME2 @650140
  SAY UNIDENTIFIED_DESC @650141
  SAY DESC @650141
COPY ~CtB/items/translate/CBBK7511.ITM~ ~override~
  SAY NAME1 @650142
  SAY NAME2 @650142
  SAY UNIDENTIFIED_DESC @650143
  SAY DESC @650143
COPY ~CtB/items/translate/CBBK7512.ITM~ ~override~
  SAY NAME1 @650144
  SAY NAME2 @650144
  SAY UNIDENTIFIED_DESC @650145
  SAY DESC @650145
COPY ~CtB/items/translate/CBBK7513.ITM~ ~override~
  SAY NAME1 @650146
  SAY NAME2 @650146
  SAY UNIDENTIFIED_DESC @650147
  SAY DESC @650147
COPY ~CtB/items/translate/CBBK7514.ITM~ ~override~
  SAY NAME1 @650148
  SAY NAME2 @650148
  SAY UNIDENTIFIED_DESC @650149
  SAY DESC @650149
COPY ~CtB/items/translate/CBBK7515.ITM~ ~override~
  SAY NAME1 @650150
  SAY NAME2 @650150
  SAY UNIDENTIFIED_DESC @650151
  SAY DESC @650151
COPY ~CtB/items/translate/CBBK7516.ITM~ ~override~
  SAY NAME1 @650152
  SAY NAME2 @650152
  SAY UNIDENTIFIED_DESC @650153
  SAY DESC @650153
COPY ~CtB/items/translate/CBBK7517.ITM~ ~override~
  SAY NAME1 @650154
  SAY NAME2 @650154
  SAY UNIDENTIFIED_DESC @650155
  SAY DESC @650155
COPY ~CtB/items/translate/CBBK7518.ITM~ ~override~
  SAY NAME1 @650156
  SAY NAME2 @650156
  SAY UNIDENTIFIED_DESC @650157
  SAY DESC @650157
COPY ~CtB/items/translate/CBBK7519.ITM~ ~override~
  SAY NAME1 @650158
  SAY NAME2 @650158
  SAY UNIDENTIFIED_DESC @650159
  SAY DESC @650159
COPY ~CtB/items/translate/CBBK7520.ITM~ ~override~
  SAY NAME1 @650160
  SAY NAME2 @650160
  SAY UNIDENTIFIED_DESC @650161
  SAY DESC @650161
COPY ~CtB/items/translate/CBBK7521.ITM~ ~override~
  SAY NAME2 @650162
  SAY DESC @650163
COPY ~CtB/items/translate/CBBK7522.ITM~ ~override~
  SAY NAME1 @650164
  SAY NAME2 @650164
  SAY UNIDENTIFIED_DESC @650165
  SAY DESC @650165
COPY ~CtB/items/translate/CBBK7523.ITM~ ~override~
  SAY NAME1 @650166
  SAY NAME2 @650166
  SAY UNIDENTIFIED_DESC @650167
  SAY DESC @650167
COPY ~CtB/items/translate/CBBK7524.ITM~ ~override~
  SAY NAME1 @650168
  SAY NAME2 @650168
  SAY UNIDENTIFIED_DESC @650169
  SAY DESC @650169
COPY ~CtB/items/translate/CBBK7525.ITM~ ~override~
  SAY NAME1 @650170
  SAY NAME2 @650170
  SAY UNIDENTIFIED_DESC @650171
  SAY DESC @650171
COPY ~CtB/items/translate/CBBK7526.ITM~ ~override~
  SAY NAME2 @650172
  SAY UNIDENTIFIED_DESC @650173
  SAY DESC @650174
COPY ~CtB/items/translate/CBBK7527.ITM~ ~override~
  SAY NAME1 @650175
  SAY NAME2 @650175
  SAY UNIDENTIFIED_DESC @650176
  SAY DESC @650176
COPY ~CtB/items/translate/CBBK7528.ITM~ ~override~
  SAY NAME1 @650177
  SAY NAME2 @650177
  SAY UNIDENTIFIED_DESC @650178
  SAY DESC @650178
COPY ~CtB/items/translate/CBBK7529.ITM~ ~override~
  SAY NAME1 @650179
  SAY NAME2 @650179
  SAY UNIDENTIFIED_DESC @650180
  SAY DESC @650180
COPY ~CtB/items/translate/CBBK7530.ITM~ ~override~
  SAY NAME1 @650181
  SAY NAME2 @650181
  SAY UNIDENTIFIED_DESC @650182
  SAY DESC @650182
COPY ~CtB/items/translate/CBBK7531.ITM~ ~override~
  SAY NAME1 @650183
  SAY NAME2 @650183
  SAY UNIDENTIFIED_DESC @650184
  SAY DESC @650184
COPY ~CtB/items/translate/CBBK7532.ITM~ ~override~
  SAY NAME1 @650185
  SAY NAME2 @650185
  SAY UNIDENTIFIED_DESC @650186
  SAY DESC @650186
COPY ~CtB/items/translate/CBBK7533.ITM~ ~override~
  SAY NAME2 @650187
  SAY DESC @650188
COPY ~CtB/items/translate/CBBK7534.ITM~ ~override~
  SAY NAME2 @650189
  SAY DESC @650190
COPY ~CtB/items/translate/CBBK7535.ITM~ ~override~
  SAY NAME2 @650191
  SAY DESC @650192
COPY ~CtB/items/translate/CBBK7536.ITM~ ~override~
  SAY NAME2 @650193
  SAY DESC @650194
COPY ~CtB/items/translate/CBBK7537.ITM~ ~override~
  SAY NAME2 @650195
  SAY DESC @650196
COPY ~CtB/items/translate/CBBK7538.ITM~ ~override~
  SAY NAME2 @650197
  SAY DESC @650198
COPY ~CtB/items/translate/CBBK7539.ITM~ ~override~
  SAY NAME1 @650199
  SAY NAME2 @650199
  SAY UNIDENTIFIED_DESC @650200
  SAY DESC @650200
COPY ~CtB/items/translate/CBBK7540.ITM~ ~override~
  SAY NAME1 @650201
  SAY NAME2 @650201
  SAY UNIDENTIFIED_DESC @650202
  SAY DESC @650202
COPY ~CtB/items/translate/CBBK7541.ITM~ ~override~
  SAY NAME1 @650203
  SAY NAME2 @650203
  SAY UNIDENTIFIED_DESC @650204
  SAY DESC @650204
COPY ~CtB/items/translate/CBBK7542.ITM~ ~override~
  SAY NAME1 @650205
  SAY NAME2 @650205
  SAY UNIDENTIFIED_DESC @650206
  SAY DESC @650206
COPY ~CtB/items/translate/CBBK7543.ITM~ ~override~
  SAY NAME1 @650207
  SAY NAME2 @650207
  SAY UNIDENTIFIED_DESC @650208
  SAY DESC @650208
COPY ~CtB/items/translate/CBBK7544.ITM~ ~override~
  SAY NAME1 @650209
  SAY NAME2 @650209
  SAY UNIDENTIFIED_DESC @650210
  SAY DESC @650210
COPY ~CtB/items/translate/CBBK7545.ITM~ ~override~
  SAY NAME1 @650211
  SAY NAME2 @650211
  SAY UNIDENTIFIED_DESC @650212
  SAY DESC @650212
COPY ~CtB/items/translate/CBBK7546.ITM~ ~override~
  SAY NAME1 @650213
  SAY NAME2 @650213
  SAY UNIDENTIFIED_DESC @650214
  SAY DESC @650214
COPY ~CtB/items/translate/CBBK7547.ITM~ ~override~
  SAY NAME1 @650215
  SAY NAME2 @650215
  SAY UNIDENTIFIED_DESC @650216
  SAY DESC @650216
COPY ~CtB/items/translate/CBBK7548.ITM~ ~override~
  SAY NAME1 @650217
  SAY NAME2 @650217
  SAY UNIDENTIFIED_DESC @650218
  SAY DESC @650218
COPY ~CtB/items/translate/CBBK7549.ITM~ ~override~
  SAY NAME1 @650219
  SAY NAME2 @650219
  SAY UNIDENTIFIED_DESC @650220
  SAY DESC @650220
COPY ~CtB/items/translate/CBBK7550.ITM~ ~override~
  SAY NAME1 @650221
  SAY NAME2 @650221
  SAY UNIDENTIFIED_DESC @650222
  SAY DESC @650222
COPY ~CtB/items/translate/CBBK7551.ITM~ ~override~
  SAY NAME1 @650223
  SAY NAME2 @650223
  SAY UNIDENTIFIED_DESC @650224
  SAY DESC @650224
COPY ~CtB/items/translate/CBBK7552.ITM~ ~override~
  SAY NAME1 @650225
  SAY NAME2 @650225
  SAY UNIDENTIFIED_DESC @650226
  SAY DESC @650226
COPY ~CtB/items/translate/CBBK7553.ITM~ ~override~
  SAY NAME1 @650227
  SAY NAME2 @650227
  SAY UNIDENTIFIED_DESC @650228
  SAY DESC @650228
COPY ~CtB/items/translate/CBBK7554.ITM~ ~override~
  SAY NAME1 @650229
  SAY NAME2 @650230
  SAY UNIDENTIFIED_DESC @650231
  SAY DESC @650232
COPY ~CtB/items/translate/CBBK7555.ITM~ ~override~
  SAY NAME1 @650229
  SAY NAME2 @650233
  SAY UNIDENTIFIED_DESC @650231
  SAY DESC @650234
COPY ~CtB/items/translate/CBBK7556.ITM~ ~override~
  SAY NAME1 @650229
  SAY NAME2 @650235
  SAY UNIDENTIFIED_DESC @650231
  SAY DESC @650236
COPY ~CtB/items/translate/CBBK7557.ITM~ ~override~
  SAY NAME1 @650229
  SAY NAME2 @650237
  SAY UNIDENTIFIED_DESC @650231
  SAY DESC @650238
COPY ~CtB/items/translate/CBBK7558.ITM~ ~override~
  SAY NAME1 @650229
  SAY NAME2 @650239
  SAY UNIDENTIFIED_DESC @650231
  SAY DESC @650240
COPY ~CtB/items/translate/CBBK7559.ITM~ ~override~
  SAY NAME1 @650241
  SAY NAME2 @650241
  SAY UNIDENTIFIED_DESC @650242
  SAY DESC @650242
COPY ~CtB/items/translate/CBBK7560.ITM~ ~override~
  SAY NAME1 @650243
  SAY NAME2 @650243
  SAY UNIDENTIFIED_DESC @650244
  SAY DESC @650244
COPY ~CtB/items/translate/CBBK7561.ITM~ ~override~
  SAY NAME1 @650245
  SAY NAME2 @650245
  SAY UNIDENTIFIED_DESC @650246
  SAY DESC @650246
COPY ~CtB/items/translate/CBBRCSPL.ITM~ ~override~
  SAY NAME2 @650247
  SAY DESC @650248
COPY ~CtB/items/translate/CBBSWRD2.ITM~ ~override~
  SAY NAME1 @650249
  SAY NAME2 @650250
  SAY UNIDENTIFIED_DESC @650251
  SAY DESC @650252
COPY ~CtB/items/translate/CBCHANP4.ITM~ ~override~
  SAY NAME2 @650254
  SAY DESC @650256
COPY ~CtB/items/translate/CBCLCKP3.ITM~ ~override~
  SAY NAME2 @650258
  SAY DESC @650260
COPY ~CtB/items/translate/CBCLKSCP.ITM~ ~override~
  SAY NAME2 @650261
  SAY DESC @650262
COPY ~CtB/items/translate/CBCO8ROD.ITM~ ~override~
  SAY NAME2 @650263
  SAY DESC @650264
COPY ~CtB/items/translate/CBCRYBLL.ITM~ ~override~
  SAY NAME2 @650266
  SAY UNIDENTIFIED_DESC @650267
  SAY DESC @650268
COPY ~CtB/items/translate/CBCWRSCH.ITM~ ~override~
  SAY NAME1 @650269
  SAY NAME2 @650269
  SAY UNIDENTIFIED_DESC @650270
  SAY DESC @650270
COPY ~CtB/items/translate/CBCWSTFF.ITM~ ~override~
  SAY NAME2 @650271
  SAY DESC @650272
COPY ~CtB/items/translate/CBCWUMST.ITM~ ~override~
  SAY NAME2 @650273
  SAY DESC @650274
COPY ~CtB/items/translate/CBDAGGDS.ITM~ ~override~
  SAY NAME2 @650275
  SAY DESC @650276
COPY ~CtB/items/translate/CBDGCONV.ITM~ ~override~
  SAY NAME2 @650007
  SAY DESC @650277
COPY ~CtB/items/translate/CBDGGMSS.ITM~ ~override~
  SAY NAME2 @650278
  SAY DESC @650279

COPY ~CtB/items/translate/CBDNCSWD.ITM~ ~override~
COPY ~CtB/items/translate/CBDRDSWD.ITM~ ~override~
  SAY NAME2 @650284
  SAY DESC @650285

COPY ~CtB/items/translate/CBDRSTF1.ITM~ ~override~
  SAY NAME1 @650286
  SAY NAME2 @650286
  SAY UNIDENTIFIED_DESC @650287
  SAY DESC @650287

COPY ~CtB/items/translate/CBDRSTF2.ITM~ ~override~
  SAY NAME2 @650288
  SAY DESC @650289
COPY ~CtB/items/translate/CBDRSTF3.ITM~ ~override~
  SAY NAME2 @650288
  SAY DESC @650290

COPY ~CtB/items/translate/CBDRSwod.ITM~ ~override~
  SAY NAME1 @650291
  SAY NAME2 @650291
  SAY UNIDENTIFIED_DESC @650292
  SAY DESC @650292
COPY ~CtB/items/translate/CBEM25SD.ITM~ ~override~
  SAY NAME1 @650293
  SAY NAME2 @650293
  SAY UNIDENTIFIED_DESC @650294
  SAY DESC @650294
COPY ~CtB/items/translate/CBEMHILT.ITM~ ~override~
  SAY NAME2 @650295
  SAY UNIDENTIFIED_DESC @650296
  SAY DESC @650297
COPY ~CtB/items/translate/CBEMMETL.ITM~ ~override~
  SAY NAME1 @650298
  SAY NAME2 @650298
  SAY UNIDENTIFIED_DESC @650299
  SAY DESC @650299
COPY ~CtB/items/translate/CBEMMOON.ITM~ ~override~
  SAY DESC @650300
COPY ~CtB/items/translate/CBGEMSEE.ITM~ ~override~
  SAY NAME1 @650301
  SAY NAME2 @650302
  SAY UNIDENTIFIED_DESC @650303
  SAY DESC @650304
COPY ~CtB/items/translate/CBGONAST.ITM~ ~override~
  SAY NAME1 @650305
  SAY NAME2 @650305
  SAY UNIDENTIFIED_DESC @650306
  SAY DESC @650306
COPY ~CtB/items/translate/CBHLD001.ITM~ ~override~
  SAY NAME2 @650307
  SAY DESC @650308
COPY ~CtB/items/translate/CBHLD002.ITM~ ~override~
  SAY DESC @650310
COPY ~CtB/items/translate/CBHLFD01.ITM~ ~override~
  SAY NAME1 @650311
  SAY NAME2 @650311
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD02.ITM~ ~override~
  SAY NAME1 @650313
  SAY NAME2 @650313
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD03.ITM~ ~override~
  SAY NAME1 @650314
  SAY NAME2 @650314
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD04.ITM~ ~override~
  SAY NAME1 @650315
  SAY NAME2 @650315
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD05.ITM~ ~override~
  SAY NAME1 @650316
  SAY NAME2 @650316
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD06.ITM~ ~override~
  SAY NAME1 @650317
  SAY NAME2 @650317
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD07.ITM~ ~override~
  SAY NAME1 @650318
  SAY NAME2 @650318
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD08.ITM~ ~override~
  SAY NAME1 @650319
  SAY NAME2 @650319
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD09.ITM~ ~override~
  SAY NAME1 @650320
  SAY NAME2 @650320
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD10.ITM~ ~override~
  SAY NAME1 @650321
  SAY NAME2 @650321
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD11.ITM~ ~override~
  SAY NAME1 @650322
  SAY NAME2 @650322
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD12.ITM~ ~override~
  SAY NAME1 @650323
  SAY NAME2 @650323
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD13.ITM~ ~override~
  SAY NAME1 @650324
  SAY NAME2 @650324
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD14.ITM~ ~override~
  SAY NAME1 @650325
  SAY NAME2 @650325
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD15.ITM~ ~override~
  SAY NAME1 @650326
  SAY NAME2 @650326
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD16.ITM~ ~override~
  SAY NAME1 @650327
  SAY NAME2 @650327
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD17.ITM~ ~override~
  SAY NAME1 @650328
  SAY NAME2 @650328
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD18.ITM~ ~override~
  SAY NAME1 @650329
  SAY NAME2 @650329
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD19.ITM~ ~override~
  SAY NAME1 @650330
  SAY NAME2 @650330
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD20.ITM~ ~override~
  SAY NAME1 @650331
  SAY NAME2 @650331
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD21.ITM~ ~override~
  SAY NAME1 @650332
  SAY NAME2 @650332
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD22.ITM~ ~override~
  SAY NAME1 @650333
  SAY NAME2 @650333
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD23.ITM~ ~override~
  SAY NAME1 @650334
  SAY NAME2 @650334
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD24.ITM~ ~override~
  SAY NAME1 @650335
  SAY NAME2 @650335
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLFD25.ITM~ ~override~
  SAY NAME1 @650336
  SAY NAME2 @650336
  SAY UNIDENTIFIED_DESC @650312
  SAY DESC @650312
COPY ~CtB/items/translate/CBHLGATE.ITM~ ~override~
  SAY NAME1 @650337
  SAY NAME2 @650338
  SAY UNIDENTIFIED_DESC @650339
  SAY DESC @650340
COPY ~CtB/items/translate/CBHLYTA2.ITM~ ~override~
  SAY NAME1 @650341
  SAY NAME2 @650342
  SAY DESC @650343
COPY ~CtB/items/translate/CBHLYTAX.ITM~ ~override~
  SAY NAME1 @650341
  SAY NAME2 @650344
  SAY DESC @650345
COPY ~CtB/items/translate/CBICEBLK.ITM~ ~override~
  SAY NAME1 @650346
  SAY NAME2 @650346
  SAY UNIDENTIFIED_DESC @650347
  SAY DESC @650347
COPY ~CtB/items/translate/CBKY3643.ITM~ ~override~
  SAY UNIDENTIFIED_DESC @650348
  SAY DESC @650348
COPY ~CtB/items/translate/CBLSCONV.ITM~ ~override~
  SAY NAME2 @650007
  SAY DESC @650354
COPY ~CtB/items/translate/CBMALDUP.ITM~ ~override~
  SAY NAME1 @650355
  SAY NAME2 @650355
  SAY UNIDENTIFIED_DESC @650356
  SAY DESC @650356
COPY ~CtB/items/translate/CBMALMGE.ITM~ ~override~
  SAY NAME1 @650357
  SAY NAME2 @650358
  SAY UNIDENTIFIED_DESC @650359
  SAY DESC @650360
COPY ~CtB/items/translate/CBMALR1a.ITM~ ~override~
  SAY NAME2 @650361
  SAY DESC @650362
COPY ~CtB/items/translate/CBMALR2a.ITM~ ~override~
  SAY NAME2 @650363
  SAY DESC @650364
COPY ~CtB/items/translate/CBMALR3a.ITM~ ~override~
  SAY NAME2 @650365
  SAY DESC @650366
COPY ~CtB/items/translate/CBMALR3b.ITM~ ~override~
  SAY NAME1 @650367
  SAY NAME2 @650367
COPY ~CtB/items/translate/CBMALR4a.ITM~ ~override~
  SAY NAME2 @650368
  SAY DESC @650369
COPY ~CtB/items/translate/CBMALR5a.ITM~ ~override~
  SAY NAME2 @263
  SAY DESC  @264
COPY ~CtB/items/translate/CBMALR6a.ITM~ ~override~
  SAY NAME1 @650372
  SAY NAME2 @650373
  SAY UNIDENTIFIED_DESC @650374
  SAY DESC @650375
COPY ~CtB/items/translate/CBMALR6b.ITM~ ~override~
  SAY NAME1 @650376
  SAY NAME2 @650376
COPY ~CtB/items/translate/CBMALR6c.ITM~ ~override~
  SAY NAME1 @650372
  SAY NAME2 @650373
  SAY UNIDENTIFIED_DESC @650374
  SAY DESC @650375
COPY ~CtB/items/translate/CBMHSHLD.ITM~ ~override~
  SAY NAME2 @650378
  SAY DESC @650380
COPY ~CtB/items/translate/CBMNAMUL.ITM~ ~override~
  SAY NAME2 @650385
  SAY DESC @650387
COPY ~CtB/items/translate/CBMONP1b.ITM~ ~override~
     ~CtB/items/translate/CBMONP1C.ITM~ ~override~
     ~CtB/items/translate/CBMONP1D.ITM~ ~override~
  SAY NAME1 @650388
  SAY NAME2 @650388
  SAY DESC @650389
COPY ~CtB/items/translate/CBMONP2B.ITM~ ~override~
     ~CtB/items/translate/CBMONP2C.ITM~ ~override~
     ~CtB/items/translate/CBMONP2D.ITM~ ~override~
  SAY NAME1 @650388
  SAY NAME2 @650388
  SAY DESC @650390
COPY ~CtB/items/translate/CBMONP3B.ITM~ ~override~
     ~CtB/items/translate/CBMONP3C.ITM~ ~override~
     ~CtB/items/translate/CBMONP3D.ITM~ ~override~
  SAY NAME1 @650388
  SAY NAME2 @650388
  SAY DESC @650391
COPY ~CtB/items/translate/CBMONP4B.ITM~ ~override~
     ~CtB/items/translate/CBMONP4C.ITM~ ~override~
     ~CtB/items/translate/CBMONP4D.ITM~ ~override~
  SAY NAME1 @650388
  SAY NAME2 @650388
  SAY DESC @650392
COPY ~CtB/items/translate/CBMONP5B.ITM~ ~override~
     ~CtB/items/translate/CBMONP5C.ITM~ ~override~
     ~CtB/items/translate/CBMONP5D.ITM~ ~override~
  SAY NAME1 @650388
  SAY NAME2 @650388
  SAY DESC @650393
COPY ~CtB/items/translate/CBMONP6B.ITM~ ~override~
     ~CtB/items/translate/CBMONP6C.ITM~ ~override~
     ~CtB/items/translate/CBMONP6D.ITM~ ~override~
  SAY NAME1 @650388
  SAY NAME2 @650388
  SAY DESC @650394
COPY ~CtB/items/translate/CBMOONP1.ITM~ ~override~
  SAY NAME2 @650388
  SAY DESC @650389
COPY ~CtB/items/translate/CBMOONP2.ITM~ ~override~
  SAY NAME2 @650388
  SAY DESC @650390
COPY ~CtB/items/translate/CBMOONP3.ITM~ ~override~
  SAY NAME2 @650388
  SAY DESC @650391
COPY ~CtB/items/translate/CBMOONP4.ITM~ ~override~
  SAY NAME2 @650388
  SAY DESC @650392
COPY ~CtB/items/translate/CBMOONP5.ITM~ ~override~
  SAY NAME2 @650388
  SAY DESC @650393
COPY ~CtB/items/translate/CBMOONP6.ITM~ ~override~
  SAY NAME2 @650388
  SAY DESC @650394
COPY ~CtB/items/translate/CBMSCONV.ITM~ ~override~
  SAY NAME2 @650007
  SAY DESC @650395
COPY ~CtB/items/translate/CBMTAROW.ITM~ ~override~
  SAY NAME1 @650396
  SAY NAME2 @650396
  SAY UNIDENTIFIED_DESC @7650396
COPY ~CtB/items/translate/CBMTBOLT.ITM~ ~override~
  SAY NAME1 @650397
  SAY NAME2 @650397
  SAY UNIDENTIFIED_DESC @7650397
COPY ~CtB/items/translate/CBMTBTAX.ITM~ ~override~
  SAY NAME1 @650398
  SAY NAME2 @650398
  SAY UNIDENTIFIED_DESC @7650398
COPY ~CtB/items/translate/CBMTBWCL.ITM~ ~override~
  SAY NAME1 @650399
  SAY NAME2 @650399
  SAY UNIDENTIFIED_DESC @7650399
COPY ~CtB/items/translate/CBMTBWLB.ITM~ ~override~
  SAY NAME1 @650400
  SAY NAME2 @650400
  SAY UNIDENTIFIED_DESC @7650400
COPY ~CtB/items/translate/CBMTBWSB.ITM~ ~override~
  SAY NAME1 @650401
  SAY NAME2 @650401
  SAY UNIDENTIFIED_DESC @7650401
COPY ~CtB/items/translate/CBMTCHAN.ITM~ ~override~
  SAY NAME2 @650402
  SAY DESC @650403
COPY ~CtB/items/translate/CBMTCLUB.ITM~ ~override~
  SAY NAME1 @650404
  SAY NAME2 @650404
  SAY UNIDENTIFIED_DESC @7650404
COPY ~CtB/items/translate/CBMTDAGG.ITM~ ~override~
  SAY NAME1 @650405
  SAY NAME2 @650405
  SAY UNIDENTIFIED_DESC @7650405
COPY ~CtB/items/translate/CBMTDART.ITM~ ~override~
  SAY NAME1 @650406
  SAY NAME2 @650406
  SAY UNIDENTIFIED_DESC @7650406
COPY ~CtB/items/translate/CBMTDGME.ITM~ ~override~
  SAY NAME2 @650407
  SAY DESC @650408
COPY ~CtB/items/translate/CBMTFLAL.ITM~ ~override~
  SAY NAME1 @650409
  SAY NAME2 @650409
  SAY UNIDENTIFIED_DESC @7650409
COPY ~CtB/items/translate/CBMTGTAX.ITM~ ~override~
  SAY NAME1 @650410
  SAY NAME2 @650410
  SAY UNIDENTIFIED_DESC @7650410
COPY ~CtB/items/translate/CBMTGTJU.ITM~ ~override~
  SAY NAME1 @650341
  SAY NAME2 @650411
  SAY UNIDENTIFIED_DESC @650412
  SAY DESC @650413
COPY ~CtB/items/translate/CBMTHALB.ITM~ ~override~
  SAY NAME1 @650414
  SAY NAME2 @650414
  SAY UNIDENTIFIED_DESC @7650414
COPY ~CtB/items/translate/CBMTHAMM.ITM~ ~override~
  SAY NAME1 @650415
  SAY NAME2 @650415
  SAY UNIDENTIFIED_DESC @7650415
COPY ~CtB/items/translate/CBMTHDAX.ITM~ ~override~
  SAY NAME1 @650416
  SAY NAME2 @650416
  SAY UNIDENTIFIED_DESC @7650416
COPY ~CtB/items/translate/CBMTHLCH.ITM~ ~override~
  SAY NAME2 @650417
  SAY DESC @650418
COPY ~CtB/items/translate/CBMTLGGD.ITM~ ~override~
  SAY NAME2 @650419
  SAY DESC @650420
COPY ~CtB/items/translate/CBMTMACE.ITM~ ~override~
  SAY NAME1 @650421
  SAY NAME2 @650421
  SAY UNIDENTIFIED_DESC @7650421
COPY ~CtB/items/translate/CBMTMNST.ITM~ ~override~
  SAY NAME1 @650422
  SAY NAME2 @650422
  SAY UNIDENTIFIED_DESC @7650422
COPY ~CtB/items/translate/CBMTSBDF.ITM~ ~override~
  SAY NAME2 @650423
  SAY DESC @650424
COPY ~CtB/items/translate/CBMTSCIM.ITM~ ~override~
  SAY NAME1 @650425
  SAY NAME2 @650425
  SAY UNIDENTIFIED_DESC @7650425
COPY ~CtB/items/translate/CBMTSLNG.ITM~ ~override~
  SAY NAME1 @650426
  SAY NAME2 @650426
  SAY UNIDENTIFIED_DESC @7650426
COPY ~CtB/items/translate/CBMTSPER.ITM~ ~override~
  SAY NAME1 @650427
  SAY NAME2 @650427
  SAY UNIDENTIFIED_DESC @7650427
COPY ~CtB/items/translate/CBMTSTAF.ITM~ ~override~
  SAY NAME1 @650428
  SAY NAME2 @650428
  SAY UNIDENTIFIED_DESC @7650428
COPY ~CtB/items/translate/CBMTSWBS.ITM~ ~override~
  SAY NAME1 @650429
  SAY NAME2 @650429
  SAY UNIDENTIFIED_DESC @7650429
COPY ~CtB/items/translate/CBMTSWGS.ITM~ ~override~
  SAY NAME1 @650430
  SAY NAME2 @650430
  SAY UNIDENTIFIED_DESC @7650430
COPY ~CtB/items/translate/CBMTSWKT.ITM~ ~override~
  SAY NAME1 @650431
  SAY NAME2 @650431
  SAY UNIDENTIFIED_DESC @7650431
COPY ~CtB/items/translate/CBMTSWLS.ITM~ ~override~
  SAY NAME1 @650432
  SAY NAME2 @650432
  SAY UNIDENTIFIED_DESC @7650432
COPY ~CtB/items/translate/CBMTSWNT.ITM~ ~override~
  SAY NAME1 @650433
  SAY NAME2 @650433
  SAY UNIDENTIFIED_DESC @7650433
COPY ~CtB/items/translate/CBMTSWSS.ITM~ ~override~
  SAY NAME1 @650434
  SAY NAME2 @650434
  SAY UNIDENTIFIED_DESC @7650434
COPY ~CtB/items/translate/CBMTSWWK.ITM~ ~override~
  SAY NAME1 @650435
  SAY NAME2 @650435
  SAY UNIDENTIFIED_DESC @7650435
COPY ~CtB/items/translate/CBMTTHHM.ITM~ ~override~
  SAY NAME1 @650436
  SAY NAME2 @650436
  SAY UNIDENTIFIED_DESC @7650436
COPY ~CtB/items/translate/CBMTTWAX.ITM~ ~override~
  SAY NAME1 @650437
  SAY NAME2 @650437
  SAY UNIDENTIFIED_DESC @7650437
COPY ~CtB/items/translate/CBMTXBHV.ITM~ ~override~
  SAY NAME1 @650438
  SAY NAME2 @650438
  SAY UNIDENTIFIED_DESC @7650438
COPY ~CtB/items/translate/CBMTXBLT.ITM~ ~override~
  SAY NAME1 @650439
  SAY NAME2 @650439
  SAY UNIDENTIFIED_DESC @7650439

COPY ~CtB/items/translate/CBMYSTTP.ITM~ ~override~
  SAY NAME1 @650440
  SAY NAME2 @650440
  SAY UNIDENTIFIED_DESC @650441
  SAY DESC @650441
COPY ~CtB/items/translate/CBMYSTWT.ITM~ ~override~
  SAY NAME1 @650442
  SAY NAME2 @650442
  SAY UNIDENTIFIED_DESC @650443
  SAY DESC @650443
COPY ~CtB/items/translate/CBNRTH01.ITM~ ~override~
  SAY NAME2 @650444
  SAY DESC @650445
COPY ~CtB/items/translate/CBNRTH02.ITM~ ~override~
  SAY NAME2 @650444
  SAY DESC @650445
COPY ~CtB/items/translate/CBNRTHM1.ITM~ ~override~
  SAY NAME1 @650446
  SAY NAME2 @650446
  SAY UNIDENTIFIED_DESC @650447
  SAY DESC @650447
COPY ~CtB/items/translate/CBNRTHM2.ITM~ ~override~
  SAY NAME1 @650448
  SAY NAME2 @650448
  SAY UNIDENTIFIED_DESC @650449
  SAY DESC @650449
COPY ~CtB/items/translate/CBNRTHMM.ITM~ ~override~
  SAY NAME2 @650444
  SAY DESC @650450
COPY ~CtB/items/translate/CBNRTSTF.ITM~ ~override~
  SAY NAME2 @650451
  SAY DESC @650452
COPY ~CtB/items/translate/CBOVRSPR.ITM~ ~override~
  SAY NAME2 @650454
  SAY DESC @650456
COPY ~CtB/items/translate/CBPLAT13.ITM~ ~override~
  SAY NAME2 @650457
  SAY DESC @650458
COPY ~CtB/items/translate/CBPLAYR3.ITM~ ~override~
  SAY NAME1 @650459
  SAY NAME2 @650459
  SAY UNIDENTIFIED_DESC @650460
  SAY DESC @650460
COPY ~CtB/items/translate/CBPOTNLD.ITM~ ~override~
  SAY NAME2 @650461
  SAY DESC @650462
  SAY 0x1fe @650463
COPY ~CtB/items/translate/CBPSBSWD.ITM~ ~override~
  SAY NAME1 @650478
  SAY NAME2 @650478
  SAY UNIDENTIFIED_DESC @650479
  SAY DESC @650480
COPY ~CtB/items/translate/CBQUIV01.ITM~ ~override~
  SAY NAME2 @650482
  SAY DESC @650484
COPY ~CtB/items/translate/CBRINGP3.ITM~ ~override~
  SAY NAME2 @650486
  SAY DESC @650488
COPY ~CtB/items/translate/CBRNGax1.ITM~ ~override~
  SAY NAME1 @650489
  SAY NAME2 @650489
  SAY UNIDENTIFIED_DESC @650490
  SAY DESC @650490
COPY ~CtB/items/translate/CBRNGax2.ITM~ ~override~
  SAY NAME2 @650491
  SAY UNIDENTIFIED_DESC @650490
  SAY DESC @650492
COPY ~CtB/items/translate/CBRNGax3.ITM~ ~override~
  SAY NAME2 @650491
  SAY UNIDENTIFIED_DESC @650490
  SAY DESC @650490
COPY ~CtB/items/translate/CBRNGmtl.ITM~ ~override~
  SAY NAME1 @650493
  SAY NAME2 @650493
  SAY UNIDENTIFIED_DESC @650494
  SAY DESC @650494
COPY ~CtB/items/translate/CBROPE50.ITM~ ~override~
  SAY NAME1 @650097
  SAY NAME2 @650097
  SAY UNIDENTIFIED_DESC @650098
  SAY DESC @650098
COPY ~CtB/items/translate/CBRYBERG.ITM~ ~override~
  SAY UNIDENTIFIED_DESC @650495
COPY ~CtB/items/translate/CBRYCHST.ITM~ ~override~
  SAY NAME1 @650496
  SAY NAME2 @650496
  SAY UNIDENTIFIED_DESC @650497
COPY ~CtB/items/translate/CBRYNN.ITM~ ~override~
  SAY NAME1 @650498
  SAY NAME2 @650498
  SAY UNIDENTIFIED_DESC @650499
  SAY DESC @650499
COPY ~CtB/items/translate/CBSCLTTR.ITM~ ~override~
  SAY UNIDENTIFIED_DESC @650501
COPY ~CtB/items/translate/CBSCPRCH.ITM~ ~override~
  SAY NAME1 @650502
  SAY NAME2 @650502
  SAY UNIDENTIFIED_DESC @650503
COPY ~CtB/items/translate/CBSCRLEV.ITM~ ~override~
COPY ~CtB/items/translate/CBSCVLLM.ITM~ ~override~
  SAY NAME1 @650507
  SAY NAME2 @650507
  SAY UNIDENTIFIED_DESC @650508
COPY ~CtB/items/translate/CBSFINVI.ITM~ ~override~
  SAY UNIDENTIFIED_DESC @650509
COPY ~CtB/items/translate/CBSHDWKY.ITM~ ~override~
  SAY NAME2 @650510
  SAY UNIDENTIFIED_DESC @650511
  SAY DESC @650511
COPY ~CtB/items/translate/CBSHLDWK.ITM~ ~override~
  SAY NAME2 @650512
  SAY DESC @650513
COPY ~CtB/items/translate/CBSNWMDN.ITM~ ~override~
  SAY NAME2 @650514
  SAY DESC @650515
COPY ~CtB/items/translate/CBSPERRG.ITM~ ~override~
  SAY NAME2 @650517
  SAY DESC @650518
COPY ~CtB/items/translate/CBSPKDED.ITM~ ~override~
  SAY NAME2  @267
  SAY DESC   @268
COPY ~CtB/items/translate/CBSSHILT.ITM~ ~override~
  SAY NAME2 @650522
  SAY UNIDENTIFIED_DESC @650296
  SAY DESC @650523
COPY ~CtB/items/translate/CBSSLNG1.ITM~ ~override~
  SAY NAME1 @650524
  SAY NAME2 @650524
  SAY DESC @650525
COPY ~CtB/items/translate/CBSSLNG2.ITM~ ~override~
  SAY NAME1 @650524
  SAY NAME2 @650524
  SAY DESC @650526
COPY ~CtB/items/translate/CBSSLNG3.ITM~ ~override~
  SAY NAME1 @650524
  SAY NAME2 @650524
  SAY DESC @650527
COPY ~CtB/items/translate/CBSSLNG4.ITM~ ~override~
  SAY NAME1 @650524
  SAY NAME2 @650524
  SAY DESC @650528
COPY ~CtB/items/translate/CBSSLNG5.ITM~ ~override~
  SAY NAME1 @650524
  SAY NAME2 @650524
  SAY DESC @650529
COPY ~CtB/items/translate/CBSSLNG6.ITM~ ~override~
  SAY NAME1 @650524
  SAY NAME2 @650524
  SAY DESC @650530
COPY ~CtB/items/translate/CBSSSHRT.ITM~ ~override~
  SAY NAME1 @650531
  SAY NAME2 @650531
  SAY DESC @650532
COPY ~CtB/items/translate/CBSTKS66.ITM~ ~override~
  SAY NAME2 @650534
  SAY UNIDENTIFIED_DESC @650535
  SAY DESC @650536
COPY ~CtB/items/translate/CBSTRARW.ITM~ ~override~
  SAY NAME2 @650538
  SAY DESC @650540
COPY ~CtB/items/translate/CBTENTBD.ITM~ ~override~
  SAY NAME1 @650541
  SAY NAME2 @650541
  SAY UNIDENTIFIED_DESC @650542
  SAY DESC @650542
COPY ~CtB/items/translate/CBTLCLCK.ITM~ ~override~
  SAY NAME2 @650543
  SAY DESC @650544
COPY ~CtB/items/translate/CBTLSWRD.ITM~ ~override~
  SAY DESC @650548
COPY ~CtB/items/translate/CBTSAX01.ITM~ ~override~
  SAY NAME1 @650549
  SAY NAME2 @650549
  SAY UNIDENTIFIED_DESC @7650549
COPY ~CtB/items/translate/CBTSCH01.ITM~ ~override~
  SAY NAME2 @650550
  SAY DESC @650551
COPY ~CtB/items/translate/CBTSDG01.ITM~ ~override~
  SAY NAME1 @650552
  SAY NAME2 @650552
  SAY UNIDENTIFIED_DESC @7650552
COPY ~CtB/items/translate/CBTSFL01.ITM~ ~override~
  SAY NAME1 @650553
  SAY NAME2 @650553
  SAY UNIDENTIFIED_DESC @7650553
COPY ~CtB/items/translate/CBTSHB01.ITM~ ~override~
  SAY NAME1 @650554
  SAY NAME2 @650554
  SAY UNIDENTIFIED_DESC @7650554
COPY ~CtB/items/translate/CBTSPT01.ITM~ ~override~
  SAY NAME2 @650555
  SAY DESC @650556
COPY ~CtB/items/translate/CBTSSD01.ITM~ ~override~
  SAY NAME2 @650557
  SAY DESC @650558
COPY ~CtB/items/translate/CBTSSP01.ITM~ ~override~
  SAY NAME1 @650559
  SAY NAME2 @650559
  SAY UNIDENTIFIED_DESC @7650559
COPY ~CtB/items/translate/CBTSST01.ITM~ ~override~
  SAY NAME2 @650560
  SAY DESC @650561
COPY ~CtB/items/translate/CBTSSW01.ITM~ ~override~
  SAY NAME1 @650562
  SAY NAME2 @650562
  SAY UNIDENTIFIED_DESC @7650562
COPY ~CtB/items/translate/CBTSWH01.ITM~ ~override~
  SAY NAME1 @650563
  SAY NAME2 @650563
  SAY UNIDENTIFIED_DESC @7650563
COPY ~CtB/items/translate/CBTTOOL1.ITM~ ~override~
  SAY NAME1 @650564
  SAY NAME2 @650564
  SAY UNIDENTIFIED_DESC @650565
  SAY DESC @650566
COPY ~CtB/items/translate/CBVALTSS.ITM~ ~override~
  SAY NAME2 @650567
  SAY DESC @650568
COPY ~CtB/items/translate/CBVMPCF1.ITM~ ~override~
     ~CtB/items/translate/CBVMPCF2.ITM~ ~override~
     ~CtB/items/translate/CBVMPCF3.ITM~ ~override~
     ~CtB/items/translate/CBVMPCF4.ITM~ ~override~
  SAY NAME1 @650569
  SAY NAME2 @650569
  SAY UNIDENTIFIED_DESC @650570
COPY ~CtB/items/translate/CBVMPDR1.ITM~ ~override~
     ~CtB/items/translate/CBVMPDR2.ITM~ ~override~
     ~CtB/items/translate/CBVMPDR3.ITM~ ~override~
  SAY NAME1 @650571
  SAY NAME2 @650571
  SAY UNIDENTIFIED_DESC @650572
COPY ~CtB/items/translate/CBWT700.ITM~ ~override~
  SAY NAME2 @650573
  SAY DESC @650574

COPY ~CtB/items/translate/CBWT7a10.ITM~ ~override~
  SAY NAME2  @344
  SAY DESC   @345
COPY ~CtB/items/translate/CBWT7b10.ITM~ ~override~
  SAY NAME2  @346
  SAY DESC   @347
COPY ~CtB/items/translate/CBWT7b20.ITM~ ~override~
  SAY NAME2  @346
COPY ~CtB/items/translate/CBWT7c10.ITM~ ~override~
  SAY NAME2  @356
  SAY DESC   @357
COPY ~CtB/items/translate/CBWT7c20.ITM~ ~override~
  SAY NAME2  @356
COPY ~CtB/items/translate/CBWT7d10.ITM~ ~override~
  SAY NAME2  @350
  SAY DESC   @351
COPY ~CtB/items/translate/CBWT7e10.ITM~ ~override~
  SAY NAME2  @348
  SAY DESC   @349
COPY ~CtB/items/translate/CBWT7f10.ITM~ ~override~
  SAY NAME2  @352
  SAY DESC   @353
COPY ~CtB/items/translate/CBWT7f20.ITM~ ~override~
  SAY NAME2 @352
COPY ~CtB/items/translate/CBWT7g10.ITM~ ~override~
  SAY NAME2  @354
  SAY DESC   @355
COPY ~CtB/items/translate/CBWT7h10.ITM~ ~override~
  SAY NAME2  @358
  SAY DESC   @359
COPY ~CtB/items/translate/CBWT7i10.ITM~ ~override~
  SAY NAME2  @360
  SAY DESC   @361
COPY ~CtB/items/translate/CBWT7i20.ITM~ ~override~
  SAY NAME2  @360
COPY ~CtB/items/translate/CBWT7j10.ITM~ ~override~
  SAY NAME2  @362
  SAY DESC   @363
COPY ~CtB/items/translate/CBWT7k10.ITM~ ~override~
  SAY NAME2  @364
  SAY DESC   @365
COPY ~CtB/items/translate/CBWT7l10.ITM~ ~override~
  SAY NAME2  @366
  SAY DESC   @367

COPY ~CtB/items/translate/CBWTNI1a.ITM~ ~override~
  SAY NAME2 @650601
  SAY DESC @650602
COPY ~CtB/items/translate/CBWTNI1b.ITM~ ~override~
  SAY NAME2 @650601
  SAY DESC @650603
COPY ~CtB/items/translate/CBWTNI1c.ITM~ ~override~
  SAY NAME2 @650601
  SAY DESC @650604
COPY ~CtB/items/translate/CBWTNI1d.ITM~ ~override~
  SAY NAME2 @650601
  SAY DESC @650605
COPY ~CtB/items/translate/CBWTNI2a.ITM~ ~override~
  SAY NAME2 @650606
  SAY DESC @650607
COPY ~CtB/items/translate/CBWTNI3a.ITM~ ~override~
  SAY NAME2 @650608
  SAY DESC @650609
COPY ~CtB/items/translate/CBWTNI4a.ITM~ ~override~
  SAY NAME2 @650610
  SAY DESC @650611
COPY ~CtB/items/translate/CBWTNI5a.ITM~ ~override~
  SAY NAME2 @650612
  SAY DESC @650613
COPY ~CtB/items/translate/CBWTNI6a.ITM~ ~override~
  SAY NAME2 @650614
  SAY DESC @650615
COPY ~CtB/items/translate/CBXTGBaa.ITM~ ~override~
  SAY NAME1 @650616
  SAY NAME2 @650616
  SAY UNIDENTIFIED_DESC @650617
  SAY DESC @650617
COPY ~CtB/items/translate/CBXTGBbb.ITM~ ~override~
  SAY NAME1 @650618
  SAY NAME2 @650618
  SAY UNIDENTIFIED_DESC @650619
  SAY DESC @650619
COPY ~CtB/items/translate/CBXTGCaa.ITM~ ~override~
  SAY NAME2 @650620
  SAY DESC @650621
COPY ~CtB/items/translate/CBXTGCbb.ITM~ ~override~
  SAY NAME2 @650430
  SAY DESC @660204
COPY ~CtB/items/translate/CBXTGCcc.ITM~ ~override~
  SAY NAME2 @650428
  SAY DESC @660202
COPY ~CtB/items/translate/CBXTGCdd.ITM~ ~override~
  SAY NAME2 @660205
  SAY DESC @660206
COPY ~CtB/items/translate/CBXTHSaa.ITM~ ~override~
  SAY NAME2 @650623
  SAY UNIDENTIFIED_DESC @650624
  SAY DESC @650625
COPY ~CtB/items/translate/CBXTHSbb.ITM~ ~override~
  SAY NAME2 @650626
  SAY DESC @650627
COPY ~CtB/items/translate/CBXTHScc.ITM~ ~override~
  SAY DESC @650628
COPY ~CtB/items/translate/CBXTHSdd.ITM~ ~override~
  SAY DESC @650629
COPY ~CtB/items/translate/CBXTJEaa.ITM~ ~override~
  SAY NAME2 @650630
  SAY DESC @650631
COPY ~CtB/items/translate/CBXTJEbb.ITM~ ~override~
  SAY UNIDENTIFIED_DESC @650632
COPY ~CtB/items/translate/CBXTLTaa.ITM~ ~override~
  SAY NAME2 @650633
  SAY DESC @650634
COPY ~CtB/items/translate/CBXTLTbb.ITM~ ~override~
  SAY NAME1 @650635
  SAY NAME2 @650636
  SAY UNIDENTIFIED_DESC @650637
  SAY DESC @650638
COPY ~CtB/items/translate/CBXTLTcc.ITM~ ~override~
  SAY NAME2 @650639
  SAY DESC @650640
COPY ~CtB/items/translate/CBXTRHaa.ITM~ ~override~
  SAY DESC @650641
COPY ~CtB/items/translate/CBXTSHaa.ITM~ ~override~
  SAY DESC @650642
COPY ~CtB/items/translate/CBXTSHbb.ITM~ ~override~
  SAY NAME2 @650643
  SAY DESC @650644
COPY ~CtB/items/translate/CBXTSHcc.ITM~ ~override~
  SAY NAME1 @650645
  SAY NAME2 @650645
  SAY UNIDENTIFIED_DESC @650646
COPY ~CtB/items/translate/CBXTSHdd.ITM~ ~override~
  SAY NAME2 @650647
  SAY DESC @650648
COPY ~CtB/items/translate/CBXTSHee.ITM~ ~override~
  SAY UNIDENTIFIED_DESC @650649
COPY ~CtB/items/translate/SW1H78.ITM~ ~override~
  SAY NAME2 @650658
  SAY DESC @650659
COPY ~CtB/items/translate/SW1H79.ITM~ ~override~
  SAY NAME2 @650660
  SAY DESC @650661
COPY ~CtB/items/translate/CB901CHG.ITM~ ~override~
  SAY NAME1 @660207
  SAY NAME2 @660211
  SAY UNIDENTIFIED_DESC @660213
  SAY DESC @660217
COPY ~CtB/items/translate/CB901CMS.ITM~ ~override~
  SAY NAME1 @660207
  SAY NAME2 @660209
  SAY UNIDENTIFIED_DESC @660213
  SAY DESC @660215
COPY ~CtB/items/translate/CB901ELD.ITM~ ~override~
  SAY NAME1 @660207
  SAY NAME2 @660210
  SAY UNIDENTIFIED_DESC @660213
  SAY DESC @660216
COPY ~CtB/items/translate/CB901PCH.ITM~ ~override~
  SAY NAME1 @660207
  SAY NAME2 @660208
  SAY UNIDENTIFIED_DESC @660213
  SAY DESC @660214
COPY ~CtB/items/translate/CB901WRM.ITM~ ~override~
  SAY NAME1 @660207
  SAY NAME2 @660212
  SAY UNIDENTIFIED_DESC @660213
  SAY DESC @660218
COPY ~CtB/items/translate/CBHOLLY1.ITM~ ~override~
  SAY NAME2 @660219
  SAY DESC @660220
COPY ~CtB/items/translate/CBHOLLY2.ITM~ ~override~
  SAY NAME2 @660219
  SAY DESC @660220
  SAY 0x1ce @650047
  SAY 0x1fe @650048
  SAY 0x22e @650049
  SAY 0x25e @650050
  SAY 0x28e @650051
COPY ~CtB/items/translate/CBCHAUNT.ITM~ ~override~
  SAY NAME2 @661011
  SAY DESC @661012
COPY ~CtB/items/translate/CBCYRICx.ITM~ ~override~
  SAY NAME2 @661013
  SAY DESC @661014
COPY ~CtB/items/translate/CBILMATA.ITM~ ~override~
  SAY NAME2 @661015
  SAY DESC @661016
COPY ~CtB/items/translate/CBMIELIK.ITM~ ~override~
  SAY NAME2 @661017
  SAY DESC @661018
COPY ~CtB/items/translate/CBMYSTRA.ITM~ ~override~
  SAY NAME2 @661019
  SAY DESC @661020
COPY ~CtB/items/translate/CBTEMPUS.ITM~ ~override~
  SAY NAME2 @661021
  SAY DESC @661022
COPY ~CtB/items/translate/CBWAUKEE.ITM~ ~override~
  SAY NAME2 @661023
  SAY DESC @661024
COPY ~CtB/items/translate/CBPDofCM.ITM~ ~override~
  SAY NAME2 @661026
  SAY DESC @661027

//***********************************************************
//  Stores
//***********************************************************
PRINT ~Patching original BG2 stores...~

COPY_EXISTING ~SHOP08.STO~ ~override/SHOP08.STO~
 ADD_STORE_ITEM "CBSCPRCH" #1 #0 #0 ~IDENTIFIED~ #5
 ADD_STORE_ITEM "CBSCVLLM" #1 #0 #0 ~IDENTIFIED~ #5


PRINT ~Installing new stores...~

COPY ~CtB/stores/CB363501.STO~ ~override~ SAY STORE_NAME @134
 SAY 0xa4 @143
 SAY 0xb8 @144
 SAY 0xcc @145

COPY ~CtB/stores/CB3647HB.STO~ ~override~ SAY STORE_NAME @135
COPY ~CtB/stores/CB3651IN.STO~ ~override~ SAY STORE_NAME @136
COPY ~CtB/stores/CB3651IO.STO~ ~override~ SAY STORE_NAME @136
COPY ~CtB/stores/CBCWUMST.STO~ ~override~
COPY ~CtB/stores/CBHL3631.STO~ ~override~
COPY ~CtB/stores/CBHL3634.STO~ ~override~
COPY ~CtB/stores/CBHLD0W1.STO~ ~override~ SAY STORE_NAME @137
COPY ~CtB/stores/CBHLVLNT.STO~ ~override~ SAY STORE_NAME @138
COPY ~CtB/stores/CBMALR1a.STO~ ~override~
COPY ~CtB/stores/CBMALR1b.STO~ ~override~
COPY ~CtB/stores/CBMYSBAG.STO~ ~override~
COPY ~CtB/stores/CBMYSSCR.STO~ ~override~
COPY ~CtB/stores/CBMYSTP1.STO~ ~override~ SAY STORE_NAME @139
COPY ~CtB/stores/CBRNCMAN.STO~ ~override~ SAY STORE_NAME @140
COPY ~CtB/stores/CBTENTBD.STO~ ~override~ SAY STORE_NAME @141
COPY ~CtB/stores/CBWT700.STO~  ~override~ SAY STORE_NAME @142


//***********************************************************
//  Areas
//***********************************************************
PRINT ~Patching original BG2 areas...~


COPY_EXISTING ~AR1600.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%actors_num%"; cnt=cnt+1 ) BEGIN  //actors loop
   READ_ASCII ("%actors_offset%"+0x110*cnt)       "actor_name" (13)
   PATCH_IF (("%actor_name%" STRING_COMPARE_CASE "WyrbrinHorton")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN             //adding new actor  *******************************
   SET offset = ("%actors_offset%"+0x110*"%actors_num%")
   INSERT_BYTES offset 0x110
   WRITE_ASCII offset ~WyrbrinHorton~
   WRITE_SHORT (offset+0x20) 3165         //X
   WRITE_SHORT (offset+0x22) 1590         //Y
   WRITE_SHORT (offset+0x24) 3165         //destination X
   WRITE_SHORT (offset+0x26) 1590         //destination Y
   WRITE_LONG  (offset+0x28) 1            //visible
   WRITE_BYTE  (offset+0x30) 0x13         //unknown
   WRITE_BYTE  (offset+0x31) 0x63         //unknown
   WRITE_LONG  (offset+0x34) 13           //orientation
   WRITE_LONG  (offset+0x38) 0xffffffff   //unknown
   WRITE_LONG  (offset+0x40) 0xfffc003f   //schedule
   WRITE_ASCII (offset+0x80) ~CBXTTHEF~   //creature
   SET "actors_num"="%actors_num%"+1
   WRITE_SHORT 0x58  "%actors_num%"
 END

 SET "info_ext"=0x110*info_1
 PATCH_IF ("%infotrig_offset%">="%actors_offset%") BEGIN
   "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
   WRITE_LONG  0x5c "%infotrig_offset%"
 END
 PATCH_IF ("%spawns_offset%">="%actors_offset%") BEGIN
   "spawns_offset"="%spawns_offset%"+"%info_ext%"
   WRITE_LONG  0x60  "%spawns_offset%"
 END
 PATCH_IF ("%entrances_offset%">="%actors_offset%") BEGIN
   "entrances_offset"="%entrances_offset%"+"%info_ext%"
   WRITE_LONG  0x68  "%entrances_offset%"
 END
 PATCH_IF ("%cont_offset%">="%actors_offset%") BEGIN
   "cont_offset"="%cont_offset%"+"%info_ext%"
   WRITE_LONG  0x70  "%cont_offset%"
 END
 PATCH_IF ("%items_offset%">="%actors_offset%") BEGIN
   "items_offset"="%items_offset%"+"%info_ext%"
   WRITE_LONG  0x78  "%items_offset%"
 END
 PATCH_IF ("%vert_offset%">="%actors_offset%") BEGIN
   "vert_offset"="%vert_offset%"+"%info_ext%"
   WRITE_LONG  0x7c  "%vert_offset%"
 END
 PATCH_IF ("%amb_offset%">="%actors_offset%") BEGIN
   "amb_offset"="%amb_offset%"+"%info_ext%"
   WRITE_LONG  0x84  "%amb_offset%"
 END
 PATCH_IF ("%vars_offset%">="%actors_offset%") BEGIN
   "vars_offset"="%vars_offset%"+"%info_ext%"
   WRITE_LONG  0x88  "%vars_offset%"
 END
 PATCH_IF ("%expbmp_offset%">="%actors_offset%") BEGIN
   "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
   WRITE_LONG  0xa0  "%expbmp_offset%"
 END
 PATCH_IF ("%doors_offset%">="%actors_offset%") BEGIN
   "doors_offset"="%doors_offset%"+"%info_ext%"
   WRITE_LONG  0xa8  "%doors_offset%"
 END
 PATCH_IF ("%anim_offset%">="%actors_offset%") BEGIN
   "anim_offset"="%anim_offset%"+"%info_ext%"
   WRITE_LONG  0xb0  "%anim_offset%"
 END
 PATCH_IF ("%tiled_offset%">="%actors_offset%") BEGIN
   "tiled_offset"="%tiled_offset%"+"%info_ext%"
   WRITE_LONG  0xb8  "%tiled_offset%"
 END
 PATCH_IF ("%songs_offset%">="%actors_offset%") BEGIN
   "songs_offset"="%songs_offset%"+"%info_ext%"
   WRITE_LONG  0xbc  "%songs_offset%"
 END
 PATCH_IF ("%rest_spawns_offset%">="%actors_offset%") BEGIN
   "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
   WRITE_LONG  0xc0  "%rest_spawns_offset%"
 END
 PATCH_IF ("%automap_offset%">="%actors_offset%") BEGIN
   "automap_offset"="%automap_offset%"+"%info_ext%"
   WRITE_LONG  0xc4  "%automap_offset%"
 END
 BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR1600.are~


COPY_EXISTING ~AR2008.ARE~ ~override~      //for BDash?????
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"

 FOR( cnt=0; cnt<"%infotrig_num%"; cnt=cnt+1 ) BEGIN  //info/triggers loop
   READ_ASCII ("%infotrig_offset%"+0xc4*cnt)       "info_name"
   PATCH_IF ( ("%info_name%" STRING_COMPARE_CASE "Tran2000")=0 OR
              ("%info_name%" STRING_COMPARE_CASE "Tran2000b")=0 ) BEGIN
     READ_LONG  ("%infotrig_offset%"+0xc4*cnt+0x60)  flags
     WRITE_LONG ("%infotrig_offset%"+0xc4*cnt+0x60)  (flags BAND 0xfffffdff) //remove "NPC Can't pass" flag
   END
 END
 BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR2008.are~


COPY_EXISTING ~AR2500.ARE~ ~override~      //for BDash?????
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"

 FOR( cnt=0; cnt<"%actors_num%"; cnt=cnt+1 ) BEGIN  //actors loop
   READ_SHORT ("%actors_offset%"+0x110*cnt+0x20)  X
   READ_SHORT ("%actors_offset%"+0x110*cnt+0x22)  Y
   PATCH_IF ( "%X%"=1061 AND "%Y%"=1962 ) BEGIN
     WRITE_SHORT ("%actors_offset%"+0x110*cnt+0x20)  844
     WRITE_SHORT ("%actors_offset%"+0x110*cnt+0x22)  1908
     WRITE_SHORT ("%actors_offset%"+0x110*cnt+0x24)  844
     WRITE_SHORT ("%actors_offset%"+0x110*cnt+0x26)  1908
   END
 END
 BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR2500.are~

//*******************************************************************************************************
//*******************************************************************************************************
COPY_EXISTING ~AR2600.ARE~  ~override~ //********* LOOOOOOOOOOOOOONG STORY ******************************
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%actors_num%"; cnt=cnt+1 ) BEGIN  //actors loop
   READ_ASCII ("%actors_offset%"+0x110*cnt)       "actor_name" (5)
   PATCH_IF (("%actor_name%" STRING_COMPARE_CASE "Paddy")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN //Here we go.........
 //adding 9 new actors  *******************************
   SET offset = ("%actors_offset%"+0x110*"%actors_num%")
   INSERT_BYTES offset 0x110
   WRITE_ASCII offset ~Lawantha~
   WRITE_SHORT (offset+0x20) 4415         //X
   WRITE_SHORT (offset+0x22) 2474         //Y
   WRITE_SHORT (offset+0x24) 4415         //destination X
   WRITE_SHORT (offset+0x26) 2474         //destination Y
   WRITE_LONG  (offset+0x28) 1            //visible
   WRITE_LONG  (offset+0x34) 0            //orientation
   WRITE_LONG  (offset+0x38) 0xffffffff   //unknown
   WRITE_LONG  (offset+0x40) 0xffffffff   //schedule
   WRITE_ASCII (offset+0x80) ~CBLSLNDA~   //creature
   INSERT_BYTES offset 0x110
   WRITE_ASCII offset ~Marilyn~
   WRITE_SHORT (offset+0x20) 4201         //X
   WRITE_SHORT (offset+0x22) 2414         //Y
   WRITE_SHORT (offset+0x24) 4201         //destination X
   WRITE_SHORT (offset+0x26) 2414         //destination Y
   WRITE_LONG  (offset+0x28) 1            //visible
   WRITE_LONG  (offset+0x34) 2            //orientation
   WRITE_LONG  (offset+0x38) 0xffffffff   //unknown
   WRITE_LONG  (offset+0x40) 0xffffffff   //schedule
   WRITE_ASCII (offset+0x80) ~CBHREDWN~   //creature
   INSERT_BYTES offset 0x110
   WRITE_ASCII offset ~Manfred~
   WRITE_SHORT (offset+0x20) 4358         //X
   WRITE_SHORT (offset+0x22) 2276         //Y
   WRITE_SHORT (offset+0x24) 4358         //destination X
   WRITE_SHORT (offset+0x26) 2276         //destination Y
   WRITE_LONG  (offset+0x28) 1            //visible
   WRITE_LONG  (offset+0x34) 14           //orientation
   WRITE_LONG  (offset+0x38) 0xffffffff   //unknown
   WRITE_LONG  (offset+0x40) 0xffffffff   //schedule
   WRITE_ASCII (offset+0x80) ~CBMANARB~   //creature
   INSERT_BYTES offset 0x110
   WRITE_ASCII offset ~Arkaneus~
   WRITE_SHORT (offset+0x20) 4401         //X
   WRITE_SHORT (offset+0x22) 2338         //Y
   WRITE_SHORT (offset+0x24) 4401         //destination X
   WRITE_SHORT (offset+0x26) 2338         //destination Y
   WRITE_LONG  (offset+0x28) 1            //visible
   WRITE_LONG  (offset+0x34) 3            //orientation
   WRITE_LONG  (offset+0x38) 0xffffffff   //unknown
   WRITE_LONG  (offset+0x40) 0xffffffff   //schedule
   WRITE_ASCII (offset+0x80) ~CBARKSLV~   //creature
   INSERT_BYTES offset 0x110
   WRITE_ASCII offset ~Tardeth~
   WRITE_SHORT (offset+0x20) 4254         //X
   WRITE_SHORT (offset+0x22) 2450         //Y
   WRITE_SHORT (offset+0x24) 4254         //destination X
   WRITE_SHORT (offset+0x26) 2450         //destination Y
   WRITE_LONG  (offset+0x28) 1            //visible
   WRITE_LONG  (offset+0x34) 2            //orientation
   WRITE_LONG  (offset+0x38) 0xffffffff   //unknown
   WRITE_LONG  (offset+0x40) 0xffffffff   //schedule
   WRITE_ASCII (offset+0x80) ~CBTARDTH~   //creature
   INSERT_BYTES offset 0x110
   WRITE_ASCII offset ~Silvanus~
   WRITE_SHORT (offset+0x20) 4472         //X
   WRITE_SHORT (offset+0x22) 2657         //Y
   WRITE_SHORT (offset+0x24) 4472         //destination X
   WRITE_SHORT (offset+0x26) 2657         //destination Y
   WRITE_LONG  (offset+0x28) 1            //visible
   WRITE_LONG  (offset+0x34) 2            //orientation
   WRITE_LONG  (offset+0x38) 0xffffffff   //unknown
   WRITE_LONG  (offset+0x40) 0xffffffff   //schedule
   WRITE_ASCII (offset+0x80) ~CBMONDRP~   //creature
   INSERT_BYTES offset 0x110
   WRITE_ASCII offset ~Sir John Johns~
   WRITE_SHORT (offset+0x20) 4173         //X
   WRITE_SHORT (offset+0x22) 2651         //Y
   WRITE_SHORT (offset+0x24) 4173         //destination X
   WRITE_SHORT (offset+0x26) 2651         //destination Y
   WRITE_LONG  (offset+0x28) 1            //visible
   WRITE_LONG  (offset+0x34) 12           //orientation
   WRITE_LONG  (offset+0x38) 0xffffffff   //unknown
   WRITE_LONG  (offset+0x40) 0xffffffff   //schedule
   WRITE_ASCII (offset+0x80) ~CBSMHRSE~   //creature
   INSERT_BYTES offset 0x110
   WRITE_ASCII offset ~Target~
   WRITE_SHORT (offset+0x20) 4784         //X
   WRITE_SHORT (offset+0x22) 2664         //Y
   WRITE_SHORT (offset+0x24) 4784         //destination X
   WRITE_SHORT (offset+0x26) 2664         //destination Y
   WRITE_LONG  (offset+0x28) 1            //visible
   WRITE_LONG  (offset+0x34) 0            //orientation
   WRITE_LONG  (offset+0x38) 0xffffffff   //unknown
   WRITE_LONG  (offset+0x40) 0xffffffff   //schedule
   WRITE_ASCII (offset+0x80) ~CBSMTRGT~   //creature
   INSERT_BYTES offset 0x110
   WRITE_ASCII offset ~Paddy~
   WRITE_SHORT (offset+0x20) 3317         //X
   WRITE_SHORT (offset+0x22) 631          //Y
   WRITE_SHORT (offset+0x24) 3317         //destination X
   WRITE_SHORT (offset+0x26) 631          //destination Y
   WRITE_LONG  (offset+0x28) 1            //visible
   WRITE_LONG  (offset+0x34) 5            //orientation
   WRITE_LONG  (offset+0x38) 0xffffffff   //unknown
   WRITE_LONG  (offset+0x40) 0xff3fff80   //schedule
   WRITE_ASCII (offset+0x80) ~CBSTTFLW~   //creature
   SET "actors_num"="%actors_num%"+9
   WRITE_SHORT 0x58  "%actors_num%"

   SET "info_ext"=0x110*9
   PATCH_IF ("%infotrig_offset%">="%actors_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c "%infotrig_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%actors_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%actors_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%actors_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%actors_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%actors_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%actors_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%actors_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%actors_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%actors_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%actors_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%actors_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%actors_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%actors_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%actors_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END
   
   FOR( cnt=0; cnt<"%infotrig_num%"; cnt=cnt+1 ) BEGIN  //info/triggers loop
     READ_ASCII ("%infotrig_offset%"+0xc4*cnt)       "info_name"
     PATCH_IF ( ("%info_name%" STRING_COMPARE_CASE "Tran2602")=0 ) BEGIN
       WRITE_ASCII ("%infotrig_offset%"+0xc4*cnt)      "Tran3530"  //changing trigger's name
       WRITE_SHORT ("%infotrig_offset%"+0xc4*cnt+0x20) 1           //info trigger instead of travel
       WRITE_ASCII ("%infotrig_offset%"+0xc4*cnt+0x38) "" #8       //clear destination area
       WRITE_ASCII ("%infotrig_offset%"+0xc4*cnt+0x40) "" #8       //clear destination area's entrance name
       WRITE_LONG  ("%infotrig_offset%"+0xc4*cnt+0x60) 0x00000804  //party required/connected to door
       WRITE_ASCII ("%infotrig_offset%"+0xc4*cnt+0x7c) "CBTR3530"  //script name
       //patching vertices for this trigger region
       READ_LONG  ("%infotrig_offset%"+0xc4*cnt+0x2c) vert_idx
       WRITE_SHORT ("%vert_offset%"+4*(0+vert_idx))   4479
       WRITE_SHORT ("%vert_offset%"+4*(0+vert_idx)+2) 2238
       WRITE_SHORT ("%vert_offset%"+4*(1+vert_idx))   4498
       WRITE_SHORT ("%vert_offset%"+4*(1+vert_idx)+2) 2183
       WRITE_SHORT ("%vert_offset%"+4*(2+vert_idx))   4545
       WRITE_SHORT ("%vert_offset%"+4*(2+vert_idx)+2) 2198
       WRITE_SHORT ("%vert_offset%"+4*(3+vert_idx))   4526
       WRITE_SHORT ("%vert_offset%"+4*(3+vert_idx)+2) 2258
       WRITE_SHORT ("%vert_offset%"+4*(4+vert_idx))   4499
       WRITE_SHORT ("%vert_offset%"+4*(4+vert_idx)+2) 2256
     END
   END

//adding 6 new Proximity triggers  ***************************
   SET offset = ("%infotrig_offset%"+0xc4*"%infotrig_num%")
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~PaddyPT1~
   WRITE_SHORT (offset+0x20) 0            //proximity trigger
   WRITE_SHORT (offset+0x22) 3295         //bounding box
   WRITE_SHORT (offset+0x24) 618          //bounding box
   WRITE_SHORT (offset+0x26) 3310         //bounding box
   WRITE_SHORT (offset+0x28) 634          //bounding box
   WRITE_SHORT (offset+0x2a) 4            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%" //first vertex index
   WRITE_SHORT (offset+0x70) 3289         //Trap location X
   WRITE_SHORT (offset+0x72) 627          //Trap location Y
   SET offset = offset+0xc4
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~PaddyPT2~
   WRITE_SHORT (offset+0x20) 0            //proximity trigger
   WRITE_SHORT (offset+0x22) 2607         //bounding box
   WRITE_SHORT (offset+0x24) 1507         //bounding box
   WRITE_SHORT (offset+0x26) 2623         //bounding box
   WRITE_SHORT (offset+0x28) 1523         //bounding box
   WRITE_SHORT (offset+0x2a) 4            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%"+4 //first vertex index
   WRITE_SHORT (offset+0x70) 2615         //Trap location X
   WRITE_SHORT (offset+0x72) 1515          //Trap location Y
   SET offset = offset+0xc4
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~PaddyPT3~
   WRITE_SHORT (offset+0x20) 0            //proximity trigger
   WRITE_SHORT (offset+0x22) 2663         //bounding box
   WRITE_SHORT (offset+0x24) 2245         //bounding box
   WRITE_SHORT (offset+0x26) 2678         //bounding box
   WRITE_SHORT (offset+0x28) 2261         //bounding box
   WRITE_SHORT (offset+0x2a) 4            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%"+8 //first vertex index
   WRITE_SHORT (offset+0x70) 2670         //Trap location X
   WRITE_SHORT (offset+0x72) 2253         //Trap location Y
   SET offset = offset+0xc4
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~PaddyPT4~
   WRITE_SHORT (offset+0x20) 0            //proximity trigger
   WRITE_SHORT (offset+0x22) 3134         //bounding box
   WRITE_SHORT (offset+0x24) 2949         //bounding box
   WRITE_SHORT (offset+0x26) 3149         //bounding box
   WRITE_SHORT (offset+0x28) 2966         //bounding box
   WRITE_SHORT (offset+0x2a) 4            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%"+12 //first vertex index
   WRITE_SHORT (offset+0x70) 3141         //Trap location X
   WRITE_SHORT (offset+0x72) 2957         //Trap location Y
   SET offset = offset+0xc4
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~PaddyPT5~
   WRITE_SHORT (offset+0x20) 0            //proximity trigger
   WRITE_SHORT (offset+0x22) 3948         //bounding box
   WRITE_SHORT (offset+0x24) 2980         //bounding box
   WRITE_SHORT (offset+0x26) 3963         //bounding box
   WRITE_SHORT (offset+0x28) 2995         //bounding box
   WRITE_SHORT (offset+0x2a) 4            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%"+16 //first vertex index
   WRITE_SHORT (offset+0x70) 3955         //Trap location X
   WRITE_SHORT (offset+0x72) 2987         //Trap location Y
   SET offset = offset+0xc4
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~PaddyPT6~
   WRITE_SHORT (offset+0x20) 0            //proximity trigger
   WRITE_SHORT (offset+0x22) 4190         //bounding box
   WRITE_SHORT (offset+0x24) 2334         //bounding box
   WRITE_SHORT (offset+0x26) 4208         //bounding box
   WRITE_SHORT (offset+0x28) 2352         //bounding box
   WRITE_SHORT (offset+0x2a) 4            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%"+20 //first vertex index
   WRITE_SHORT (offset+0x70) 4199         //Trap location X
   WRITE_SHORT (offset+0x72) 2343         //Trap location Y
   SET "infotrig_num"="%infotrig_num%"+6
   WRITE_SHORT 0x5a  "%infotrig_num%"

   SET "info_ext"=0xc4*6
   PATCH_IF ("%actors_offset%">="%infotrig_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%infotrig_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%infotrig_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%infotrig_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%infotrig_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%infotrig_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%infotrig_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%infotrig_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%infotrig_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%infotrig_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%infotrig_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%infotrig_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%infotrig_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%infotrig_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%infotrig_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END
   
  //adding 24 new vertices for triggers
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*4)
   WRITE_SHORT  offset      3299
   WRITE_SHORT  (offset+2)  618
   WRITE_SHORT  (offset+4)  3295
   WRITE_SHORT  (offset+6)  634
   WRITE_SHORT  (offset+8)  3310
   WRITE_SHORT  (offset+10) 624
   WRITE_SHORT  (offset+12) 3299
   WRITE_SHORT  (offset+14) 618
   SET offset = offset + 4*4
   INSERT_BYTES offset (0x04*4)
   WRITE_SHORT  offset      2613
   WRITE_SHORT  (offset+2)  1507
   WRITE_SHORT  (offset+4)  2607
   WRITE_SHORT  (offset+6)  1523
   WRITE_SHORT  (offset+8)  2623
   WRITE_SHORT  (offset+10) 1517
   WRITE_SHORT  (offset+12) 2613
   WRITE_SHORT  (offset+14) 1507
   SET offset = offset + 4*4
   INSERT_BYTES offset (0x04*4)
   WRITE_SHORT  offset      2664
   WRITE_SHORT  (offset+2)  2245
   WRITE_SHORT  (offset+4)  2663
   WRITE_SHORT  (offset+6)  2261
   WRITE_SHORT  (offset+8)  2678
   WRITE_SHORT  (offset+10) 2253
   WRITE_SHORT  (offset+12) 2664
   WRITE_SHORT  (offset+14) 2245
   SET offset = offset + 4*4
   INSERT_BYTES offset (0x04*4)
   WRITE_SHORT  offset      3137
   WRITE_SHORT  (offset+2)  2949
   WRITE_SHORT  (offset+4)  3134
   WRITE_SHORT  (offset+6)  2966
   WRITE_SHORT  (offset+8)  3149
   WRITE_SHORT  (offset+10) 2958
   WRITE_SHORT  (offset+12) 3137
   WRITE_SHORT  (offset+14) 2949
   SET offset = offset + 4*4
   INSERT_BYTES offset (0x04*4)
   WRITE_SHORT  offset      3953
   WRITE_SHORT  (offset+2)  2980
   WRITE_SHORT  (offset+4)  3948
   WRITE_SHORT  (offset+6)  2995
   WRITE_SHORT  (offset+8)  3963
   WRITE_SHORT  (offset+10) 2989
   WRITE_SHORT  (offset+12) 3953
   WRITE_SHORT  (offset+14) 2980
   SET offset = offset + 4*4
   INSERT_BYTES offset (0x04*4)
   WRITE_SHORT  offset      4196
   WRITE_SHORT  (offset+2)  2334
   WRITE_SHORT  (offset+4)  4190
   WRITE_SHORT  (offset+6)  2352
   WRITE_SHORT  (offset+8)  4208
   WRITE_SHORT  (offset+10) 2349
   WRITE_SHORT  (offset+12) 4196
   WRITE_SHORT  (offset+14) 2334
   SET "vert_num"="%vert_num%"+24
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*24
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END
  
   FOR( cnt=0; cnt<"%doors_num%"; cnt=cnt+1 ) BEGIN  //doors loop
     READ_ASCII ("%doors_offset%"+0xc8*cnt)    "door_name"
     PATCH_IF (("%door_name%" STRING_COMPARE_CASE "Door02")=0) BEGIN
       WRITE_LONG  ("%doors_offset%"+0xc8*cnt+0x28) 0x00000402 //locked, use key(?)
       WRITE_LONG  ("%doors_offset%"+0xc8*cnt+0x8c) 100        //Lock dificulty
       WRITE_ASCII ("%doors_offset%"+0xc8*cnt+0x9c) "Tran3530"
     END
   END

   FOR( cnt=0; cnt<"%entrances_num%"; cnt=cnt+1 ) BEGIN  //entrances loop
     READ_ASCII ("%entrances_offset%"+0x68*cnt)    "entry_name" (8)
     PATCH_IF (("%entry_name%" STRING_COMPARE_CASE "Exit2602")=0) BEGIN
       WRITE_ASCII ("%entrances_offset%"+0x68*cnt) "Exit3530"    //changing entrance name
     END
   END

   FOR( cnt=0; cnt<"%automap_num%"; cnt=cnt+1 ) BEGIN  //automap notes loop
     READ_SHORT ("%automap_offset%"+0x34*cnt)    X
     READ_SHORT ("%automap_offset%"+0x34*cnt+2)  Y
     PATCH_IF ("%X%"=4489 AND "%Y%"=2322) BEGIN
       SAY ("%automap_offset%"+0x34*cnt+4) @650692     //"Cult of Dragon Stronghold" string
     END
   END

   FOR( cnt=0; cnt<"%spawns_num%"; cnt=cnt+1 ) BEGIN  //spawns loop
     READ_ASCII ("%spawns_offset%"+0xc8*cnt)    "spawn_name"  (13)
     PATCH_IF (("%spawn_name%" STRING_COMPARE_CASE "Spawn Point 1")=0 OR
               ("%spawn_name%" STRING_COMPARE_CASE "Spawn Point 7")=0) BEGIN
       DELETE_BYTES ("%spawns_offset%"+0xc8*cnt) 0xc8
       SET "spawns_num" = "%spawns_num%" - 1
       cnt = cnt - 1
     END
   END
   WRITE_LONG  0x64  "%spawns_num%"

   SET "info_ext"=0xc8*2
   PATCH_IF ("%actors_offset%">="%spawns_offset%") BEGIN
     "actors_offset"="%actors_offset%"-"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%vert_offset%">="%spawns_offset%") BEGIN
     "vert_offset"="%vert_offset%"-"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%spawns_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"-"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%spawns_offset%") BEGIN
     "cont_offset"="%cont_offset%"-"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%spawns_offset%") BEGIN
     "items_offset"="%items_offset%"-"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%spawns_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"-"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%spawns_offset%") BEGIN
     "amb_offset"="%amb_offset%"-"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%spawns_offset%") BEGIN
     "vars_offset"="%vars_offset%"-"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%spawns_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"-"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%spawns_offset%") BEGIN
     "doors_offset"="%doors_offset%"-"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%spawns_offset%") BEGIN
     "anim_offset"="%anim_offset%"-"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%spawns_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"-"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%spawns_offset%") BEGIN
     "songs_offset"="%songs_offset%"-"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%spawns_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"-"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%spawns_offset%") BEGIN
     "automap_offset"="%automap_offset%"-"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main IF info_1
BUT_ONLY_IF_IT_CHANGES //******************************************************************  ~AR2600.are~
//*******************************************************************************************************
//*******************************************************************************************************


COPY_EXISTING ~AR3005.ARE~  ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_LONG  0xc0  "rest_spawns_offset"

 FOR( cnt=0; cnt<"%actors_num%"; cnt=cnt+1 ) BEGIN  //actors loop
   READ_ASCII ("%actors_offset%"+0x110*cnt)       "actor_name"
   PATCH_IF (("%actor_name%" STRING_COMPARE_CASE "Tiefling")=0) BEGIN
     WRITE_ASCII  ("%actors_offset%"+0x110*cnt)     "Chimera" #32
     WRITE_BYTE  ("%actors_offset%"+0x110*cnt+0x30) 0xd0 //2 unknowns
     WRITE_BYTE  ("%actors_offset%"+0x110*cnt+0x31) 0xe0 //??
     WRITE_ASCII ("%actors_offset%"+0x110*cnt+0x80) ~CBCHIMRA~
   END
 END
 WRITE_ASCII "%rest_spawns_offset%"           ~Chimera~  #32
 WRITE_ASCII ("%rest_spawns_offset%"+0x48)    ~CBCHIMRA~ #8
 WRITE_ASCII ("%rest_spawns_offset%"+0x48+8)  ~CBCHIMRA~ #8
 WRITE_ASCII ("%rest_spawns_offset%"+0x48+16) ~CBCHIMRA~ #8
BUT_ONLY_IF_IT_CHANGES //**************************************************************  ~AR3005.are~


COPY_EXISTING ~AR3021.are~           ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET "first_item"=0
 SET "items"=0
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //containers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name" (11)
   PATCH_IF ("%items%">0) BEGIN
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "first_item_next"        //shift all next containers' items
     WRITE_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "%first_item_next%"+1
   END
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "Container 7")=0) BEGIN
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "first_item"
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x44)  "items"
     WRITE_LONG ("%cont_offset%"+0xc0*cnt+0x44) "%items%"+1  //we'll add 2 more items there
   END
 END

 PATCH_IF ("%items%">0 ) BEGIN
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET offset = ("%items_offset%"+0x14*"%first_item%")  //adding 1 item the container  *******************************
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBEMMETL~

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END
 END
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR3021.are~


COPY_EXISTING ~AR5004.are~           ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET "first_item"=0
 SET "items"=0
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //containers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF ("%items%">0) BEGIN
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "first_item_next"        //shift all next containers' items
     WRITE_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "%first_item_next%"+1
   END
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "Shelf1")=0) BEGIN
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "first_item"
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x44)  "items"
     WRITE_LONG ("%cont_offset%"+0xc0*cnt+0x44) "%items%"+1  //we'll add 2 more items there
   END
 END

 PATCH_IF ("%items%">0 ) BEGIN
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET offset = ("%items_offset%"+0x14*"%first_item%")  //adding 1 item the container  *******************************
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBSPKDED~

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END
 END
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR5004.are~


COPY_EXISTING ~AR5505.are~           ~override~
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"

   FOR( cnt=0; cnt<"%infotrig_num%"; cnt=cnt+1 ) BEGIN  //info/triggers loop
     READ_ASCII ("%infotrig_offset%"+0xc4*cnt)       "info_name"
     PATCH_IF ( ("%info_name%" STRING_COMPARE_CASE "ThroneR")=0 ) BEGIN
       WRITE_SHORT ("%infotrig_offset%"+0xc4*cnt+0x22) 1385        //info trigger instead of travel
       WRITE_SHORT ("%infotrig_offset%"+0xc4*cnt+0x24) 679         //info trigger instead of travel
       WRITE_SHORT ("%infotrig_offset%"+0xc4*cnt+0x26) 1417        //info trigger instead of travel
       WRITE_SHORT ("%infotrig_offset%"+0xc4*cnt+0x28) 703         //info trigger instead of travel
       //patching vertices for this trigger region
       READ_LONG  ("%infotrig_offset%"+0xc4*cnt+0x2c) vert_idx
       WRITE_SHORT ("%vert_offset%"+4*(0+vert_idx))   1385
       WRITE_SHORT ("%vert_offset%"+4*(0+vert_idx)+2) 703
       WRITE_SHORT ("%vert_offset%"+4*(1+vert_idx))   1405
       WRITE_SHORT ("%vert_offset%"+4*(1+vert_idx)+2) 679
       WRITE_SHORT ("%vert_offset%"+4*(2+vert_idx))   1417
       WRITE_SHORT ("%vert_offset%"+4*(2+vert_idx)+2) 700
     END
     PATCH_IF ( ("%info_name%" STRING_COMPARE_CASE "ThroneL")=0 ) BEGIN
       WRITE_SHORT ("%infotrig_offset%"+0xc4*cnt+0x22) 344         //info trigger instead of travel
       WRITE_SHORT ("%infotrig_offset%"+0xc4*cnt+0x24) 1000        //info trigger instead of travel
       WRITE_SHORT ("%infotrig_offset%"+0xc4*cnt+0x26) 375         //info trigger instead of travel
       WRITE_SHORT ("%infotrig_offset%"+0xc4*cnt+0x28) 1041        //info trigger instead of travel
       //patching vertices for this trigger region
       READ_LONG  ("%infotrig_offset%"+0xc4*cnt+0x2c) vert_idx
       WRITE_SHORT ("%vert_offset%"+4*(0+vert_idx))   344
       WRITE_SHORT ("%vert_offset%"+4*(0+vert_idx)+2) 1041
       WRITE_SHORT ("%vert_offset%"+4*(1+vert_idx))   361
       WRITE_SHORT ("%vert_offset%"+4*(1+vert_idx)+2) 1000
       WRITE_SHORT ("%vert_offset%"+4*(2+vert_idx))   375
       WRITE_SHORT ("%vert_offset%"+4*(2+vert_idx)+2) 1023
     END
   END
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR5505.are~


//*******************************************************************************
//From CBisson nice WeiDUization attempts ;P
//*******************************************************************************
COPY_EXISTING ~AR0300.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%actors_num%"; cnt=cnt+1 ) BEGIN  //actors loop
   READ_ASCII ("%actors_offset%"+0x110*cnt)       "actor_name" (11)
   PATCH_IF (("%actor_name%" STRING_COMPARE_CASE "Sea Captain")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN             //adding new actor  *******************************
   SET offset = ("%actors_offset%"+0x110*"%actors_num%")
   INSERT_BYTES offset 0x110
   WRITE_ASCII offset ~Sea Captain~
   WRITE_SHORT (offset+0x20) 1760         //X
   WRITE_SHORT (offset+0x22) 3174         //Y
   WRITE_SHORT (offset+0x24) 1760         //destination X
   WRITE_SHORT (offset+0x26) 3174         //destination Y
   WRITE_LONG  (offset+0x28) 1            //visible
   WRITE_LONG  (offset+0x34) 8            //orientation
   WRITE_LONG  (offset+0x30) 0x0000c800   //unknown (animation?)
   WRITE_LONG  (offset+0x40) 0xffffffff   //schedule
   WRITE_ASCII (offset+0x80) ~CBSEACPT~   //creature
   SET "actors_num"="%actors_num%"+1
   WRITE_SHORT 0x58  "%actors_num%"

   SET "info_ext"=0x110
   PATCH_IF ("%infotrig_offset%">="%actors_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c "%infotrig_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%actors_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%actors_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%actors_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%actors_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%actors_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%actors_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%actors_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%actors_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%actors_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%actors_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%actors_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%actors_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%actors_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%actors_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

//adding 5 new triggers  ************************************************
   SET offset = ("%infotrig_offset%"+0xc4*"%infotrig_num%")
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~Tran3565~
   WRITE_SHORT (offset+0x20) 2            //travel trigger
   WRITE_SHORT (offset+0x22) 1327         //bounding box
   WRITE_SHORT (offset+0x24) 876          //bounding box
   WRITE_SHORT (offset+0x26) 1345         //bounding box
   WRITE_SHORT (offset+0x28) 946          //bounding box
   WRITE_SHORT (offset+0x2a) 6            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%" //first vertex index
   WRITE_LONG  (offset+0x34) 30           //cursor
   WRITE_ASCII (offset+0x38) ~AR3565~     //destination area
   WRITE_ASCII (offset+0x40) ~EXIT0300~   //destination area's entrance name
   WRITE_LONG  (offset+0x60) 0x00000100   //flags - trigger deactivated
   WRITE_SHORT (offset+0x70) 1396         //Trap location X
   WRITE_SHORT (offset+0x72) 948          //Trap location Y
   SET offset = offset+0xc4
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~Tran3566~
   WRITE_SHORT (offset+0x20) 2            //travel trigger
   WRITE_SHORT (offset+0x22) 4412         //bounding box
   WRITE_SHORT (offset+0x24) 1001         //bounding box
   WRITE_SHORT (offset+0x26) 4466         //bounding box
   WRITE_SHORT (offset+0x28) 1056         //bounding box
   WRITE_SHORT (offset+0x2a) 8            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%"+6 //first vertex index
   WRITE_LONG  (offset+0x34) 30           //cursor
   WRITE_ASCII (offset+0x38) ~AR3566~     //destination area
   WRITE_ASCII (offset+0x40) ~EXIT300b~   //destination area's entrance name
   WRITE_LONG  (offset+0x60) 0x00000104   //flags - trigger deactivated
   WRITE_SHORT (offset+0x70) 4574         //Trap location X
   WRITE_SHORT (offset+0x72) 990          //Trap location Y
   SET offset = offset+0xc4
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~CBSTAMBH~
   WRITE_SHORT (offset+0x20) 0            //proximity trigger
   WRITE_SHORT (offset+0x22) 2270         //bounding box
   WRITE_SHORT (offset+0x24) 2358         //bounding box
   WRITE_SHORT (offset+0x26) 2667         //bounding box
   WRITE_SHORT (offset+0x28) 2900         //bounding box
   WRITE_SHORT (offset+0x2a) 5            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%"+14 //first vertex index
   WRITE_LONG  (offset+0x60) 0x00000002   //flags
   WRITE_SHORT (offset+0x6c) 1            //Trapped
   WRITE_SHORT (offset+0x70) 2468         //Trap location X
   WRITE_SHORT (offset+0x72) 2629         //Trap location Y
   WRITE_ASCII (offset+0x7c) ~CBSTAM03~   //Trap script
   SET offset = offset+0xc4
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~CbInf328~
   WRITE_SHORT (offset+0x20) 1            //info trigger
   WRITE_SHORT (offset+0x22) 961          //bounding box
   WRITE_SHORT (offset+0x24) 1150         //bounding box
   WRITE_SHORT (offset+0x26) 1023         //bounding box
   WRITE_SHORT (offset+0x28) 1228         //bounding box
   WRITE_SHORT (offset+0x2a) 8            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%"+19 //first vertex index
   WRITE_LONG  (offset+0x34) 22           //cursor
   WRITE_LONG  (offset+0x60) 0x00000100   //flags - trigger deactivated
   WRITE_LONG  (offset+0x64) 39132        //StrRef
   WRITE_SHORT (offset+0x6c) 1            //Trapped
   WRITE_SHORT (offset+0x70) 670          //Trap location X
   WRITE_SHORT (offset+0x72) 1502         //Trap location Y
   SET offset = offset+0xc4
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~CBPARLFT~
   WRITE_SHORT (offset+0x20) 0            //proximity trigger
   WRITE_SHORT (offset+0x22) 1788         //bounding box
   WRITE_SHORT (offset+0x24) 240          //bounding box
   WRITE_SHORT (offset+0x26) 2323         //bounding box
   WRITE_SHORT (offset+0x28) 572          //bounding box
   WRITE_SHORT (offset+0x2a) 5            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%"+27 //first vertex index
   WRITE_LONG  (offset+0x60) 0x00000001   //flags
   WRITE_SHORT (offset+0x6c) 1            //Trapped
   WRITE_SHORT (offset+0x70) 2055         //Trap location X
   WRITE_SHORT (offset+0x72) 406         //Trap location Y
   WRITE_ASCII (offset+0x7c) ~CBPARLFT~   //Trap script
   SET "infotrig_num"="%infotrig_num%"+5
   WRITE_SHORT 0x5a  "%infotrig_num%"

   SET "info_ext"=0xc4*5
   PATCH_IF ("%actors_offset%">="%infotrig_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%infotrig_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%infotrig_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%infotrig_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%infotrig_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%infotrig_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%infotrig_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%infotrig_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%infotrig_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%infotrig_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%infotrig_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%infotrig_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%infotrig_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%infotrig_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%infotrig_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END
   
  //adding 32 new vertices for triggers
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*6)
   WRITE_SHORT  offset      1345
   WRITE_SHORT  (offset+2)  921
   WRITE_SHORT  (offset+4)  1345
   WRITE_SHORT  (offset+6)  876
   WRITE_SHORT  (offset+8)  1335
   WRITE_SHORT  (offset+10) 880
   WRITE_SHORT  (offset+12) 1327
   WRITE_SHORT  (offset+14) 882
   WRITE_SHORT  (offset+16) 1327
   WRITE_SHORT  (offset+18) 886
   WRITE_SHORT  (offset+20) 1327
   WRITE_SHORT  (offset+22) 946
   SET offset = offset + 4*6
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      4412
   WRITE_SHORT  (offset+2)  1056
   WRITE_SHORT  (offset+4)  4414
   WRITE_SHORT  (offset+6)  1011
   WRITE_SHORT  (offset+8)  4424
   WRITE_SHORT  (offset+10) 1002
   WRITE_SHORT  (offset+12) 4436
   WRITE_SHORT  (offset+14) 1001
   WRITE_SHORT  (offset+16) 4452
   WRITE_SHORT  (offset+18) 1002
   WRITE_SHORT  (offset+20) 4461
   WRITE_SHORT  (offset+22) 1005
   WRITE_SHORT  (offset+24) 4466
   WRITE_SHORT  (offset+26) 1011
   WRITE_SHORT  (offset+28) 4466
   WRITE_SHORT  (offset+30) 1053
   SET offset = offset + 4*8
   INSERT_BYTES offset (0x04*5)
   WRITE_SHORT  offset      2270
   WRITE_SHORT  (offset+2)  2537
   WRITE_SHORT  (offset+4)  2455
   WRITE_SHORT  (offset+6)  2900
   WRITE_SHORT  (offset+8)  2667
   WRITE_SHORT  (offset+10) 2845
   WRITE_SHORT  (offset+12) 2420
   WRITE_SHORT  (offset+14) 2358
   WRITE_SHORT  (offset+16) 2270
   WRITE_SHORT  (offset+18) 2537
   SET offset = offset + 4*5
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      961
   WRITE_SHORT  (offset+2)  1213
   WRITE_SHORT  (offset+4)  961
   WRITE_SHORT  (offset+6)  1190
   WRITE_SHORT  (offset+8)  962
   WRITE_SHORT  (offset+10) 1150
   WRITE_SHORT  (offset+12) 980
   WRITE_SHORT  (offset+14) 1156
   WRITE_SHORT  (offset+16) 1023
   WRITE_SHORT  (offset+18) 1163
   WRITE_SHORT  (offset+20) 1022
   WRITE_SHORT  (offset+22) 1183
   WRITE_SHORT  (offset+24) 1020
   WRITE_SHORT  (offset+26) 1203
   WRITE_SHORT  (offset+28) 1019
   WRITE_SHORT  (offset+30) 1228
   SET offset = offset + 4*8
   INSERT_BYTES offset (0x04*5)
   WRITE_SHORT  offset      1788
   WRITE_SHORT  (offset+2)  291
   WRITE_SHORT  (offset+4)  1979
   WRITE_SHORT  (offset+6)  572
   WRITE_SHORT  (offset+8)  2323
   WRITE_SHORT  (offset+10) 462
   WRITE_SHORT  (offset+12) 2134
   WRITE_SHORT  (offset+14) 240
   WRITE_SHORT  (offset+16) 1788
   WRITE_SHORT  (offset+18) 291
   SET "vert_num"="%vert_num%"+32
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*32
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0300.are~


COPY_EXISTING ~AR0330.ARE~ ~override~
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
    FOR( cnt=0; cnt<"%infotrig_num%"; cnt=cnt+1 ) BEGIN  //info/triggers loop
     READ_ASCII ("%infotrig_offset%"+0xc4*cnt)       "info_name"
     PATCH_IF ( ("%info_name%" STRING_COMPARE_CASE "Tran0331")=0 ) BEGIN
       WRITE_ASCII ("%infotrig_offset%"+0xc4*cnt)      "Tran3578"   //changing trigger's name
       WRITE_ASCII ("%infotrig_offset%"+0xc4*cnt+0x38) "AR3578" #8  //new destination area
     END
   END
 BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0330.are~


COPY_EXISTING ~AR0504.ARE~ ~override~
  WRITE_ASCII 0x94 ~AR0504~   //script
 BUT_ONLY_IF_IT_CHANGES


/*COPY_EXISTING ~AR0713.ARE~ ~override~  - non-existing CtB script
  WRITE_ASCII 0x94 ~AR0713~   //script
 BUT_ONLY_IF_IT_CHANGES*/


COPY_EXISTING ~AR1100.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%actors_num%"; cnt=cnt+1 ) BEGIN  //actors loop
   READ_ASCII ("%actors_offset%"+0x110*cnt)       "actor_name"
   PATCH_IF (("%actor_name%" STRING_COMPARE_CASE "CbBarlot")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN             //adding new actor  *******************************
   SET offset = ("%actors_offset%"+0x110*"%actors_num%")
   INSERT_BYTES offset 0x110
   WRITE_ASCII offset ~CbBarlot~
   WRITE_SHORT (offset+0x20) 533          //X
   WRITE_SHORT (offset+0x22) 2045         //Y
   WRITE_SHORT (offset+0x24) 533          //destination X
   WRITE_SHORT (offset+0x26) 2045         //destination Y
   WRITE_LONG  (offset+0x28) 1            //visible
   WRITE_LONG  (offset+0x30) 0x00006100   //unknown (animation?)
   WRITE_LONG  (offset+0x34) 3            //orientation
   WRITE_LONG  (offset+0x40) 0xffffffff   //schedule
   WRITE_ASCII (offset+0x80) ~CBPISSMN~   //creature
   SET "actors_num"="%actors_num%"+1
   WRITE_SHORT 0x58  "%actors_num%"
 END

 SET "info_ext"=0x110*info_1
 PATCH_IF ("%infotrig_offset%">="%actors_offset%") BEGIN
   "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
   WRITE_LONG  0x5c "%infotrig_offset%"
 END
 PATCH_IF ("%spawns_offset%">="%actors_offset%") BEGIN
   "spawns_offset"="%spawns_offset%"+"%info_ext%"
   WRITE_LONG  0x60  "%spawns_offset%"
 END
 PATCH_IF ("%entrances_offset%">="%actors_offset%") BEGIN
   "entrances_offset"="%entrances_offset%"+"%info_ext%"
   WRITE_LONG  0x68  "%entrances_offset%"
 END
 PATCH_IF ("%cont_offset%">="%actors_offset%") BEGIN
   "cont_offset"="%cont_offset%"+"%info_ext%"
   WRITE_LONG  0x70  "%cont_offset%"
 END
 PATCH_IF ("%items_offset%">="%actors_offset%") BEGIN
   "items_offset"="%items_offset%"+"%info_ext%"
   WRITE_LONG  0x78  "%items_offset%"
 END
 PATCH_IF ("%vert_offset%">="%actors_offset%") BEGIN
   "vert_offset"="%vert_offset%"+"%info_ext%"
   WRITE_LONG  0x7c  "%vert_offset%"
 END
 PATCH_IF ("%amb_offset%">="%actors_offset%") BEGIN
   "amb_offset"="%amb_offset%"+"%info_ext%"
   WRITE_LONG  0x84  "%amb_offset%"
 END
 PATCH_IF ("%vars_offset%">="%actors_offset%") BEGIN
   "vars_offset"="%vars_offset%"+"%info_ext%"
   WRITE_LONG  0x88  "%vars_offset%"
 END
 PATCH_IF ("%expbmp_offset%">="%actors_offset%") BEGIN
   "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
   WRITE_LONG  0xa0  "%expbmp_offset%"
 END
 PATCH_IF ("%doors_offset%">="%actors_offset%") BEGIN
   "doors_offset"="%doors_offset%"+"%info_ext%"
   WRITE_LONG  0xa8  "%doors_offset%"
 END
 PATCH_IF ("%anim_offset%">="%actors_offset%") BEGIN
   "anim_offset"="%anim_offset%"+"%info_ext%"
   WRITE_LONG  0xb0  "%anim_offset%"
 END
 PATCH_IF ("%tiled_offset%">="%actors_offset%") BEGIN
   "tiled_offset"="%tiled_offset%"+"%info_ext%"
   WRITE_LONG  0xb8  "%tiled_offset%"
 END
 PATCH_IF ("%songs_offset%">="%actors_offset%") BEGIN
   "songs_offset"="%songs_offset%"+"%info_ext%"
   WRITE_LONG  0xbc  "%songs_offset%"
 END
 PATCH_IF ("%rest_spawns_offset%">="%actors_offset%") BEGIN
   "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
   WRITE_LONG  0xc0  "%rest_spawns_offset%"
 END
 PATCH_IF ("%automap_offset%">="%actors_offset%") BEGIN
   "automap_offset"="%automap_offset%"+"%info_ext%"
   WRITE_LONG  0xc4  "%automap_offset%"
 END
 BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR1100.are~


COPY_EXISTING ~AR1202.ARE~  ~override~
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 SET "first_item1"=0
 SET "items1"=0
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //containers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name" (11)
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "Container 3")=0) BEGIN
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "first_item1"
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x44)  "items1"
   END
 END
 PATCH_IF ("%items1%">0 ) BEGIN
   SET ar_cnt=0
   SET bl_cnt=0
   FOR( cnt=0; cnt<"%items1%"; cnt=cnt+1 ) BEGIN       //items loop
     READ_ASCII ("%items_offset%"+0x14*(cnt+"%first_item1%")) "name"
     PATCH_IF ( ("%name%" STRING_COMPARE_CASE "AROW01")=0 ) BEGIN
       PATCH_IF( ar_cnt=0 ) BEGIN
         WRITE_ASCII ("%items_offset%"+0x14*(cnt+"%first_item1%"))     "CBNRTHM2" #8 //replacing item
         WRITE_SHORT ("%items_offset%"+0x14*(cnt+"%first_item1%")+0xa) 1
       END
       ELSE BEGIN
         PATCH_IF( ar_cnt=1 ) BEGIN
           WRITE_ASCII ("%items_offset%"+0x14*(cnt+"%first_item1%"))   "AROW02" #8 //replacing item
         END
       END
       ar_cnt += 1
     END
     PATCH_IF ( ("%name%" STRING_COMPARE_CASE "BOLT01")=0 ) BEGIN
       PATCH_IF( bl_cnt=0 ) BEGIN
         WRITE_ASCII ("%items_offset%"+0x14*(cnt+"%first_item1%"))     "BOLT06" #8 //replacing item
       END
       bl_cnt += 1
     END
   END
 END
BUT_ONLY_IF_IT_CHANGES //********************************************************  ~AR1202.are~


COPY_EXISTING ~AR1515.are~           ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET "first_item"=0
 SET "items"=0
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //containers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF ("%items%">0) BEGIN
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "first_item_next"     //shift all next containers' items
     WRITE_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "%first_item_next%"+1
   END
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "Desk 1")=0) BEGIN
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "first_item"
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x44)  "items"
     WRITE_LONG ("%cont_offset%"+0xc0*cnt+0x44) "%items%"+1  //we'll add 1 new item there
   END
 END

 PATCH_IF ("%items%">0 ) BEGIN
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET offset = ("%items_offset%"+0x14*"%first_item%")  //adding 1 item **************************
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBCWRSCH~

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END
 END
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR1515.are~


COPY_EXISTING ~AR0711.are~           ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET "first_item"=0
 SET "items"=0
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //containers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"  (11)
   PATCH_IF ("%items%">0) BEGIN
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "first_item_next"        //shift all next containers' items
     WRITE_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "%first_item_next%"+1
   END
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "Container 1")=0) BEGIN
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "first_item"
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x44)  "items"
     WRITE_LONG ("%cont_offset%"+0xc0*cnt+0x44) "%items%"+1  //we'll add 2 more items there
   END
 END

 PATCH_IF ("%items%">0 ) BEGIN
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET offset = ("%items_offset%"+0x14*"%first_item%")  //adding 1 item **************************
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBEMMETL~

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END
 END
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0711.are~



COPY_EXISTING ~AR0500.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%infotrig_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%infotrig_offset%"+0xc4*cnt)       "info_name"
   PATCH_IF (("%info_name%" STRING_COMPARE_CASE "CbMaltese")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       //adding 1 new Proximity trigger  ***************************
   SET offset = ("%infotrig_offset%"+0xc4*"%infotrig_num%")
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~CbMaltese~
   WRITE_SHORT (offset+0x20) 0            //proximity trigger
   WRITE_SHORT (offset+0x22) 1039         //bounding box
   WRITE_SHORT (offset+0x24) 3163         //bounding box
   WRITE_SHORT (offset+0x26) 1244         //bounding box
   WRITE_SHORT (offset+0x28) 3477         //bounding box
   WRITE_SHORT (offset+0x2a) 5            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%" //first vertex index
   WRITE_LONG  (offset+0x60) 0x00000001   //flags
   WRITE_SHORT (offset+0x6c) 1            //Trapped
   WRITE_SHORT (offset+0x70) 1141         //Trap location X
   WRITE_SHORT (offset+0x72) 3321         //Trap location Y
   WRITE_ASCII (offset+0x7c) ~CBMALMGE~   //Trap script
   SET "infotrig_num"="%infotrig_num%"+1
   WRITE_SHORT 0x5a  "%infotrig_num%"

   SET "info_ext"=0xc4
   PATCH_IF ("%actors_offset%">="%infotrig_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%infotrig_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%infotrig_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%infotrig_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%infotrig_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%infotrig_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%infotrig_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%infotrig_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%infotrig_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%infotrig_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%infotrig_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%infotrig_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%infotrig_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%infotrig_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%infotrig_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END
   
  //adding 5 new vertices for trigger
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*5)
   WRITE_SHORT  offset      1039
   WRITE_SHORT  (offset+2)  3241
   WRITE_SHORT  (offset+4)  1116
   WRITE_SHORT  (offset+6)  3477
   WRITE_SHORT  (offset+8)  1244
   WRITE_SHORT  (offset+10) 3396
   WRITE_SHORT  (offset+12) 1156
   WRITE_SHORT  (offset+14) 3163
   WRITE_SHORT  (offset+16) 1039
   WRITE_SHORT  (offset+18) 3241
   SET "vert_num"="%vert_num%"+5
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*5
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0500.are~


COPY_EXISTING ~AR1106.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%infotrig_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%infotrig_offset%"+0xc4*cnt)       "info_name"
   PATCH_IF (("%info_name%" STRING_COMPARE_CASE "PoolofRadiance")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       //adding 2 new triggers  ***************************
   SET offset = ("%infotrig_offset%"+0xc4*"%infotrig_num%")
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~PoolofRadiance~
   WRITE_SHORT (offset+0x20) 1            //info trigger
   WRITE_SHORT (offset+0x22) 293          //bounding box
   WRITE_SHORT (offset+0x24) 771          //bounding box
   WRITE_SHORT (offset+0x26) 522          //bounding box
   WRITE_SHORT (offset+0x28) 916          //bounding box
   WRITE_SHORT (offset+0x2a) 30           //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%" //first vertex index
   WRITE_LONG  (offset+0x34) 22           //cursor
   WRITE_SHORT (offset+0x70) 409          //Trap location X
   WRITE_SHORT (offset+0x72) 846          //Trap location Y
   WRITE_ASCII (offset+0x7c) ~CB1106TR~   //Trap script
   WRITE_SHORT (offset+0x84) 412         //override box left?????
   WRITE_SHORT (offset+0x86) 500         //override box top??????
   SET offset = offset+0xc4
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~Tran3575~
   WRITE_SHORT (offset+0x20) 2            //travel trigger
   WRITE_SHORT (offset+0x22) 293          //bounding box
   WRITE_SHORT (offset+0x24) 771          //bounding box
   WRITE_SHORT (offset+0x26) 522          //bounding box
   WRITE_SHORT (offset+0x28) 916          //bounding box
   WRITE_SHORT (offset+0x2a) 30           //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%"+30 //first vertex index
   WRITE_LONG  (offset+0x34) 34           //cursor
   WRITE_ASCII (offset+0x38) ~AR3575~     //destination area
   WRITE_ASCII (offset+0x40) ~EXIT1106~   //destination area's entrance name
   WRITE_LONG  (offset+0x60) 0x00000500   //flags - trigger deactivated, use override box (??)
   WRITE_SHORT (offset+0x70) 409         //Trap location X
   WRITE_SHORT (offset+0x72) 927         //Trap location Y
   WRITE_SHORT (offset+0x84) 409         //override box left???????
   WRITE_SHORT (offset+0x86) 927         //override box top????????

   SET "infotrig_num"="%infotrig_num%"+2
   WRITE_SHORT 0x5a  "%infotrig_num%"

   SET "info_ext"=0xc4*2
   PATCH_IF ("%actors_offset%">="%infotrig_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%infotrig_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%infotrig_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%infotrig_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%infotrig_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%infotrig_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%infotrig_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%infotrig_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%infotrig_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%infotrig_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%infotrig_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%infotrig_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%infotrig_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%infotrig_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%infotrig_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END
   
  //adding new vertices for triggers
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*30)
   WRITE_SHORT  offset      313
   WRITE_SHORT  (offset+2)  791
   WRITE_SHORT  (offset+4)  354
   WRITE_SHORT  (offset+6)  777
   WRITE_SHORT  (offset+8)  355
   WRITE_SHORT  (offset+10) 778
   WRITE_SHORT  (offset+12) 366
   WRITE_SHORT  (offset+14) 774
   WRITE_SHORT  (offset+16) 387
   WRITE_SHORT  (offset+18) 771
   WRITE_SHORT  (offset+20) 403
   WRITE_SHORT  (offset+22) 771
   WRITE_SHORT  (offset+24) 426
   WRITE_SHORT  (offset+26) 778
   WRITE_SHORT  (offset+28) 450
   WRITE_SHORT  (offset+30) 784
   WRITE_SHORT  (offset+32) 472
   WRITE_SHORT  (offset+34) 793
   WRITE_SHORT  (offset+36) 488
   WRITE_SHORT  (offset+38) 804
   WRITE_SHORT  (offset+40) 489
   WRITE_SHORT  (offset+42) 810
   WRITE_SHORT  (offset+44) 497
   WRITE_SHORT  (offset+46) 812
   WRITE_SHORT  (offset+48) 514
   WRITE_SHORT  (offset+50) 825
   WRITE_SHORT  (offset+52) 519
   WRITE_SHORT  (offset+54) 831
   WRITE_SHORT  (offset+56) 522
   WRITE_SHORT  (offset+58) 846
   WRITE_SHORT  (offset+60) 514
   WRITE_SHORT  (offset+62) 871
   WRITE_SHORT  (offset+64) 498
   WRITE_SHORT  (offset+66) 889
   WRITE_SHORT  (offset+68) 463
   WRITE_SHORT  (offset+70) 904
   WRITE_SHORT  (offset+72) 434
   WRITE_SHORT  (offset+74) 914
   WRITE_SHORT  (offset+76) 412
   WRITE_SHORT  (offset+78) 916
   WRITE_SHORT  (offset+80) 378
   WRITE_SHORT  (offset+82) 908
   WRITE_SHORT  (offset+84) 368
   WRITE_SHORT  (offset+86) 908
   WRITE_SHORT  (offset+88) 368
   WRITE_SHORT  (offset+90) 904
   WRITE_SHORT  (offset+92) 364
   WRITE_SHORT  (offset+94) 898
   WRITE_SHORT  (offset+96) 339
   WRITE_SHORT  (offset+98) 883
   WRITE_SHORT  (offset+100) 323
   WRITE_SHORT  (offset+102) 872
   WRITE_SHORT  (offset+104) 309
   WRITE_SHORT  (offset+106) 857
   WRITE_SHORT  (offset+108) 294
   WRITE_SHORT  (offset+110) 839
   WRITE_SHORT  (offset+112) 293
   WRITE_SHORT  (offset+114) 830
   WRITE_SHORT  (offset+116) 299
   WRITE_SHORT  (offset+118) 811
   SET offset = offset + 4*30
   INSERT_BYTES offset (0x04*30)
   WRITE_SHORT  offset      313
   WRITE_SHORT  (offset+2)  791
   WRITE_SHORT  (offset+4)  354
   WRITE_SHORT  (offset+6)  777
   WRITE_SHORT  (offset+8)  355
   WRITE_SHORT  (offset+10) 778
   WRITE_SHORT  (offset+12) 366
   WRITE_SHORT  (offset+14) 774
   WRITE_SHORT  (offset+16) 387
   WRITE_SHORT  (offset+18) 771
   WRITE_SHORT  (offset+20) 403
   WRITE_SHORT  (offset+22) 771
   WRITE_SHORT  (offset+24) 426
   WRITE_SHORT  (offset+26) 778
   WRITE_SHORT  (offset+28) 450
   WRITE_SHORT  (offset+30) 784
   WRITE_SHORT  (offset+32) 472
   WRITE_SHORT  (offset+34) 793
   WRITE_SHORT  (offset+36) 488
   WRITE_SHORT  (offset+38) 804
   WRITE_SHORT  (offset+40) 489
   WRITE_SHORT  (offset+42) 810
   WRITE_SHORT  (offset+44) 497
   WRITE_SHORT  (offset+46) 812
   WRITE_SHORT  (offset+48) 514
   WRITE_SHORT  (offset+50) 825
   WRITE_SHORT  (offset+52) 519
   WRITE_SHORT  (offset+54) 831
   WRITE_SHORT  (offset+56) 522
   WRITE_SHORT  (offset+58) 846
   WRITE_SHORT  (offset+60) 514
   WRITE_SHORT  (offset+62) 871
   WRITE_SHORT  (offset+64) 498
   WRITE_SHORT  (offset+66) 889
   WRITE_SHORT  (offset+68) 463
   WRITE_SHORT  (offset+70) 904
   WRITE_SHORT  (offset+72) 434
   WRITE_SHORT  (offset+74) 914
   WRITE_SHORT  (offset+76) 412
   WRITE_SHORT  (offset+78) 916
   WRITE_SHORT  (offset+80) 378
   WRITE_SHORT  (offset+82) 908
   WRITE_SHORT  (offset+84) 368
   WRITE_SHORT  (offset+86) 908
   WRITE_SHORT  (offset+88) 368
   WRITE_SHORT  (offset+90) 904
   WRITE_SHORT  (offset+92) 364
   WRITE_SHORT  (offset+94) 898
   WRITE_SHORT  (offset+96) 339
   WRITE_SHORT  (offset+98) 883
   WRITE_SHORT  (offset+100) 323
   WRITE_SHORT  (offset+102) 872
   WRITE_SHORT  (offset+104) 309
   WRITE_SHORT  (offset+106) 857
   WRITE_SHORT  (offset+108) 294
   WRITE_SHORT  (offset+110) 839
   WRITE_SHORT  (offset+112) 293
   WRITE_SHORT  (offset+114) 830
   WRITE_SHORT  (offset+116) 299
   WRITE_SHORT  (offset+118) 811
   SET "vert_num"="%vert_num%"+60
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*60
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR1106.are~


COPY_EXISTING ~AR1300.ARE~ ~override~
              ~AR1304.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%infotrig_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%infotrig_offset%"+0xc4*cnt)       "info_name"
   PATCH_IF (("%info_name%" STRING_COMPARE_CASE "ElderberryInfo")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       //adding 1 new info trigger  ***************************
   SET offset = ("%infotrig_offset%"+0xc4*"%infotrig_num%")
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~ElderberryInfo~
   WRITE_SHORT (offset+0x20) 1            //info trigger
   WRITE_SHORT (offset+0x22) 2677         //bounding box
   WRITE_SHORT (offset+0x24) 3363         //bounding box
   WRITE_SHORT (offset+0x26) 3157         //bounding box
   WRITE_SHORT (offset+0x28) 3566         //bounding box
   WRITE_SHORT (offset+0x2a) 8            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%" //first vertex index
   WRITE_LONG  (offset+0x34) 22           //cursor
   WRITE_SHORT (offset+0x6c) 1            //Trapped
   WRITE_SHORT (offset+0x70) 3033         //Trap location X
   WRITE_SHORT (offset+0x72) 3620         //Trap location Y
   WRITE_ASCII (offset+0x7c) ~CB1300DS~   //script
   SET "infotrig_num"="%infotrig_num%"+1
   WRITE_SHORT 0x5a  "%infotrig_num%"

   SET "info_ext"=0xc4
   PATCH_IF ("%actors_offset%">="%infotrig_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%infotrig_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%infotrig_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%infotrig_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%infotrig_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%infotrig_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%infotrig_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%infotrig_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%infotrig_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%infotrig_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%infotrig_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%infotrig_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%infotrig_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%infotrig_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%infotrig_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 1 new container
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~ElderberryCont~
   WRITE_SHORT (offset+0x20) 3034           //location X
   WRITE_SHORT (offset+0x22) 3622           //location Y
   WRITE_SHORT (offset+0x24) 8              //invisible
   WRITE_SHORT (offset+0x38) 2672           //bounding box left
   WRITE_SHORT (offset+0x3a) 3354           //bounding box top
   WRITE_SHORT (offset+0x3c) 3157           //bounding box right
   WRITE_SHORT (offset+0x3e) 3566           //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"+8 //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET "cont_num" = "%cont_num%" + 1
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CB901ELD~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000001
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 16 new vertices for trigger and container
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      2681
   WRITE_SHORT  (offset+2)  3559
   WRITE_SHORT  (offset+4)  3133
   WRITE_SHORT  (offset+6)  3555
   WRITE_SHORT  (offset+8)  3097
   WRITE_SHORT  (offset+10) 3446
   WRITE_SHORT  (offset+12) 3002
   WRITE_SHORT  (offset+14) 3376
   WRITE_SHORT  (offset+16) 2902
   WRITE_SHORT  (offset+18) 3381
   WRITE_SHORT  (offset+20) 2741
   WRITE_SHORT  (offset+22) 3360
   WRITE_SHORT  (offset+24) 2718
   WRITE_SHORT  (offset+26) 3387
   WRITE_SHORT  (offset+28) 2676
   WRITE_SHORT  (offset+30) 3519
   SET offset = offset + 4*8
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      2681
   WRITE_SHORT  (offset+2)  3559
   WRITE_SHORT  (offset+4)  3133
   WRITE_SHORT  (offset+6)  3555
   WRITE_SHORT  (offset+8)  3097
   WRITE_SHORT  (offset+10) 3446
   WRITE_SHORT  (offset+12) 3002
   WRITE_SHORT  (offset+14) 3376
   WRITE_SHORT  (offset+16) 2902
   WRITE_SHORT  (offset+18) 3381
   WRITE_SHORT  (offset+20) 2741
   WRITE_SHORT  (offset+22) 3360
   WRITE_SHORT  (offset+24) 2718
   WRITE_SHORT  (offset+26) 3387
   WRITE_SHORT  (offset+28) 2676
   WRITE_SHORT  (offset+30) 3519
   SET "vert_num"="%vert_num%"+16
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*16
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR1300,AR1304.are~



COPY_EXISTING ~AR1400.ARE~ ~override~
              ~AR1404.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%infotrig_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%infotrig_offset%"+0xc4*cnt)       "info_name"
   PATCH_IF (("%info_name%" STRING_COMPARE_CASE "ClubMossInfo")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       //adding 1 new info trigger  ***************************
   SET offset = ("%infotrig_offset%"+0xc4*"%infotrig_num%")
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~ClubMossInfo~
   WRITE_SHORT (offset+0x20) 1            //info trigger
   WRITE_SHORT (offset+0x22) 2518         //bounding box
   WRITE_SHORT (offset+0x24) 133          //bounding box
   WRITE_SHORT (offset+0x26) 2650         //bounding box
   WRITE_SHORT (offset+0x28) 220          //bounding box
   WRITE_SHORT (offset+0x2a) 8            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%" //first vertex index
   WRITE_LONG  (offset+0x34) 22           //cursor
   WRITE_SHORT (offset+0x6c) 1            //Trapped
   WRITE_SHORT (offset+0x70) 2712         //Trap location X
   WRITE_SHORT (offset+0x72) 174          //Trap location Y
   WRITE_ASCII (offset+0x7c) ~CB1400DS~   //script
   SET "infotrig_num"="%infotrig_num%"+1
   WRITE_SHORT 0x5a  "%infotrig_num%"

   SET "info_ext"=0xc4
   PATCH_IF ("%actors_offset%">="%infotrig_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%infotrig_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%infotrig_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%infotrig_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%infotrig_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%infotrig_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%infotrig_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%infotrig_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%infotrig_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%infotrig_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%infotrig_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%infotrig_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%infotrig_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%infotrig_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%infotrig_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 1 new container
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~ClubMossCont~
   WRITE_SHORT (offset+0x20) 2712           //location X
   WRITE_SHORT (offset+0x22) 174            //location Y
   WRITE_SHORT (offset+0x24) 8              //invisible
   WRITE_SHORT (offset+0x38) 2513           //bounding box left
   WRITE_SHORT (offset+0x3a) 123            //bounding box top
   WRITE_SHORT (offset+0x3c) 2650           //bounding box right
   WRITE_SHORT (offset+0x3e) 220            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"+8 //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET "cont_num" = "%cont_num%" + 1
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CB901CMS~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000001
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 16 new vertices for trigger and container
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      2515
   WRITE_SHORT  (offset+2)  182
   WRITE_SHORT  (offset+4)  2547
   WRITE_SHORT  (offset+6)  205
   WRITE_SHORT  (offset+8)  2622
   WRITE_SHORT  (offset+10) 207
   WRITE_SHORT  (offset+12) 2645
   WRITE_SHORT  (offset+14) 204
   WRITE_SHORT  (offset+16) 2615
   WRITE_SHORT  (offset+18) 128
   WRITE_SHORT  (offset+20) 2585
   WRITE_SHORT  (offset+22) 132
   WRITE_SHORT  (offset+24) 2561
   WRITE_SHORT  (offset+26) 140
   WRITE_SHORT  (offset+28) 2537
   WRITE_SHORT  (offset+30) 144
   SET offset = offset + 4*8
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      2515
   WRITE_SHORT  (offset+2)  182
   WRITE_SHORT  (offset+4)  2547
   WRITE_SHORT  (offset+6)  205
   WRITE_SHORT  (offset+8)  2622
   WRITE_SHORT  (offset+10) 207
   WRITE_SHORT  (offset+12) 2645
   WRITE_SHORT  (offset+14) 204
   WRITE_SHORT  (offset+16) 2615
   WRITE_SHORT  (offset+18) 128
   WRITE_SHORT  (offset+20) 2585
   WRITE_SHORT  (offset+22) 132
   WRITE_SHORT  (offset+24) 2561
   WRITE_SHORT  (offset+26) 140
   WRITE_SHORT  (offset+28) 2537
   WRITE_SHORT  (offset+30) 144
   SET "vert_num"="%vert_num%"+16
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*16
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR1400,AR1404.are~


COPY_EXISTING ~AR1700.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%infotrig_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%infotrig_offset%"+0xc4*cnt)       "info_name"
   PATCH_IF (("%info_name%" STRING_COMPARE_CASE "WormwoodInfo")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       //adding 1 new info trigger  ***************************
   SET offset = ("%infotrig_offset%"+0xc4*"%infotrig_num%")
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~WormwoodInfo~
   WRITE_SHORT (offset+0x20) 1            //info trigger
   WRITE_SHORT (offset+0x22) 3157         //bounding box
   WRITE_SHORT (offset+0x24) 184          //bounding box
   WRITE_SHORT (offset+0x26) 3358         //bounding box
   WRITE_SHORT (offset+0x28) 682          //bounding box
   WRITE_SHORT (offset+0x2a) 8            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%" //first vertex index
   WRITE_LONG  (offset+0x34) 22           //cursor
   WRITE_SHORT (offset+0x6c) 1            //Trapped
   WRITE_SHORT (offset+0x70) 3170         //Trap location X
   WRITE_SHORT (offset+0x72) 570          //Trap location Y
   WRITE_ASCII (offset+0x7c) ~CB1700DS~   //script
   SET "infotrig_num"="%infotrig_num%"+1
   WRITE_SHORT 0x5a  "%infotrig_num%"

   SET "info_ext"=0xc4
   PATCH_IF ("%actors_offset%">="%infotrig_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%infotrig_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%infotrig_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%infotrig_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%infotrig_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%infotrig_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%infotrig_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%infotrig_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%infotrig_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%infotrig_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%infotrig_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%infotrig_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%infotrig_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%infotrig_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%infotrig_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 1 new container
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~WormwoodCont~
   WRITE_SHORT (offset+0x20) 3179           //location X
   WRITE_SHORT (offset+0x22) 582            //location Y
   WRITE_SHORT (offset+0x24) 8              //invisible
   WRITE_SHORT (offset+0x38) 3152           //bounding box left
   WRITE_SHORT (offset+0x3a) 184            //bounding box top
   WRITE_SHORT (offset+0x3c) 3358           //bounding box right
   WRITE_SHORT (offset+0x3e) 682            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"+8 //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET "cont_num" = "%cont_num%" + 1
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CB901WRM~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000001
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 16 new vertices for trigger and container
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      3154
   WRITE_SHORT  (offset+2)  600
   WRITE_SHORT  (offset+4)  3263
   WRITE_SHORT  (offset+6)  672
   WRITE_SHORT  (offset+8)  3286
   WRITE_SHORT  (offset+10) 572
   WRITE_SHORT  (offset+12) 3317
   WRITE_SHORT  (offset+14) 503
   WRITE_SHORT  (offset+16) 3291
   WRITE_SHORT  (offset+18) 474
   WRITE_SHORT  (offset+20) 3210
   WRITE_SHORT  (offset+22) 481
   WRITE_SHORT  (offset+24) 3169
   WRITE_SHORT  (offset+26) 517
   WRITE_SHORT  (offset+28) 3190
   WRITE_SHORT  (offset+30) 571
   SET offset = offset + 4*8
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      3154
   WRITE_SHORT  (offset+2)  600
   WRITE_SHORT  (offset+4)  3263
   WRITE_SHORT  (offset+6)  672
   WRITE_SHORT  (offset+8)  3286
   WRITE_SHORT  (offset+10) 572
   WRITE_SHORT  (offset+12) 3317
   WRITE_SHORT  (offset+14) 503
   WRITE_SHORT  (offset+16) 3291
   WRITE_SHORT  (offset+18) 474
   WRITE_SHORT  (offset+20) 3210
   WRITE_SHORT  (offset+22) 481
   WRITE_SHORT  (offset+24) 3169
   WRITE_SHORT  (offset+26) 517
   WRITE_SHORT  (offset+28) 3190
   WRITE_SHORT  (offset+30) 571
   SET "vert_num"="%vert_num%"+16
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*16
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR1700.are~


COPY_EXISTING ~AR1900.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%infotrig_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%infotrig_offset%"+0xc4*cnt)       "info_name"
   PATCH_IF (("%info_name%" STRING_COMPARE_CASE "CouchGrassInfo")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       //adding 1 new info trigger  ***************************
   SET offset = ("%infotrig_offset%"+0xc4*"%infotrig_num%")
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~CouchGrassInfo~
   WRITE_SHORT (offset+0x20) 1            //info trigger
   WRITE_SHORT (offset+0x22) 197          //bounding box
   WRITE_SHORT (offset+0x24) 1090         //bounding box
   WRITE_SHORT (offset+0x26) 830          //bounding box
   WRITE_SHORT (offset+0x28) 1453         //bounding box
   WRITE_SHORT (offset+0x2a) 8            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%" //first vertex index
   WRITE_LONG  (offset+0x34) 22           //cursor
   WRITE_SHORT (offset+0x6c) 1            //Trapped
   WRITE_SHORT (offset+0x70) 513          //Trap location X
   WRITE_SHORT (offset+0x72) 1302         //Trap location Y
   WRITE_ASCII (offset+0x7c) ~CB1900DS~   //script
   SET "infotrig_num"="%infotrig_num%"+1
   WRITE_SHORT 0x5a  "%infotrig_num%"

   SET "info_ext"=0xc4
   PATCH_IF ("%actors_offset%">="%infotrig_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%infotrig_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%infotrig_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%infotrig_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%infotrig_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%infotrig_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%infotrig_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%infotrig_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%infotrig_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%infotrig_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%infotrig_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%infotrig_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%infotrig_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%infotrig_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%infotrig_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 1 new container
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CouchGrassCont~
   WRITE_SHORT (offset+0x20) 531            //location X
   WRITE_SHORT (offset+0x22) 1302           //location Y
   WRITE_SHORT (offset+0x24) 8              //invisible
   WRITE_SHORT (offset+0x38) 197            //bounding box left
   WRITE_SHORT (offset+0x3a) 1080           //bounding box top
   WRITE_SHORT (offset+0x3c) 830            //bounding box right
   WRITE_SHORT (offset+0x3e) 1453           //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"+8 //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET "cont_num" = "%cont_num%" + 1
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CB901CHG~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000001
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 16 new vertices for trigger and container
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      245
   WRITE_SHORT  (offset+2)  1449
   WRITE_SHORT  (offset+4)  403
   WRITE_SHORT  (offset+6)  1292
   WRITE_SHORT  (offset+8)  654
   WRITE_SHORT  (offset+10) 1156
   WRITE_SHORT  (offset+12) 800
   WRITE_SHORT  (offset+14) 1212
   WRITE_SHORT  (offset+16) 785
   WRITE_SHORT  (offset+18) 1124
   WRITE_SHORT  (offset+20) 672
   WRITE_SHORT  (offset+22) 1085
   WRITE_SHORT  (offset+24) 435
   WRITE_SHORT  (offset+26) 1184
   WRITE_SHORT  (offset+28) 226
   WRITE_SHORT  (offset+30) 1375
   SET offset = offset + 4*8
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      245
   WRITE_SHORT  (offset+2)  1449
   WRITE_SHORT  (offset+4)  403
   WRITE_SHORT  (offset+6)  1292
   WRITE_SHORT  (offset+8)  654
   WRITE_SHORT  (offset+10) 1156
   WRITE_SHORT  (offset+12) 800
   WRITE_SHORT  (offset+14) 1212
   WRITE_SHORT  (offset+16) 785
   WRITE_SHORT  (offset+18) 1124
   WRITE_SHORT  (offset+20) 672
   WRITE_SHORT  (offset+22) 1085
   WRITE_SHORT  (offset+24) 435
   WRITE_SHORT  (offset+26) 1184
   WRITE_SHORT  (offset+28) 226
   WRITE_SHORT  (offset+30) 1375
   SET "vert_num"="%vert_num%"+16
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*16
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR1900.are~



COPY_EXISTING ~AR1200.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%infotrig_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%infotrig_offset%"+0xc4*cnt)       "info_name"
   PATCH_IF (("%info_name%" STRING_COMPARE_CASE "PeachTreeInfo")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       //adding 1 new info trigger  ***************************
   SET offset = ("%infotrig_offset%"+0xc4*"%infotrig_num%")
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~PeachTreeInfo~
   WRITE_SHORT (offset+0x20) 1            //info trigger
   WRITE_SHORT (offset+0x22) 2487          //bounding box
   WRITE_SHORT (offset+0x24) 3158         //bounding box
   WRITE_SHORT (offset+0x26) 2825         //bounding box
   WRITE_SHORT (offset+0x28) 3491         //bounding box
   WRITE_SHORT (offset+0x2a) 8            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%" //first vertex index
   WRITE_LONG  (offset+0x34) 22           //cursor
   WRITE_SHORT (offset+0x6c) 1            //Trapped
   WRITE_SHORT (offset+0x70) 2757         //Trap location X
   WRITE_SHORT (offset+0x72) 3530         //Trap location Y
   WRITE_ASCII (offset+0x7c) ~CB1200DS~   //script
   SET "infotrig_num"="%infotrig_num%"+1
   WRITE_SHORT 0x5a  "%infotrig_num%"

   SET "info_ext"=0xc4
   PATCH_IF ("%actors_offset%">="%infotrig_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%infotrig_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%infotrig_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%infotrig_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%infotrig_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%infotrig_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%infotrig_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%infotrig_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%infotrig_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%infotrig_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%infotrig_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%infotrig_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%infotrig_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%infotrig_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%infotrig_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 1 new container
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~PeachTreeCont~
   WRITE_SHORT (offset+0x20) 2757            //location X
   WRITE_SHORT (offset+0x22) 3530           //location Y
   WRITE_SHORT (offset+0x24) 8              //invisible
   WRITE_SHORT (offset+0x38) 2482           //bounding box left
   WRITE_SHORT (offset+0x3a) 3158           //bounding box top
   WRITE_SHORT (offset+0x3c) 2825           //bounding box right
   WRITE_SHORT (offset+0x3e) 3491           //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"+8 //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET "cont_num" = "%cont_num%" + 1
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CB901PCH~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000001
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 16 new vertices for trigger and container
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      2482
   WRITE_SHORT  (offset+2)  3438
   WRITE_SHORT  (offset+4)  2560
   WRITE_SHORT  (offset+6)  3475
   WRITE_SHORT  (offset+8)  2751
   WRITE_SHORT  (offset+10) 3471
   WRITE_SHORT  (offset+12) 2820
   WRITE_SHORT  (offset+14) 3325
   WRITE_SHORT  (offset+16) 2752
   WRITE_SHORT  (offset+18) 3226
   WRITE_SHORT  (offset+20) 2618
   WRITE_SHORT  (offset+22) 3212
   WRITE_SHORT  (offset+24) 2520
   WRITE_SHORT  (offset+26) 3230
   WRITE_SHORT  (offset+28) 2535
   WRITE_SHORT  (offset+30) 3312
   SET offset = offset + 4*8
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      2482
   WRITE_SHORT  (offset+2)  3438
   WRITE_SHORT  (offset+4)  2560
   WRITE_SHORT  (offset+6)  3475
   WRITE_SHORT  (offset+8)  2751
   WRITE_SHORT  (offset+10) 3471
   WRITE_SHORT  (offset+12) 2820
   WRITE_SHORT  (offset+14) 3325
   WRITE_SHORT  (offset+16) 2752
   WRITE_SHORT  (offset+18) 3226
   WRITE_SHORT  (offset+20) 2618
   WRITE_SHORT  (offset+22) 3212
   WRITE_SHORT  (offset+24) 2520
   WRITE_SHORT  (offset+26) 3230
   WRITE_SHORT  (offset+28) 2535
   WRITE_SHORT  (offset+30) 3312
   SET "vert_num"="%vert_num%"+16
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*16
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR1200.are~



COPY_EXISTING ~AR0308.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "CbCont01")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       
   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 2 new containers
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont01~
   WRITE_SHORT (offset+0x20) 1401           //location X
   WRITE_SHORT (offset+0x22) 610            //location Y
   WRITE_SHORT (offset+0x24) 5              //Table
   WRITE_SHORT (offset+0x26) 40             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 1325           //bounding box left
   WRITE_SHORT (offset+0x3a) 553            //bounding box top
   WRITE_SHORT (offset+0x3c) 1416           //bounding box right
   WRITE_SHORT (offset+0x3e) 619            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"   //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET offset = offset + 0xc0
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont02~
   WRITE_SHORT (offset+0x20) 1382           //location X
   WRITE_SHORT (offset+0x22) 472            //location Y
   WRITE_SHORT (offset+0x24) 8              //nonvisible
   WRITE_SHORT (offset+0x26) 64             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 1386           //bounding box left
   WRITE_SHORT (offset+0x3a) 402            //bounding box top
   WRITE_SHORT (offset+0x3c) 1435           //bounding box right
   WRITE_SHORT (offset+0x3e) 454            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"+1//1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"+8 //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET "cont_num" = "%cont_num%" + 2
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0*2
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTHSCC~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   SET offset = offset + 0x14
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTHSDD~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   WRITE_SHORT 0x76  "%items_num%"+2       //increment total items count

   SET "info_ext"=0x14*2                 //we added 2 items
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 16 new vertices for trigger and container
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      1416
   WRITE_SHORT  (offset+2)  571
   WRITE_SHORT  (offset+4)  1403
   WRITE_SHORT  (offset+6)  560
   WRITE_SHORT  (offset+8)  1391
   WRITE_SHORT  (offset+10) 553
   WRITE_SHORT  (offset+12) 1358
   WRITE_SHORT  (offset+14) 572
   WRITE_SHORT  (offset+16) 1325
   WRITE_SHORT  (offset+18) 599
   WRITE_SHORT  (offset+20) 1334
   WRITE_SHORT  (offset+22) 605
   WRITE_SHORT  (offset+24) 1351
   WRITE_SHORT  (offset+26) 619
   WRITE_SHORT  (offset+28) 1382
   WRITE_SHORT  (offset+30) 592
   SET offset = offset + 4*8
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      1386
   WRITE_SHORT  (offset+2)  412
   WRITE_SHORT  (offset+4)  1405
   WRITE_SHORT  (offset+6)  402
   WRITE_SHORT  (offset+8)  1426
   WRITE_SHORT  (offset+10) 422
   WRITE_SHORT  (offset+12) 1435
   WRITE_SHORT  (offset+14) 448
   WRITE_SHORT  (offset+16) 1426
   WRITE_SHORT  (offset+18) 454
   WRITE_SHORT  (offset+20) 1406
   WRITE_SHORT  (offset+22) 445
   WRITE_SHORT  (offset+24) 1395
   WRITE_SHORT  (offset+26) 435
   WRITE_SHORT  (offset+28) 1387
   WRITE_SHORT  (offset+30) 422
   SET "vert_num"="%vert_num%"+16
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*16
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0308.are~


COPY_EXISTING ~AR0309.ARE~ ~override~
 WRITE_ASCII 0x94 ~AR0309~ #8  //area script (KD) - just to make sure it's set
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "CbCont01")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       
   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 2 new containers
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont01~
   WRITE_SHORT (offset+0x20) 756            //location X
   WRITE_SHORT (offset+0x22) 1240           //location Y
   WRITE_SHORT (offset+0x24) 5              //Table
   WRITE_SHORT (offset+0x26) 0              //Lock difficulty
   WRITE_SHORT (offset+0x28) 0              //not Locked
   WRITE_SHORT (offset+0x38) 668            //bounding box left
   WRITE_SHORT (offset+0x3a) 1187           //bounding box top
   WRITE_SHORT (offset+0x3c) 739            //bounding box right
   WRITE_SHORT (offset+0x3e) 1237           //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"   //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET offset = offset + 0xc0
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont02~
   WRITE_SHORT (offset+0x20) 1118           //location X
   WRITE_SHORT (offset+0x22) 1061           //location Y
   WRITE_SHORT (offset+0x24) 5              //nonvisible
   WRITE_SHORT (offset+0x26) 0              //Lock difficulty
   WRITE_SHORT (offset+0x28) 0              //not Locked
   WRITE_SHORT (offset+0x38) 1044           //bounding box left
   WRITE_SHORT (offset+0x3a) 976            //bounding box top
   WRITE_SHORT (offset+0x3c) 1132           //bounding box right
   WRITE_SHORT (offset+0x3e) 1039           //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"+1//1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"+8 //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET "cont_num" = "%cont_num%" + 2
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0*2
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTHSAA~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   SET offset = offset + 0x14
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTHSBB~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   WRITE_SHORT 0x76  "%items_num%"+2       //increment total items count

   SET "info_ext"=0x14*2                 //we added 2 items
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 16 new vertices for trigger and container
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      668
   WRITE_SHORT  (offset+2)  1218
   WRITE_SHORT  (offset+4)  678
   WRITE_SHORT  (offset+6)  1226
   WRITE_SHORT  (offset+8)  690
   WRITE_SHORT  (offset+10) 1237
   WRITE_SHORT  (offset+12) 720
   WRITE_SHORT  (offset+14) 1220
   WRITE_SHORT  (offset+16) 739
   WRITE_SHORT  (offset+18) 1208
   WRITE_SHORT  (offset+20) 725
   WRITE_SHORT  (offset+22) 1195
   WRITE_SHORT  (offset+24) 716
   WRITE_SHORT  (offset+26) 1188
   WRITE_SHORT  (offset+28) 715
   WRITE_SHORT  (offset+30) 1187
   SET offset = offset + 4*8
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      1044
   WRITE_SHORT  (offset+2)  1009
   WRITE_SHORT  (offset+4)  1062
   WRITE_SHORT  (offset+6)  992
   WRITE_SHORT  (offset+8)  1092
   WRITE_SHORT  (offset+10) 976
   WRITE_SHORT  (offset+12) 1115
   WRITE_SHORT  (offset+14) 992
   WRITE_SHORT  (offset+16) 1132
   WRITE_SHORT  (offset+18) 1005
   WRITE_SHORT  (offset+20) 1110
   WRITE_SHORT  (offset+22) 1020
   WRITE_SHORT  (offset+24) 1090
   WRITE_SHORT  (offset+26) 1032
   WRITE_SHORT  (offset+28) 1085
   WRITE_SHORT  (offset+30) 1039
   SET "vert_num"="%vert_num%"+16
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*16
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0309.are~


COPY_EXISTING ~AR0204.are~           ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET "first_item"=0
 SET "items"=0
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //containers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"  (11)
   PATCH_IF ("%items%">0) BEGIN
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "first_item_next"        //shift all next containers' items
     WRITE_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "%first_item_next%"+1
   END
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "Container 3")=0) BEGIN
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "first_item"
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x44)  "items"
     WRITE_LONG ("%cont_offset%"+0xc0*cnt+0x44) "%items%"+1  //we'll add 2 more items there
   END
 END

 PATCH_IF ("%items%">0 ) BEGIN
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET offset = ("%items_offset%"+0x14*"%first_item%")  //adding 1 item **************************
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBRYBERG~
   WRITE_SHORT  (offset+0x0a) 1

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END
 END
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0204.are~


COPY_EXISTING ~AR0805.ARE~ ~override~
 WRITE_ASCII 0x94 ~AR0805~ #8  //area script (KD) - just to make sure it's set
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "CbCont01")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       
   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 1 new container
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont01~
   WRITE_SHORT (offset+0x20) 404            //location X
   WRITE_SHORT (offset+0x22) 449            //location Y
   WRITE_SHORT (offset+0x24) 8              //nonvisible
   WRITE_SHORT (offset+0x26) 35             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 395            //bounding box left
   WRITE_SHORT (offset+0x3a) 335            //bounding box top
   WRITE_SHORT (offset+0x3c) 504            //bounding box right
   WRITE_SHORT (offset+0x3e) 420            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"   //1st vertex index
   WRITE_SHORT (offset+0x54) 7              //vertices number
   SET "cont_num" = "%cont_num%" + 1
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTGCAA~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 7 new vertices for trigger and container
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*7)
   WRITE_SHORT  offset      395
   WRITE_SHORT  (offset+2)  397
   WRITE_SHORT  (offset+4)  429
   WRITE_SHORT  (offset+6)  420
   WRITE_SHORT  (offset+8)  504
   WRITE_SHORT  (offset+10) 367
   WRITE_SHORT  (offset+12) 504
   WRITE_SHORT  (offset+14) 364
   WRITE_SHORT  (offset+16) 504
   WRITE_SHORT  (offset+18) 360
   WRITE_SHORT  (offset+20) 470
   WRITE_SHORT  (offset+22) 335
   WRITE_SHORT  (offset+24) 395
   WRITE_SHORT  (offset+26) 388
   SET "vert_num"="%vert_num%"+7
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*7
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0805.are~


COPY_EXISTING ~AR0806.ARE~ ~override~
 WRITE_ASCII 0x94 ~AR0806~ #8  //area script (KD) - just to make sure it's set
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "CbCont01")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       
   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 1 new container
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont01~
   WRITE_SHORT (offset+0x20) 355            //location X
   WRITE_SHORT (offset+0x22) 330            //location Y
   WRITE_SHORT (offset+0x24) 2              //chest
   WRITE_SHORT (offset+0x26) 65             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 321            //bounding box left
   WRITE_SHORT (offset+0x3a) 270            //bounding box top
   WRITE_SHORT (offset+0x3c) 367            //bounding box right
   WRITE_SHORT (offset+0x3e) 316            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"   //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET "cont_num" = "%cont_num%" + 1
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTGCDD~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 8 new vertices for trigger and container
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      321
   WRITE_SHORT  (offset+2)  301
   WRITE_SHORT  (offset+4)  336
   WRITE_SHORT  (offset+6)  316
   WRITE_SHORT  (offset+8)  367
   WRITE_SHORT  (offset+10) 300
   WRITE_SHORT  (offset+12) 367
   WRITE_SHORT  (offset+14) 285
   WRITE_SHORT  (offset+16) 362
   WRITE_SHORT  (offset+18) 277
   WRITE_SHORT  (offset+20) 358
   WRITE_SHORT  (offset+22) 272
   WRITE_SHORT  (offset+24) 353
   WRITE_SHORT  (offset+26) 270
   WRITE_SHORT  (offset+28) 321
   WRITE_SHORT  (offset+30) 286
   SET "vert_num"="%vert_num%"+8
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*8
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0806.are~


COPY_EXISTING ~AR0807.ARE~ ~override~
 WRITE_ASCII 0x94 ~AR0807~ #8  //area script (KD) - just to make sure it's set
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "CbCont01")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       
   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 1 new container
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont01~
   WRITE_SHORT (offset+0x20) 434            //location X
   WRITE_SHORT (offset+0x22) 405            //location Y
   WRITE_SHORT (offset+0x24) 8              //nonvisible
   WRITE_SHORT (offset+0x26) 35             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 335            //bounding box left
   WRITE_SHORT (offset+0x3a) 294            //bounding box top
   WRITE_SHORT (offset+0x3c) 444            //bounding box right
   WRITE_SHORT (offset+0x3e) 379            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"   //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET "cont_num" = "%cont_num%" + 1
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTGCBB~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 8 new vertices for trigger and container
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      335
   WRITE_SHORT  (offset+2)  325
   WRITE_SHORT  (offset+4)  410
   WRITE_SHORT  (offset+6)  379
   WRITE_SHORT  (offset+8)  444
   WRITE_SHORT  (offset+10) 355
   WRITE_SHORT  (offset+12) 444
   WRITE_SHORT  (offset+14) 352
   WRITE_SHORT  (offset+16) 444
   WRITE_SHORT  (offset+18) 350
   WRITE_SHORT  (offset+20) 444
   WRITE_SHORT  (offset+22) 348
   WRITE_SHORT  (offset+24) 369
   WRITE_SHORT  (offset+26) 294
   WRITE_SHORT  (offset+28) 335
   WRITE_SHORT  (offset+30) 316
   SET "vert_num"="%vert_num%"+8
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*8
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0807.are~


COPY_EXISTING ~AR0809.are~           ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET "first_item"=0
 SET "items"=0
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //containers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF ("%items%">0) BEGIN
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "first_item_next"        //shift all next containers' items
     WRITE_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "%first_item_next%"+1
   END
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "Altar 1")=0) BEGIN
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x40)  "first_item"
     READ_LONG ("%cont_offset%"+0xc0*cnt+0x44)  "items"
     WRITE_LONG ("%cont_offset%"+0xc0*cnt+0x44) "%items%"+1  //we'll add 2 more items there
   END
 END

 PATCH_IF ("%items%">0 ) BEGIN
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET offset = ("%items_offset%"+0x14*"%first_item%")  //adding 1 item **************************
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CB3597ST~

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END
 END
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0809.are~


COPY_EXISTING ~AR0813.ARE~ ~override~
 WRITE_ASCII 0x94 ~AR0813~ #8  //area script (KD) - just to make sure it's set
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "CbCont01")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       
   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 1 new container
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont01~
   WRITE_SHORT (offset+0x20) 455            //location X
   WRITE_SHORT (offset+0x22) 395            //location Y
   WRITE_SHORT (offset+0x24) 8              //nonvisible
   WRITE_SHORT (offset+0x26) 25             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 335            //bounding box left
   WRITE_SHORT (offset+0x3a) 294            //bounding box top
   WRITE_SHORT (offset+0x3c) 444            //bounding box right
   WRITE_SHORT (offset+0x3e) 379            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"   //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET "cont_num" = "%cont_num%" + 1
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTGCCC~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 8 new vertices for container
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      335
   WRITE_SHORT  (offset+2)  325
   WRITE_SHORT  (offset+4)  410
   WRITE_SHORT  (offset+6)  379
   WRITE_SHORT  (offset+8)  444
   WRITE_SHORT  (offset+10) 355
   WRITE_SHORT  (offset+12) 444
   WRITE_SHORT  (offset+14) 352
   WRITE_SHORT  (offset+16) 444
   WRITE_SHORT  (offset+18) 350
   WRITE_SHORT  (offset+20) 444
   WRITE_SHORT  (offset+22) 348
   WRITE_SHORT  (offset+24) 369
   WRITE_SHORT  (offset+26) 294
   WRITE_SHORT  (offset+28) 335
   WRITE_SHORT  (offset+30) 316
   SET "vert_num"="%vert_num%"+8
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*8
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0813.are~


COPY_EXISTING ~AR0902.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "CbCont01")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       
   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 2 new containers
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont01~
   WRITE_SHORT (offset+0x20) 1325           //location X
   WRITE_SHORT (offset+0x22) 1513           //location Y
   WRITE_SHORT (offset+0x24) 2              //chest
   WRITE_SHORT (offset+0x26) 90             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 1286           //bounding box left
   WRITE_SHORT (offset+0x3a) 1437           //bounding box top
   WRITE_SHORT (offset+0x3c) 1334           //bounding box right
   WRITE_SHORT (offset+0x3e) 1505           //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 2              //2 items
   WRITE_LONG  (offset+0x50) "%vert_num%"   //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET offset = offset + 0xc0
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont02~
   WRITE_SHORT (offset+0x20) 1434           //location X
   WRITE_SHORT (offset+0x22) 1606           //location Y
   WRITE_SHORT (offset+0x24) 2              //chest
   WRITE_SHORT (offset+0x26) 65             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 1445           //bounding box left
   WRITE_SHORT (offset+0x3a) 1557           //bounding box top
   WRITE_SHORT (offset+0x3c) 1489           //bounding box right
   WRITE_SHORT (offset+0x3e) 1610           //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"+2  //1st item index
   WRITE_LONG  (offset+0x44) 1              //2 items
   WRITE_LONG  (offset+0x50) "%vert_num%"+8   //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET "cont_num" = "%cont_num%" + 2
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0*2
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTLTAA~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   SET offset = offset + 0x14
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTLTCC~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   SET offset = offset + 0x14
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTLTBB~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   WRITE_SHORT 0x76  "%items_num%"+3       //increment total items count

   SET "info_ext"=0x14*3                 //we added 3 items
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 16 new vertices for 2 containers
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      1300
   WRITE_SHORT  (offset+2)  1505
   WRITE_SHORT  (offset+4)  1286
   WRITE_SHORT  (offset+6)  1490
   WRITE_SHORT  (offset+8)  1286
   WRITE_SHORT  (offset+10) 1470
   WRITE_SHORT  (offset+12) 1286
   WRITE_SHORT  (offset+14) 1449
   WRITE_SHORT  (offset+16) 1318
   WRITE_SHORT  (offset+18) 1437
   WRITE_SHORT  (offset+20) 1334
   WRITE_SHORT  (offset+22) 1455
   WRITE_SHORT  (offset+24) 1334
   WRITE_SHORT  (offset+26) 1470
   WRITE_SHORT  (offset+28) 1344
   WRITE_SHORT  (offset+30) 1490
   SET offset = offset + 0x04*8
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      1445
   WRITE_SHORT  (offset+2)  1590
   WRITE_SHORT  (offset+4)  1445
   WRITE_SHORT  (offset+6)  1570
   WRITE_SHORT  (offset+8)  1448
   WRITE_SHORT  (offset+10) 1563
   WRITE_SHORT  (offset+12) 1453
   WRITE_SHORT  (offset+14) 1558
   WRITE_SHORT  (offset+16) 1458
   WRITE_SHORT  (offset+18) 1557
   WRITE_SHORT  (offset+20) 1489
   WRITE_SHORT  (offset+22) 1578
   WRITE_SHORT  (offset+24) 1489
   WRITE_SHORT  (offset+26) 1597
   WRITE_SHORT  (offset+28) 1476
   WRITE_SHORT  (offset+30) 1610
   SET "vert_num"="%vert_num%"+16
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*16
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0902.are~


COPY_EXISTING ~AR0903.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "CbCont01")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       
   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 1 new container
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont01~
   WRITE_SHORT (offset+0x20) 395            //location X
   WRITE_SHORT (offset+0x22) 547            //location Y
   WRITE_SHORT (offset+0x24) 5              //table
   WRITE_SHORT (offset+0x26) 25             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 338            //bounding box left
   WRITE_SHORT (offset+0x3a) 505            //bounding box top
   WRITE_SHORT (offset+0x3c) 379            //bounding box right
   WRITE_SHORT (offset+0x3e) 552            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"   //1st vertex index
   WRITE_SHORT (offset+0x54) 4              //vertices number
   SET "cont_num" = "%cont_num%" + 1
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTRHAA~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 4 new vertices for container
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*4)
   WRITE_SHORT  offset      338
   WRITE_SHORT  (offset+2)  507
   WRITE_SHORT  (offset+4)  377
   WRITE_SHORT  (offset+6)  505
   WRITE_SHORT  (offset+8)  379
   WRITE_SHORT  (offset+10) 549
   WRITE_SHORT  (offset+12) 342
   WRITE_SHORT  (offset+14) 552
   SET "vert_num"="%vert_num%"+4
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*4
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0903.are~


COPY_EXISTING ~AR0906.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "CbCont01")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       
   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 1 new container
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont01~
   WRITE_SHORT (offset+0x20) 572            //location X
   WRITE_SHORT (offset+0x22) 951            //location Y
   WRITE_SHORT (offset+0x24) 2              //chest
   WRITE_SHORT (offset+0x26) 36             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 514            //bounding box left
   WRITE_SHORT (offset+0x3a) 919            //bounding box top
   WRITE_SHORT (offset+0x3c) 558            //bounding box right
   WRITE_SHORT (offset+0x3e) 966            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"   //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET "cont_num" = "%cont_num%" + 1
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 1 item **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTSHEE~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   WRITE_SHORT 0x76  "%items_num%"+1       //increment total items count

   SET "info_ext"=0x14                 //we added 1 item
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 8 new vertices for container
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      514
   WRITE_SHORT  (offset+2)  946
   WRITE_SHORT  (offset+4)  538
   WRITE_SHORT  (offset+6)  966
   WRITE_SHORT  (offset+8)  558
   WRITE_SHORT  (offset+10) 955
   WRITE_SHORT  (offset+12) 558
   WRITE_SHORT  (offset+14) 939
   WRITE_SHORT  (offset+16) 532
   WRITE_SHORT  (offset+18) 919
   WRITE_SHORT  (offset+20) 527
   WRITE_SHORT  (offset+22) 919
   WRITE_SHORT  (offset+24) 520
   WRITE_SHORT  (offset+26) 923
   WRITE_SHORT  (offset+28) 514
   WRITE_SHORT  (offset+30) 930
   SET "vert_num"="%vert_num%"+8
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*8
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0906.are~


COPY_EXISTING ~AR1002.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "CbCont01")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       
   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 2 new containers
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont01~
   WRITE_SHORT (offset+0x20) 668            //location X
   WRITE_SHORT (offset+0x22) 326            //location Y
   WRITE_SHORT (offset+0x24) 7              //altar
   WRITE_SHORT (offset+0x26) 22             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 613            //bounding box left
   WRITE_SHORT (offset+0x3a) 274            //bounding box top
   WRITE_SHORT (offset+0x3c) 680            //bounding box right
   WRITE_SHORT (offset+0x3e) 324            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"   //1st vertex index
   WRITE_SHORT (offset+0x54) 4              //vertices number
   SET offset = offset + 0xc0
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont02~
   WRITE_SHORT (offset+0x20) 1052           //location X
   WRITE_SHORT (offset+0x22) 481            //location Y
   WRITE_SHORT (offset+0x24) 8              //nonvisible
   WRITE_SHORT (offset+0x26) 65             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 1048           //bounding box left
   WRITE_SHORT (offset+0x3a) 381            //bounding box top
   WRITE_SHORT (offset+0x3c) 1067           //bounding box right
   WRITE_SHORT (offset+0x3e) 414            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"+1  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"+4   //1st vertex index
   WRITE_SHORT (offset+0x54) 7              //vertices number
   SET "cont_num" = "%cont_num%" + 2
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0*2
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 2 items **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTGBAA~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   SET offset = offset + 0x14
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTGBBB~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   WRITE_SHORT 0x76  "%items_num%"+2     //increment total items count

   SET "info_ext"=0x14*2                 //we added 2 items
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 11 new vertices for 2 containers
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*4)
   WRITE_SHORT  offset      613
   WRITE_SHORT  (offset+2)  307
   WRITE_SHORT  (offset+4)  657
   WRITE_SHORT  (offset+6) 274
   WRITE_SHORT  (offset+8) 680
   WRITE_SHORT  (offset+10) 292
   WRITE_SHORT  (offset+12) 635
   WRITE_SHORT  (offset+14) 324
   SET offset = offset + 0x04*4
   INSERT_BYTES offset (0x04*7)
   WRITE_SHORT  offset      1053
   WRITE_SHORT  (offset+2)  413
   WRITE_SHORT  (offset+4)  1048
   WRITE_SHORT  (offset+6)  394
   WRITE_SHORT  (offset+8)  1060
   WRITE_SHORT  (offset+10) 381
   WRITE_SHORT  (offset+12) 1067
   WRITE_SHORT  (offset+14) 387
   WRITE_SHORT  (offset+16) 1066
   WRITE_SHORT  (offset+18) 400
   WRITE_SHORT  (offset+20) 1061
   WRITE_SHORT  (offset+22) 413
   WRITE_SHORT  (offset+24) 1058
   WRITE_SHORT  (offset+26) 414
   SET "vert_num"="%vert_num%"+11
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*11
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR1002.are~


COPY_EXISTING ~AR1006.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "CbCont01")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       
   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 2 new containers
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont01~
   WRITE_SHORT (offset+0x20) 239            //location X
   WRITE_SHORT (offset+0x22) 585            //location Y
   WRITE_SHORT (offset+0x24) 2              //chest
   WRITE_SHORT (offset+0x26) 36             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 198            //bounding box left
   WRITE_SHORT (offset+0x3a) 530            //bounding box top
   WRITE_SHORT (offset+0x3c) 247            //bounding box right
   WRITE_SHORT (offset+0x3e) 576            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"   //1st vertex index
   WRITE_SHORT (offset+0x54) 6              //vertices number
   SET offset = offset + 0xc0
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont02~
   WRITE_SHORT (offset+0x20) 438            //location X
   WRITE_SHORT (offset+0x22) 440            //location Y
   WRITE_SHORT (offset+0x24) 3              //drawer
   WRITE_SHORT (offset+0x26) 54             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 419            //bounding box left
   WRITE_SHORT (offset+0x3a) 371            //bounding box top
   WRITE_SHORT (offset+0x3c) 485            //bounding box right
   WRITE_SHORT (offset+0x3e) 435            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"+1  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"+6   //1st vertex index
   WRITE_SHORT (offset+0x54) 6              //vertices number
   SET "cont_num" = "%cont_num%" + 2
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0*2
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 2 items **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTJEAA~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   SET offset = offset + 0x14
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTJEBB~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   WRITE_SHORT 0x76  "%items_num%"+2     //increment total items count

   SET "info_ext"=0x14*2                 //we added 2 items
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 12 new vertices for 2 containers
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*6)
   WRITE_SHORT  offset      212
   WRITE_SHORT  (offset+2)  576
   WRITE_SHORT  (offset+4)  247
   WRITE_SHORT  (offset+6)  554
   WRITE_SHORT  (offset+8)  247
   WRITE_SHORT  (offset+10) 541
   WRITE_SHORT  (offset+12) 232
   WRITE_SHORT  (offset+14) 530
   WRITE_SHORT  (offset+16) 198
   WRITE_SHORT  (offset+18) 553
   WRITE_SHORT  (offset+20) 198
   WRITE_SHORT  (offset+22) 566
   SET offset = offset + 0x04*6
   INSERT_BYTES offset (0x04*6)
   WRITE_SHORT  offset      469
   WRITE_SHORT  (offset+2)  435
   WRITE_SHORT  (offset+4)  485
   WRITE_SHORT  (offset+6)  422
   WRITE_SHORT  (offset+8)  485
   WRITE_SHORT  (offset+10) 406
   WRITE_SHORT  (offset+12) 435
   WRITE_SHORT  (offset+14) 371
   WRITE_SHORT  (offset+16) 419
   WRITE_SHORT  (offset+18) 383
   WRITE_SHORT  (offset+20) 419
   WRITE_SHORT  (offset+22) 401
   SET "vert_num"="%vert_num%"+12
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*12
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR1006.are~


COPY_EXISTING ~AR0907.ARE~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=1
 FOR( cnt=0; cnt<"%cont_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%cont_offset%"+0xc0*cnt)       "cont_name"
   PATCH_IF (("%cont_name%" STRING_COMPARE_CASE "CbCont01")=0) BEGIN  //if already exists
     info_1=0
   END
 END

 PATCH_IF (info_1=1) BEGIN       
   SET offset = ("%cont_offset%"+0xc0*"%cont_num%")  //adding 4 new containers
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont01~
   WRITE_SHORT (offset+0x20) 1874           //location X
   WRITE_SHORT (offset+0x22) 493            //location Y
   WRITE_SHORT (offset+0x24) 5              //table
   WRITE_SHORT (offset+0x26) 45             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 1803           //bounding box left
   WRITE_SHORT (offset+0x3a) 408            //bounding box top
   WRITE_SHORT (offset+0x3c) 1890           //bounding box right
   WRITE_SHORT (offset+0x3e) 470            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"   //1st vertex index
   WRITE_SHORT (offset+0x54) 4              //vertices number
   SET offset = offset + 0xc0
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont02~
   WRITE_SHORT (offset+0x20) 1678           //location X
   WRITE_SHORT (offset+0x22) 606            //location Y
   WRITE_SHORT (offset+0x24) 8              //nonvisible
   WRITE_SHORT (offset+0x26) 85             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 1664           //bounding box left
   WRITE_SHORT (offset+0x3a) 552            //bounding box top
   WRITE_SHORT (offset+0x3c) 1681           //bounding box right
   WRITE_SHORT (offset+0x3e) 587            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"+1  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"+4   //1st vertex index
   WRITE_SHORT (offset+0x54) 4              //vertices number
   SET offset = offset + 0xc0
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont03~
   WRITE_SHORT (offset+0x20) 1818           //location X
   WRITE_SHORT (offset+0x22) 541            //location Y
   WRITE_SHORT (offset+0x24) 5              //table
   WRITE_SHORT (offset+0x26) 0              //Lock difficulty
   WRITE_SHORT (offset+0x28) 0              //not Locked
   WRITE_SHORT (offset+0x38) 1743           //bounding box left
   WRITE_SHORT (offset+0x3a) 447            //bounding box top
   WRITE_SHORT (offset+0x3c) 1831           //bounding box right
   WRITE_SHORT (offset+0x3e) 510            //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"+2  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"+8   //1st vertex index
   WRITE_SHORT (offset+0x54) 4              //vertices number
   SET offset = offset + 0xc0
   INSERT_BYTES offset 0xc0
   WRITE_ASCII offset ~CbCont04~
   WRITE_SHORT (offset+0x20) 255            //location X
   WRITE_SHORT (offset+0x22) 1163           //location Y
   WRITE_SHORT (offset+0x24) 2              //chest
   WRITE_SHORT (offset+0x26) 78             //Lock difficulty
   WRITE_SHORT (offset+0x28) 1              //Locked
   WRITE_SHORT (offset+0x38) 209            //bounding box left
   WRITE_SHORT (offset+0x3a) 1119           //bounding box top
   WRITE_SHORT (offset+0x3c) 247            //bounding box right
   WRITE_SHORT (offset+0x3e) 1162           //bounding box bottom
   WRITE_LONG  (offset+0x40) "%items_num%"+3  //1st item index
   WRITE_LONG  (offset+0x44) 1              //1 item
   WRITE_LONG  (offset+0x50) "%vert_num%"+12   //1st vertex index
   WRITE_SHORT (offset+0x54) 8              //vertices number
   SET "cont_num" = "%cont_num%" + 4
   WRITE_SHORT 0x74  "%cont_num%"

   SET "info_ext"=0xc0*4
   PATCH_IF ("%actors_offset%">="%cont_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%cont_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%cont_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%cont_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%items_offset%">="%cont_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%vert_offset%">="%cont_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%amb_offset%">="%cont_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%cont_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%cont_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%cont_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%cont_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%cont_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%cont_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%cont_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%cont_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 4 items **************************
   SET offset = ("%items_offset%"+0x14*"%items_num%")
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTSHAA~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   SET offset = offset + 0x14
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTSHBB~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   SET offset = offset + 0x14
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTSHCC~
   WRITE_SHORT  (offset+0x0a) 24
   WRITE_LONG   (offset+0x10) 0x00000004
   SET offset = offset + 0x14
   INSERT_BYTES offset        0x14
   WRITE_ASCII  offset        ~CBXTSHDD~
   WRITE_SHORT  (offset+0x0a) 1
   WRITE_LONG   (offset+0x10) 0x00000004
   WRITE_SHORT 0x76  "%items_num%"+4     //increment total items count

   SET "info_ext"=0x14*4                 //we added 4 items
   PATCH_IF ("%actors_offset%">="%items_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%items_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%items_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%items_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%vert_offset%">="%items_offset%") BEGIN
     "vert_offset"="%vert_offset%"+"%info_ext%"
     WRITE_LONG  0x7c  "%vert_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%items_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%items_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%items_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%items_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%items_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%items_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%items_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%items_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%items_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%items_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

  //adding 20 new vertices for 4 containers
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*4)
   WRITE_SHORT  offset      1803
   WRITE_SHORT  (offset+2)  443
   WRITE_SHORT  (offset+4)  1841
   WRITE_SHORT  (offset+6)  470
   WRITE_SHORT  (offset+8)  1890
   WRITE_SHORT  (offset+10) 437
   WRITE_SHORT  (offset+12) 1851
   WRITE_SHORT  (offset+14) 408
   SET offset = offset + 0x04*4
   INSERT_BYTES offset (0x04*4)
   WRITE_SHORT  offset      1664
   WRITE_SHORT  (offset+2)  587
   WRITE_SHORT  (offset+4)  1681
   WRITE_SHORT  (offset+6)  576
   WRITE_SHORT  (offset+8)  1681
   WRITE_SHORT  (offset+10) 552
   WRITE_SHORT  (offset+12) 1664
   WRITE_SHORT  (offset+14) 565
   SET offset = offset + 0x04*4
   INSERT_BYTES offset (0x04*4)
   WRITE_SHORT  offset      1743
   WRITE_SHORT  (offset+2)  482
   WRITE_SHORT  (offset+4)  1786
   WRITE_SHORT  (offset+6)  511
   WRITE_SHORT  (offset+8)  1831
   WRITE_SHORT  (offset+10) 475
   WRITE_SHORT  (offset+12) 1792
   WRITE_SHORT  (offset+14) 447
   SET offset = offset + 0x04*4
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      209
   WRITE_SHORT  (offset+2)  1151
   WRITE_SHORT  (offset+4)  225
   WRITE_SHORT  (offset+6)  1162
   WRITE_SHORT  (offset+8)  247
   WRITE_SHORT  (offset+10) 1144
   WRITE_SHORT  (offset+12) 247
   WRITE_SHORT  (offset+14) 1131
   WRITE_SHORT  (offset+16) 243
   WRITE_SHORT  (offset+18) 1124
   WRITE_SHORT  (offset+20) 238
   WRITE_SHORT  (offset+22) 1121
   WRITE_SHORT  (offset+24) 230
   WRITE_SHORT  (offset+26) 1119
   WRITE_SHORT  (offset+28) 209
   WRITE_SHORT  (offset+30) 1136
   SET "vert_num"="%vert_num%"+20
   WRITE_SHORT 0x80  "%vert_num%"

   SET "info_ext"=0x04*20
   PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
     "actors_offset"="%actors_offset%"+"%info_ext%"
     WRITE_LONG  0x54 "%actors_offset%"
   END
   PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
     "spawns_offset"="%spawns_offset%"+"%info_ext%"
     WRITE_LONG  0x60  "%spawns_offset%"
   END
   PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
     "entrances_offset"="%entrances_offset%"+"%info_ext%"
     WRITE_LONG  0x68  "%entrances_offset%"
   END
   PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
     "cont_offset"="%cont_offset%"+"%info_ext%"
     WRITE_LONG  0x70  "%cont_offset%"
   END
   PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
     "items_offset"="%items_offset%"+"%info_ext%"
     WRITE_LONG  0x78  "%items_offset%"
   END
   PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
     "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
     WRITE_LONG  0x5c  "%infotrig_offset%"
   END
   PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
     "amb_offset"="%amb_offset%"+"%info_ext%"
     WRITE_LONG  0x84  "%amb_offset%"
   END
   PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
     "vars_offset"="%vars_offset%"+"%info_ext%"
     WRITE_LONG  0x88  "%vars_offset%"
   END
   PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
     "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
     WRITE_LONG  0xa0  "%expbmp_offset%"
   END
   PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
     "doors_offset"="%doors_offset%"+"%info_ext%"
     WRITE_LONG  0xa8  "%doors_offset%"
   END
   PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
     "anim_offset"="%anim_offset%"+"%info_ext%"
     WRITE_LONG  0xb0  "%anim_offset%"
   END
   PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
     "tiled_offset"="%tiled_offset%"+"%info_ext%"
     WRITE_LONG  0xb8  "%tiled_offset%"
   END
   PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
     "songs_offset"="%songs_offset%"+"%info_ext%"
     WRITE_LONG  0xbc  "%songs_offset%"
   END
   PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
     "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
     WRITE_LONG  0xc0  "%rest_spawns_offset%"
   END
   PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
     "automap_offset"="%automap_offset%"+"%info_ext%"
     WRITE_LONG  0xc4  "%automap_offset%"
   END

 END //main info_1
BUT_ONLY_IF_IT_CHANGES  //********************************************************  ~AR0907.are~


COPY_EXISTING ~AR0404.ARE~  ~override~
 READ_LONG  0x54  "actors_offset"
 READ_SHORT 0x58  "actors_num"
 READ_SHORT 0x5a  "infotrig_num"
 READ_LONG  0x5c  "infotrig_offset"
 READ_LONG  0x60  "spawns_offset"
 READ_LONG  0x64  "spawns_num"
 READ_LONG  0x68  "entrances_offset"
 READ_LONG  0x6c  "entrances_num"
 READ_LONG  0x70  "cont_offset"
 READ_SHORT 0x74  "cont_num"
 READ_SHORT 0x76  "items_num"
 READ_LONG  0x78  "items_offset"
 READ_LONG  0x7c  "vert_offset"
 READ_SHORT 0x80  "vert_num"
 READ_SHORT 0x82  "amb_num"
 READ_LONG  0x84  "amb_offset"
 READ_LONG  0x88  "vars_offset"
 READ_LONG  0x8c  "vars_num"
 READ_LONG  0xa0  "expbmp_offset"
 READ_LONG  0xa4  "doors_num"
 READ_LONG  0xa8  "doors_offset"
 READ_LONG  0xac  "anim_num"
 READ_LONG  0xb0  "anim_offset"
 READ_LONG  0xb4  "tiled_num"
 READ_LONG  0xb8  "tiled_offset"
 READ_LONG  0xbc  "songs_offset"
 READ_LONG  0xc0  "rest_spawns_offset"
 READ_LONG  0xc4  "automap_offset"
 READ_LONG  0xc8  "automap_num"

 SET info_1=0
 FOR( cnt=0; cnt<"%infotrig_num%"; cnt=cnt+1 ) BEGIN  //triggers loop
   READ_ASCII ("%infotrig_offset%"+0xc4*cnt)       "info_name"
   PATCH_IF (("%info_name%" STRING_COMPARE_CASE "Door0406")=0) BEGIN
     WRITE_ASCII ("%infotrig_offset%"+0xc4*cnt)      ~Door3576~
     WRITE_ASCII ("%infotrig_offset%"+0xc4*cnt+0x38) ~AR3576~
     WRITE_LONG  ("%infotrig_offset%"+0xc4*cnt+0x60) 0x00000104
     info_1=1
   END
 END

 PATCH_IF (info_1=1) BEGIN
//adding 2 new triggers  ***************************
   SET offset = ("%infotrig_offset%"+0xc4*"%infotrig_num%")
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~Info3576~
   WRITE_SHORT (offset+0x20) 1            //info trigger
   WRITE_SHORT (offset+0x22) 521          //bounding box
   WRITE_SHORT (offset+0x24) 26           //bounding box
   WRITE_SHORT (offset+0x26) 765          //bounding box
   WRITE_SHORT (offset+0x28) 253          //bounding box
   WRITE_SHORT (offset+0x2a) 4            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%" //first vertex index
   WRITE_LONG  (offset+0x34) 22           //cursor
   SAY         (offset+0x64) @218         //prompt string
   WRITE_SHORT (offset+0x70) 798          //Trap location X
   WRITE_SHORT (offset+0x72) 350          //Trap location Y
   SET offset = offset+0xc4
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~Trans0404~
   WRITE_SHORT (offset+0x20) 2            //travel trigger
   WRITE_SHORT (offset+0x22) 2462         //bounding box
   WRITE_SHORT (offset+0x24) 995          //bounding box
   WRITE_SHORT (offset+0x26) 2710         //bounding box
   WRITE_SHORT (offset+0x28) 1296         //bounding box
   WRITE_SHORT (offset+0x2a) 8            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%"+4 //first vertex index
   WRITE_LONG  (offset+0x34) 28           //cursor
   WRITE_ASCII (offset+0x38) ~AR0406~     //destination area
   WRITE_ASCII (offset+0x40) ~Exit0404~   //destination area's entrance name
   WRITE_LONG  (offset+0x60) 0x00000004   //flags - party required
   WRITE_SHORT (offset+0x70) 2586         //Trap location X
   WRITE_SHORT (offset+0x72) 1145         //Trap location Y
   SET "infotrig_num"="%infotrig_num%"+2
   WRITE_SHORT 0x5a  "%infotrig_num%"

 SET "info_ext"=0xc4*2
 PATCH_IF ("%actors_offset%">="%infotrig_offset%") BEGIN
   "actors_offset"="%actors_offset%"+"%info_ext%"
   WRITE_LONG  0x54 "%actors_offset%"
 END
 PATCH_IF ("%spawns_offset%">="%infotrig_offset%") BEGIN
   "spawns_offset"="%spawns_offset%"+"%info_ext%"
   WRITE_LONG  0x60  "%spawns_offset%"
 END
 PATCH_IF ("%entrances_offset%">="%infotrig_offset%") BEGIN
   "entrances_offset"="%entrances_offset%"+"%info_ext%"
   WRITE_LONG  0x68  "%entrances_offset%"
 END
 PATCH_IF ("%cont_offset%">="%infotrig_offset%") BEGIN
   "cont_offset"="%cont_offset%"+"%info_ext%"
   WRITE_LONG  0x70  "%cont_offset%"
 END
 PATCH_IF ("%items_offset%">="%infotrig_offset%") BEGIN
   "items_offset"="%items_offset%"+"%info_ext%"
   WRITE_LONG  0x78  "%items_offset%"
 END
 PATCH_IF ("%vert_offset%">="%infotrig_offset%") BEGIN
   "vert_offset"="%vert_offset%"+"%info_ext%"
   WRITE_LONG  0x7c  "%vert_offset%"
 END
 PATCH_IF ("%amb_offset%">="%infotrig_offset%") BEGIN
   "amb_offset"="%amb_offset%"+"%info_ext%"
   WRITE_LONG  0x84  "%amb_offset%"
 END
 PATCH_IF ("%vars_offset%">="%infotrig_offset%") BEGIN
   "vars_offset"="%vars_offset%"+"%info_ext%"
   WRITE_LONG  0x88  "%vars_offset%"
 END
 PATCH_IF ("%expbmp_offset%">="%infotrig_offset%") BEGIN
   "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
   WRITE_LONG  0xa0  "%expbmp_offset%"
 END
 PATCH_IF ("%doors_offset%">="%infotrig_offset%") BEGIN
   "doors_offset"="%doors_offset%"+"%info_ext%"
   WRITE_LONG  0xa8  "%doors_offset%"
 END
 PATCH_IF ("%anim_offset%">="%infotrig_offset%") BEGIN
   "anim_offset"="%anim_offset%"+"%info_ext%"
   WRITE_LONG  0xb0  "%anim_offset%"
 END
 PATCH_IF ("%tiled_offset%">="%infotrig_offset%") BEGIN
   "tiled_offset"="%tiled_offset%"+"%info_ext%"
   WRITE_LONG  0xb8  "%tiled_offset%"
 END
 PATCH_IF ("%songs_offset%">="%infotrig_offset%") BEGIN
   "songs_offset"="%songs_offset%"+"%info_ext%"
   WRITE_LONG  0xbc  "%songs_offset%"
 END
 PATCH_IF ("%rest_spawns_offset%">="%infotrig_offset%") BEGIN
   "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
   WRITE_LONG  0xc0  "%rest_spawns_offset%"
 END
 PATCH_IF ("%automap_offset%">="%infotrig_offset%") BEGIN
   "automap_offset"="%automap_offset%"+"%info_ext%"
   WRITE_LONG  0xc4  "%automap_offset%"
 END

 //adding 12 new vertices for triggers
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*4)
   WRITE_SHORT  offset      521
   WRITE_SHORT  (offset+2)  133
   WRITE_SHORT  (offset+4)  599
   WRITE_SHORT  (offset+6)  253
   WRITE_SHORT  (offset+8)  765
   WRITE_SHORT  (offset+10) 137
   WRITE_SHORT  (offset+12) 693
   WRITE_SHORT  (offset+14) 26
   SET offset = offset + 4*4
   INSERT_BYTES offset (0x04*8)
   WRITE_SHORT  offset      2462
   WRITE_SHORT  (offset+2)  1064
   WRITE_SHORT  (offset+4)  2495
   WRITE_SHORT  (offset+6)  1150
   WRITE_SHORT  (offset+8)  2554
   WRITE_SHORT  (offset+10) 1195
   WRITE_SHORT  (offset+12) 2578
   WRITE_SHORT  (offset+14) 1239
   WRITE_SHORT  (offset+16) 2594
   WRITE_SHORT  (offset+18) 1252
   WRITE_SHORT  (offset+20) 2705
   WRITE_SHORT  (offset+22) 1255
   WRITE_SHORT  (offset+24) 2710
   WRITE_SHORT  (offset+26) 1166
   WRITE_SHORT  (offset+28) 2463
   WRITE_SHORT  (offset+30) 995
   SET "vert_num"="%vert_num%"+12
   WRITE_SHORT 0x80  "%vert_num%"

 SET "info_ext"=0x04*12
 PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
   "actors_offset"="%actors_offset%"+"%info_ext%"
   WRITE_LONG  0x54 "%actors_offset%"
 END
 PATCH_IF ("%spawns_offset%">="%vert_offset%") BEGIN
   "spawns_offset"="%spawns_offset%"+"%info_ext%"
   WRITE_LONG  0x60  "%spawns_offset%"
 END
 PATCH_IF ("%entrances_offset%">="%vert_offset%") BEGIN
   "entrances_offset"="%entrances_offset%"+"%info_ext%"
   WRITE_LONG  0x68  "%entrances_offset%"
 END
 PATCH_IF ("%cont_offset%">="%vert_offset%") BEGIN
   "cont_offset"="%cont_offset%"+"%info_ext%"
   WRITE_LONG  0x70  "%cont_offset%"
 END
 PATCH_IF ("%items_offset%">="%vert_offset%") BEGIN
   "items_offset"="%items_offset%"+"%info_ext%"
   WRITE_LONG  0x78  "%items_offset%"
 END
 PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
   "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
   WRITE_LONG  0x5c  "%infotrig_offset%"
 END
 PATCH_IF ("%amb_offset%">="%vert_offset%") BEGIN
   "amb_offset"="%amb_offset%"+"%info_ext%"
   WRITE_LONG  0x84  "%amb_offset%"
 END
 PATCH_IF ("%vars_offset%">="%vert_offset%") BEGIN
   "vars_offset"="%vars_offset%"+"%info_ext%"
   WRITE_LONG  0x88  "%vars_offset%"
 END
 PATCH_IF ("%expbmp_offset%">="%vert_offset%") BEGIN
   "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
   WRITE_LONG  0xa0  "%expbmp_offset%"
 END
 PATCH_IF ("%doors_offset%">="%vert_offset%") BEGIN
   "doors_offset"="%doors_offset%"+"%info_ext%"
   WRITE_LONG  0xa8  "%doors_offset%"
 END
 PATCH_IF ("%anim_offset%">="%vert_offset%") BEGIN
   "anim_offset"="%anim_offset%"+"%info_ext%"
   WRITE_LONG  0xb0  "%anim_offset%"
 END
 PATCH_IF ("%tiled_offset%">="%vert_offset%") BEGIN
   "tiled_offset"="%tiled_offset%"+"%info_ext%"
   WRITE_LONG  0xb8  "%tiled_offset%"
 END
 PATCH_IF ("%songs_offset%">="%vert_offset%") BEGIN
   "songs_offset"="%songs_offset%"+"%info_ext%"
   WRITE_LONG  0xbc  "%songs_offset%"
 END
 PATCH_IF ("%rest_spawns_offset%">="%vert_offset%") BEGIN
   "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
   WRITE_LONG  0xc0  "%rest_spawns_offset%"
 END
 PATCH_IF ("%automap_offset%">="%vert_offset%") BEGIN
   "automap_offset"="%automap_offset%"+"%info_ext%"
   WRITE_LONG  0xc4  "%automap_offset%"
 END

 //adding 1 new entrance
 SET offset = ("%entrances_offset%"+0x68*"%entrances_num%")
 INSERT_BYTES offset 0x68
 WRITE_ASCII  offset      ~Exit3576~
 WRITE_SHORT  (offset+0x20)  753      //X
 WRITE_SHORT  (offset+0x22)  246      //Y
 SET "entrances_num"="%entrances_num%"+1
 WRITE_LONG 0x6c  "%entrances_num%"

 SET "info_ext"=0x68
 PATCH_IF ("%actors_offset%">="%entrances_offset%") BEGIN
   "actors_offset"="%actors_offset%"+"%info_ext%"
   WRITE_LONG  0x54 "%actors_offset%"
 END
 PATCH_IF ("%spawns_offset%">="%entrances_offset%") BEGIN
   "spawns_offset"="%spawns_offset%"+"%info_ext%"
   WRITE_LONG  0x60  "%spawns_offset%"
 END
 PATCH_IF ("%vert_offset%">="%entrances_offset%") BEGIN
   "vert_offset"="%vert_offset%"+"%info_ext%"
   WRITE_LONG  0x7c  "%vert_offset%"
 END
 PATCH_IF ("%cont_offset%">="%entrances_offset%") BEGIN
   "cont_offset"="%cont_offset%"+"%info_ext%"
   WRITE_LONG  0x70  "%cont_offset%"
 END
 PATCH_IF ("%items_offset%">="%entrances_offset%") BEGIN
   "items_offset"="%items_offset%"+"%info_ext%"
   WRITE_LONG  0x78  "%items_offset%"
 END
 PATCH_IF ("%infotrig_offset%">="%entrances_offset%") BEGIN
   "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
   WRITE_LONG  0x5c  "%infotrig_offset%"
 END
 PATCH_IF ("%amb_offset%">="%entrances_offset%") BEGIN
   "amb_offset"="%amb_offset%"+"%info_ext%"
   WRITE_LONG  0x84  "%amb_offset%"
 END
 PATCH_IF ("%vars_offset%">="%entrances_offset%") BEGIN
   "vars_offset"="%vars_offset%"+"%info_ext%"
   WRITE_LONG  0x88  "%vars_offset%"
 END
 PATCH_IF ("%expbmp_offset%">="%entrances_offset%") BEGIN
   "expbmp_offset"="%expbmp_offset%"+"%info_ext%"
   WRITE_LONG  0xa0  "%expbmp_offset%"
 END
 PATCH_IF ("%doors_offset%">="%entrances_offset%") BEGIN
   "doors_offset"="%doors_offset%"+"%info_ext%"
   WRITE_LONG  0xa8  "%doors_offset%"
 END
 PATCH_IF ("%anim_offset%">="%entrances_offset%") BEGIN
   "anim_offset"="%anim_offset%"+"%info_ext%"
   WRITE_LONG  0xb0  "%anim_offset%"
 END
 PATCH_IF ("%tiled_offset%">="%entrances_offset%") BEGIN
   "tiled_offset"="%tiled_offset%"+"%info_ext%"
   WRITE_LONG  0xb8  "%tiled_offset%"
 END
 PATCH_IF ("%songs_offset%">="%entrances_offset%") BEGIN
   "songs_offset"="%songs_offset%"+"%info_ext%"
   WRITE_LONG  0xbc  "%songs_offset%"
 END
 PATCH_IF ("%rest_spawns_offset%">="%entrances_offset%") BEGIN
   "rest_spawns_offset"="%rest_spawns_offset%"+"%info_ext%"
   WRITE_LONG  0xc0  "%rest_spawns_offset%"
 END
 PATCH_IF ("%automap_offset%">="%entrances_offset%") BEGIN
   "automap_offset"="%automap_offset%"+"%info_ext%"
   WRITE_LONG  0xc4  "%automap_offset%"
 END

 FOR( cnt=0; cnt<"%entrances_num%"; cnt=cnt+1 ) BEGIN  //entrances loop
   READ_ASCII ("%entrances_offset%"+0x68*cnt)       "entry_name" (8)
   PATCH_IF (("%entry_name%" STRING_COMPARE_CASE "Exit0406")=0) BEGIN
     WRITE_SHORT ("%entrances_offset%"+0x68*cnt+0x20) 2420
     WRITE_SHORT ("%entrances_offset%"+0x68*cnt+0x22) 1258
   END
 END

 END //main IF info_1
BUT_ONLY_IF_IT_CHANGES //********************************************************  ~AR0404.are~
//***********************************************************************************************************
//***********************************************************************************************************
//***********************************************************************************************************


//***********************************************************
//  RNDTREAS.2DA
//***********************************************************
PRINT ~Dealing with RNDTREAS.2DA ...~

COPY_EXISTING + ~SONGLIST.2DA~ ~override~ //just used as an external bracket for actions below
 SET next_idx_scroll = 0    //next vacant 2DA row index
 SET next_idx_weapon = 0    //----"----"----
 SET next_idx_magic = 0     //----"----"----
 SET next_idx_treas = 0     //----"----"----
 SET next_idx_equip = 0     //----"----"----
 SET available_scroll = 0   //a quantity of available free slots in 2DA
 SET available_weapon = 0   //----"----"----
 SET available_magic = 0    //----"----"----
 SET available_treas = 0    //----"----"----
 SET available_equip = 0    //----"----"----
 SPRINT name_6 ""           //destination names for our random items
 SPRINT name_7 ""
 SPRINT name_8 ""
 SPRINT name_9 ""
 SPRINT name_10 ""
 SPRINT name_11 ""
 SPRINT name_12 ""
 SPRINT name_13 ""
 SPRINT name_14 ""
 SET src_6 = 1      //1-RNDSCROL, 2-RNDWEP, 3-RNDMAGIC, 4-RNDTREAS, 5-RNDEQUIP
 SET src_7 = 1      //these vars indicate where should we append our 2DA rows
 SET src_8 = 1
 SET src_9 = 1
 SET src_10 = 1
 SET src_11 = 1
 SET src_12 = 1
 SET src_13 = 1
 SET src_14 = 1

 INNER_ACTION BEGIN
  //here we are obtaining starting vacant indexes and numbers of free slots from all 5 random tables
  COPY_EXISTING + ~RNDSCROL.2DA~ ~override~
                  ~RNDWEP.2DA~   ~override~
                  ~RNDMAGIC.2DA~ ~override~
                  ~RNDTREAS.2DA~ ~override~
                  ~RNDEQUIP.2DA~ ~override~
   SET rows=2
   SET rows_prev=0
   SET col_cnt=0
   WHILE "%rows%">1 BEGIN
     col_cnt += 1
     rows_prev = rows
     COUNT_2DA_ROWS col_cnt rows
   END
   col_cnt = col_cnt - 1

   PATCH_IF( ("%SOURCE_RES%" STRING_COMPARE_CASE "RNDSCROL")=0 ) BEGIN
     SET next_idx_scroll = rows_prev+1
     PATCH_IF( next_idx_scroll<=9 ) BEGIN
       SET available_scroll = 10 - next_idx_scroll
     END
   END
   PATCH_IF( ("%SOURCE_RES%" STRING_COMPARE_CASE "RNDWEP")=0 ) BEGIN
     SET next_idx_weapon = rows_prev+1
     PATCH_IF( next_idx_weapon<=9 ) BEGIN
       SET available_weapon = 10 - next_idx_weapon
     END
   END
   PATCH_IF( ("%SOURCE_RES%" STRING_COMPARE_CASE "RNDMAGIC")=0 ) BEGIN
     SET next_idx_magic = rows_prev+1
     PATCH_IF( next_idx_magic<=9 ) BEGIN
       SET available_magic = 10 - next_idx_magic
     END
   END
   PATCH_IF( ("%SOURCE_RES%" STRING_COMPARE_CASE "RNDTREAS")=0 ) BEGIN
     SET next_idx_treas = rows_prev+1
     PATCH_IF( next_idx_treas<=9 ) BEGIN
       SET available_treas = 10 - next_idx_treas
     END
   END
   PATCH_IF( ("%SOURCE_RES%" STRING_COMPARE_CASE "RNDEQUIP")=0 ) BEGIN
     SET next_idx_equip = rows_prev+1
     PATCH_IF( next_idx_equip<=9 ) BEGIN
       SET available_equip = 10 - next_idx_equip
     END
   END
 END //INNER_ACTION


 FOR(i=6; i<=14; i+=1) BEGIN    //it is RNDTRE06-14.ITM that need to be replaced with new names
    //what item should we currently work with
    PATCH_IF(i<10) BEGIN
      SPRINT src_name "RNDTRE0%i%.ITM"
    END
    ELSE BEGIN
      SPRINT src_name "RNDTRE%i%.ITM"
    END
    //now we need to determine where and under what name the item will go
    PATCH_IF( available_scroll>0 ) BEGIN
      SPRINT name "RNDSCR0%next_idx_scroll%.ITM"
      SPRINT name_n "RNDSC_0%next_idx_scroll%"
      SET next_idx_scroll = next_idx_scroll + 1
      SET available_scroll = available_scroll - 1
      PATCH_IF(i=6) BEGIN SET src_6 = 1 END
      ELSE BEGIN PATCH_IF(i=7) BEGIN SET src_7 = 1 END
      ELSE BEGIN PATCH_IF(i=8) BEGIN SET src_8 = 1 END
      ELSE BEGIN PATCH_IF(i=9) BEGIN SET src_9 = 1 END
      ELSE BEGIN PATCH_IF(i=10) BEGIN SET src_10 = 1 END
      ELSE BEGIN PATCH_IF(i=11) BEGIN SET src_11 = 1 END
      ELSE BEGIN PATCH_IF(i=12) BEGIN SET src_12 = 1 END
      ELSE BEGIN PATCH_IF(i=13) BEGIN SET src_13 = 1 END
      ELSE BEGIN PATCH_IF(i=14) BEGIN SET src_14 = 1 END END END END END END END END END
    END
    ELSE BEGIN PATCH_IF( available_weapon>0 ) BEGIN
      SPRINT name "RNDWEP0%next_idx_weapon%.ITM"
      SPRINT name_n "RNDWE_0%next_idx_weapon%"
      SET next_idx_weapon = next_idx_weapon + 1
      SET available_weapon = available_weapon - 1
      PATCH_IF(i=6) BEGIN SET src_6 = 2 END
      ELSE BEGIN PATCH_IF(i=7) BEGIN SET src_7 = 2 END
      ELSE BEGIN PATCH_IF(i=8) BEGIN SET src_8 = 2 END
      ELSE BEGIN PATCH_IF(i=9) BEGIN SET src_9 = 2 END
      ELSE BEGIN PATCH_IF(i=10) BEGIN SET src_10 = 2 END
      ELSE BEGIN PATCH_IF(i=11) BEGIN SET src_11 = 2 END
      ELSE BEGIN PATCH_IF(i=12) BEGIN SET src_12 = 2 END
      ELSE BEGIN PATCH_IF(i=13) BEGIN SET src_13 = 2 END
      ELSE BEGIN PATCH_IF(i=14) BEGIN SET src_14 = 2 END END END END END END END END END
    END
    ELSE BEGIN PATCH_IF( available_magic>0 ) BEGIN
      SPRINT name "RNDMAG0%next_idx_magic%.ITM"
      SPRINT name_n "RNDMA_0%next_idx_magic%"
      SET next_idx_magic = next_idx_magic + 1
      SET available_magic = available_magic - 1
      PATCH_IF(i=6) BEGIN SET src_6 = 3 END
      ELSE BEGIN PATCH_IF(i=7) BEGIN SET src_7 = 3 END
      ELSE BEGIN PATCH_IF(i=8) BEGIN SET src_8 = 3 END
      ELSE BEGIN PATCH_IF(i=9) BEGIN SET src_9 = 3 END
      ELSE BEGIN PATCH_IF(i=10) BEGIN SET src_10 = 3 END
      ELSE BEGIN PATCH_IF(i=11) BEGIN SET src_11 = 3 END
      ELSE BEGIN PATCH_IF(i=12) BEGIN SET src_12 = 3 END
      ELSE BEGIN PATCH_IF(i=13) BEGIN SET src_13 = 3 END
      ELSE BEGIN PATCH_IF(i=14) BEGIN SET src_14 = 3 END END END END END END END END END
    END
    ELSE BEGIN PATCH_IF( available_treas>0 ) BEGIN
      SPRINT name "RNDTRE0%next_idx_treas%.ITM"
      SPRINT name_n "RNDTR_0%next_idx_treas%"
      SET next_idx_treas = next_idx_treas + 1
      SET available_treas = available_treas - 1
      PATCH_IF(i=6) BEGIN SET src_6 = 4 END
      ELSE BEGIN PATCH_IF(i=7) BEGIN SET src_7 = 4 END
      ELSE BEGIN PATCH_IF(i=8) BEGIN SET src_8 = 4 END
      ELSE BEGIN PATCH_IF(i=9) BEGIN SET src_9 = 4 END
      ELSE BEGIN PATCH_IF(i=10) BEGIN SET src_10 = 4 END
      ELSE BEGIN PATCH_IF(i=11) BEGIN SET src_11 = 4 END
      ELSE BEGIN PATCH_IF(i=12) BEGIN SET src_12 = 4 END
      ELSE BEGIN PATCH_IF(i=13) BEGIN SET src_13 = 4 END
      ELSE BEGIN PATCH_IF(i=14) BEGIN SET src_14 = 4 END END END END END END END END END
    END
    ELSE BEGIN PATCH_IF( available_equip>0 ) BEGIN
      SPRINT name "RNDEQU0%next_idx_equip%.ITM"
      SPRINT name_n "RNDEQ_0%next_idx_equip%"
      SET next_idx_equip = next_idx_equip + 1
      SET available_equip = available_equip - 1
      PATCH_IF(i=6) BEGIN SET src_6 = 5 END
      ELSE BEGIN PATCH_IF(i=7) BEGIN SET src_7 = 5 END
      ELSE BEGIN PATCH_IF(i=8) BEGIN SET src_8 = 5 END
      ELSE BEGIN PATCH_IF(i=9) BEGIN SET src_9 = 5 END
      ELSE BEGIN PATCH_IF(i=10) BEGIN SET src_10 = 5 END
      ELSE BEGIN PATCH_IF(i=11) BEGIN SET src_11 = 5 END
      ELSE BEGIN PATCH_IF(i=12) BEGIN SET src_12 = 5 END
      ELSE BEGIN PATCH_IF(i=13) BEGIN SET src_13 = 5 END
      ELSE BEGIN PATCH_IF(i=14) BEGIN SET src_14 = 5 END END END END END END END END END
    END
    END //ELSE 4
    END //ELSE 3
    END //ELSE 2
    END //ELSE 1

    PATCH_PRINT "%src_name%"^" --> "^"%name%"

    INNER_ACTION BEGIN
      COPY ~CtB/items/rndtre/RNDTRE.ITM~ ~override/%name%~
    END

    PATCH_IF(i=6) BEGIN
      SPRINT name_6 "%name_n%"
    END
    PATCH_IF(i=7) BEGIN
      SPRINT name_7 "%name_n%"
    END
    PATCH_IF(i=8) BEGIN
      SPRINT name_8 "%name_n%"
    END
    PATCH_IF(i=9) BEGIN
      SPRINT name_9 "%name_n%"
    END
    PATCH_IF(i=10) BEGIN
      SPRINT name_10 "%name_n%"
    END
    PATCH_IF(i=11) BEGIN
      SPRINT name_11 "%name_n%"
    END
    PATCH_IF(i=12) BEGIN
      SPRINT name_12 "%name_n%"
    END
    PATCH_IF(i=13) BEGIN
      SPRINT name_13 "%name_n%"
    END
    PATCH_IF(i=14) BEGIN
      SPRINT name_14 "%name_n%"
    END
  END  //FOR loop




  INNER_ACTION BEGIN
   //here we need to patch every appearance of old RNDTRE_ name with the new one
   COPY_EXISTING ~AR3541.ARE~ ~override~
              ~AR3542.ARE~ ~override~
              ~AR3544.ARE~ ~override~
              ~AR3545.ARE~ ~override~
              ~AR3546.ARE~ ~override~
              ~AR3547.ARE~ ~override~
              ~AR3549.ARE~ ~override~
              ~AR3551.ARE~ ~override~
              ~AR3552.ARE~ ~override~
              ~AR3553.ARE~ ~override~
              ~AR3554.ARE~ ~override~
              ~AR3556.ARE~ ~override~
              ~AR3559.ARE~ ~override~
              ~AR3610.ARE~ ~override~
              ~AR3611.ARE~ ~override~
              ~AR3613.ARE~ ~override~
              ~AR3615.ARE~ ~override~
              ~AR3616.ARE~ ~override~
              ~AR3617.ARE~ ~override~
              ~AR3620.ARE~ ~override~
              ~AR3621.ARE~ ~override~
              ~AR3622.ARE~ ~override~
              ~AR3623.ARE~ ~override~
              ~AR3624.ARE~ ~override~
              ~AR3625.ARE~ ~override~
              ~AR3626.ARE~ ~override~
              ~AR3627.ARE~ ~override~
              ~AR3628.ARE~ ~override~
              ~AR3629.ARE~ ~override~
              ~AR3630.ARE~ ~override~
              ~AR3631.ARE~ ~override~
              ~AR3632.ARE~ ~override~
              ~AR3633.ARE~ ~override~
              ~AR3634.ARE~ ~override~
              ~AR3637.ARE~ ~override~
              ~AR3638.ARE~ ~override~
              ~AR3640.ARE~ ~override~
              ~AR3641.ARE~ ~override~
              ~AR3642.ARE~ ~override~
              ~AR3643.ARE~ ~override~
              ~AR3644.ARE~ ~override~
              ~AR3645.ARE~ ~override~
              ~AR3646.ARE~ ~override~
              ~AR3647.ARE~ ~override~
              ~AR3648.ARE~ ~override~
              ~AR3649.ARE~ ~override~
              ~AR3650.ARE~ ~override~
              ~AR3652.ARE~ ~override~
              ~AR3653.ARE~ ~override~

              ~CB3651IN.CRE~ ~override~
              ~CBGRDYUO.BCS~ ~override~
              ~CBYT4446.BCS~ ~override~
              ~CBYT4447.BCS~ ~override~

              ~CBHLD00A.BCS~ ~override~
              ~CBHLD00D.BCS~ ~override~
              ~CBHLD00E.BCS~ ~override~

              ~CBZOMB02.CRE~ ~override~
              ~CBZOMBD2.CRE~ ~override~
              ~CBZOMB04.SPL~ ~override~
              ~CBZOMB07.BCS~ ~override~
              ~CBZOMB08.BCS~ ~override~
              ~CBZOMB0C.BCS~ ~override~

      REPLACE_TEXTUALLY "RNDTRE14" "%name_14%"
      REPLACE_TEXTUALLY "RNDTRE13" "%name_13%"
      REPLACE_TEXTUALLY "RNDTRE12" "%name_12%"
      REPLACE_TEXTUALLY "RNDTRE11" "%name_11%"
      REPLACE_TEXTUALLY "RNDTRE10" "%name_10%"
      REPLACE_TEXTUALLY "RNDTRE09" "%name_9%"
      REPLACE_TEXTUALLY "RNDTRE08" "%name_8%"
      REPLACE_TEXTUALLY "RNDTRE07" "%name_7%"
      REPLACE_TEXTUALLY "RNDTRE06" "%name_6%"
      REPLACE_TEXTUALLY "RNDSC_" "RNDSCR"
      REPLACE_TEXTUALLY "RNDWE_" "RNDWEP"
      REPLACE_TEXTUALLY "RNDMA_" "RNDMAG"
      REPLACE_TEXTUALLY "RNDTR_" "RNDTRE"
      REPLACE_TEXTUALLY "RNDEQ_" "RNDEQU"
   BUT_ONLY_IF_IT_CHANGES
END

//now we only have to add new 2DA rows properly
ACTION_IF( src_6=1 ) THEN BEGIN
 APPEND ~RNDSCROL.2DA~  //21 columns
 ~CTBRND01   POTN03   POTN05   POTN07   POTN09   POTN11   POTN13  POTN15  POTN17  POTN19   POTN21   POTN23   POTN25   POTN27   POTN29   POTN31   POTN33   POTN35   POTN37   POTN39  POTN39~
END
ELSE BEGIN
ACTION_IF( src_6=2 ) THEN BEGIN
 APPEND ~RNDWEP.2DA~   //21 columns
 ~CTBRND01   POTN03   POTN05   POTN07   POTN09   POTN11   POTN13  POTN15  POTN17  POTN19   POTN21   POTN23   POTN25   POTN27   POTN29   POTN31   POTN33   POTN35   POTN37   POTN39  POTN39~
END
ELSE BEGIN
ACTION_IF( src_6=3 ) THEN BEGIN
 APPEND ~RNDMAGIC.2DA~ //20 columns
 ~CTBRND01   POTN03   POTN05   POTN07   POTN09   POTN11   POTN13  POTN15  POTN17  POTN19   POTN21   POTN23   POTN25   POTN27   POTN29   POTN31   POTN33   POTN35   POTN37   POTN39~
END
ELSE BEGIN
ACTION_IF( src_6=4 ) THEN BEGIN
 APPEND ~RNDTREAS.2DA~  //20 columns
 ~CTBRND01   POTN03   POTN05   POTN07   POTN09   POTN11   POTN13  POTN15  POTN17  POTN19   POTN21   POTN23   POTN25   POTN27   POTN29   POTN31   POTN33   POTN35   POTN37   POTN39~
END
ELSE BEGIN
ACTION_IF( src_6=5 ) THEN BEGIN
 APPEND ~RNDEQUIP.2DA~  //21 columns
 ~CTBRND01   POTN03   POTN05   POTN07   POTN09   POTN11   POTN13  POTN15  POTN17  POTN19   POTN21   POTN23   POTN25   POTN27   POTN29   POTN31   POTN33   POTN35   POTN37   POTN39  POTN39~
END END END END END



ACTION_IF( src_7=1 ) THEN BEGIN
 APPEND ~RNDSCROL.2DA~  //21 columns
 ~CTBRND02   SCRL1B   SCRL6F   SCRL5K   SCRL6R   SCRL7U   SCRL8W  SCRL9Z  SCRLAR  SCRL9Q   SCRL8N   SCRL7K   SCRL6I   SCRL5B   SCRL2E   SCRL10   SCRL15   SCRL8G   SCRL5G   SCRL6N  SCRL6N~
END
ELSE BEGIN
ACTION_IF( src_7=2 ) THEN BEGIN
 APPEND ~RNDWEP.2DA~   //21 columns
 ~CTBRND02   SCRL1B   SCRL6F   SCRL5K   SCRL6R   SCRL7U   SCRL8W  SCRL9Z  SCRLAR  SCRL9Q   SCRL8N   SCRL7K   SCRL6I   SCRL5B   SCRL2E   SCRL10   SCRL15   SCRL8G   SCRL5G   SCRL6N  SCRL6N~
END
ELSE BEGIN
ACTION_IF( src_7=3 ) THEN BEGIN
 APPEND ~RNDMAGIC.2DA~ //20 columns
 ~CTBRND02   SCRL1B   SCRL6F   SCRL5K   SCRL6R   SCRL7U   SCRL8W  SCRL9Z  SCRLAR  SCRL9Q   SCRL8N   SCRL7K   SCRL6I   SCRL5B   SCRL2E   SCRL10   SCRL15   SCRL8G   SCRL5G   SCRL6N~
END
ELSE BEGIN
ACTION_IF( src_7=4 ) THEN BEGIN
 APPEND ~RNDTREAS.2DA~  //20 columns
 ~CTBRND02   SCRL1B   SCRL6F   SCRL5K   SCRL6R   SCRL7U   SCRL8W  SCRL9Z  SCRLAR  SCRL9Q   SCRL8N   SCRL7K   SCRL6I   SCRL5B   SCRL2E   SCRL10   SCRL15   SCRL8G   SCRL5G   SCRL6N~
END
ELSE BEGIN
ACTION_IF( src_7=5 ) THEN BEGIN
 APPEND ~RNDEQUIP.2DA~  //21 columns
 ~CTBRND02   SCRL1B   SCRL6F   SCRL5K   SCRL6R   SCRL7U   SCRL8W  SCRL9Z  SCRLAR  SCRL9Q   SCRL8N   SCRL7K   SCRL6I   SCRL5B   SCRL2E   SCRL10   SCRL15   SCRL8G   SCRL5G   SCRL6N  SCRL6N~
END END END END END



ACTION_IF( src_8=1 ) THEN BEGIN
 APPEND ~RNDSCROL.2DA~  //21 columns
 ~CTBRND03   RING06   RING21   RING27   RING34   WAND03   WAND06  WAND11  RODS03  AMUL08   BELT09   BOOK05   BRAC09   POTN55   001      002      003      004      005      006     007~
END
ELSE BEGIN
ACTION_IF( src_8=2 ) THEN BEGIN
 APPEND ~RNDWEP.2DA~   //21 columns
 ~CTBRND03   RING06   RING21   RING27   RING34   WAND03   WAND06  WAND11  RODS03  AMUL08   BELT09   BOOK05   BRAC09   POTN55   001      002      003      004      005      006     007~
END
ELSE BEGIN
ACTION_IF( src_8=3 ) THEN BEGIN
 APPEND ~RNDMAGIC.2DA~ //20 columns
 ~CTBRND03   RING06   RING21   RING27   RING34   WAND03   WAND06  WAND11  RODS03  AMUL08   BELT09   BOOK05   BRAC09   POTN55   001      002      003      004      005      006~
END
ELSE BEGIN
ACTION_IF( src_8=4 ) THEN BEGIN
 APPEND ~RNDTREAS.2DA~  //20 columns
 ~CTBRND03   RING06   RING21   RING27   RING34   WAND03   WAND06  WAND11  RODS03  AMUL08   BELT09   BOOK05   BRAC09   POTN55   001      002      003      004      005      006~
END
ELSE BEGIN
ACTION_IF( src_8=5 ) THEN BEGIN
 APPEND ~RNDEQUIP.2DA~  //21 columns
 ~CTBRND03   RING06   RING21   RING27   RING34   WAND03   WAND06  WAND11  RODS03  AMUL08   BELT09   BOOK05   BRAC09   POTN55   001      002      003      004      005      006     007~
END END END END END



ACTION_IF( src_9=1 ) THEN BEGIN
 APPEND ~RNDSCROL.2DA~  //21 columns
 ~CTBRND04   MISC19   MISC20   MISC22   MISC24   MISC26   MISC29  MISC30  MISC36  MISC45   LEAT01   PLAT01   HELM08   BRAC03   SHLD08   HELM19   HELM13   PLAT05   LEAT15   CHAN21  CHAN21~
END
ELSE BEGIN
ACTION_IF( src_9=2 ) THEN BEGIN
 APPEND ~RNDWEP.2DA~   //21 columns
 ~CTBRND04   MISC19   MISC20   MISC22   MISC24   MISC26   MISC29  MISC30  MISC36  MISC45   LEAT01   PLAT01   HELM08   BRAC03   SHLD08   HELM19   HELM13   PLAT05   LEAT15   CHAN21  CHAN21~
END
ELSE BEGIN
ACTION_IF( src_9=3 ) THEN BEGIN
 APPEND ~RNDMAGIC.2DA~ //20 columns
 ~CTBRND04   MISC19   MISC20   MISC22   MISC24   MISC26   MISC29  MISC30  MISC36  MISC45   LEAT01   PLAT01   HELM08   BRAC03   SHLD08   HELM19   HELM13   PLAT05   LEAT15   CHAN21~
END
ELSE BEGIN
ACTION_IF( src_9=4 ) THEN BEGIN
 APPEND ~RNDTREAS.2DA~  //20 columns
 ~CTBRND04   MISC19   MISC20   MISC22   MISC24   MISC26   MISC29  MISC30  MISC36  MISC45   LEAT01   PLAT01   HELM08   BRAC03   SHLD08   HELM19   HELM13   PLAT05   LEAT15   CHAN21~
END
ELSE BEGIN
ACTION_IF( src_9=5 ) THEN BEGIN
 APPEND ~RNDEQUIP.2DA~  //21 columns
 ~CTBRND04   MISC19   MISC20   MISC22   MISC24   MISC26   MISC29  MISC30  MISC36  MISC45   LEAT01   PLAT01   HELM08   BRAC03   SHLD08   HELM19   HELM13   PLAT05   LEAT15   CHAN21  CHAN21~
END END END END END



ACTION_IF( src_10=1 ) THEN BEGIN
 APPEND ~RNDSCROL.2DA~  //21 columns
 ~CTBRND05   HELM15   MISC18   MISC56   MISC7R   HALB10   BRAC25  HELM15  MISC18  MISC56   HELM10   SHLD01   BRAC15   CHAN02   XBOW08   LEAT01   SHLD15   HELM09   SHLD23   SHLD12  SHLD12~
END
ELSE BEGIN
ACTION_IF( src_10=2 ) THEN BEGIN
 APPEND ~RNDWEP.2DA~   //21 columns
 ~CTBRND05   HELM15   MISC18   MISC56   MISC7R   HALB10   BRAC25  HELM15  MISC18  MISC56   HELM10   SHLD01   BRAC15   CHAN02   XBOW08   LEAT01   SHLD15   HELM09   SHLD23   SHLD12  SHLD12~
END
ELSE BEGIN
ACTION_IF( src_10=3 ) THEN BEGIN
 APPEND ~RNDMAGIC.2DA~ //20 columns
 ~CTBRND05   HELM15   MISC18   MISC56   MISC7R   HALB10   BRAC25  HELM15  MISC18  MISC56   HELM10   SHLD01   BRAC15   CHAN02   XBOW08   LEAT01   SHLD15   HELM09   SHLD23   SHLD12~
END
ELSE BEGIN
ACTION_IF( src_10=4 ) THEN BEGIN
 APPEND ~RNDTREAS.2DA~  //20 columns
 ~CTBRND05   HELM15   MISC18   MISC56   MISC7R   HALB10   BRAC25  HELM15  MISC18  MISC56   HELM10   SHLD01   BRAC15   CHAN02   XBOW08   LEAT01   SHLD15   HELM09   SHLD23   SHLD12~
END
ELSE BEGIN
ACTION_IF( src_10=5 ) THEN BEGIN
 APPEND ~RNDEQUIP.2DA~  //21 columns
 ~CTBRND05   HELM15   MISC18   MISC56   MISC7R   HALB10   BRAC25  HELM15  MISC18  MISC56   HELM10   SHLD01   BRAC15   CHAN02   XBOW08   LEAT01   SHLD15   HELM09   SHLD23   SHLD12  SHLD12~
END END END END END



ACTION_IF( src_11=1 ) THEN BEGIN
 APPEND ~RNDSCROL.2DA~  //21 columns
 ~CTBRND06   MISC56   SW1H70   MISC57   SHLD31   MISC58   BOOT01  MISC59  HELM15  MISC18   MISC56   SHLD18   CHAN05   PLAT08   PLAT01   HELM11   SHLD04   CLCK31   SHLD03   HELM12  HELM12~
END
ELSE BEGIN
ACTION_IF( src_11=2 ) THEN BEGIN
 APPEND ~RNDWEP.2DA~   //21 columns
 ~CTBRND06   MISC56   SW1H70   MISC57   SHLD31   MISC58   BOOT01  MISC59  HELM15  MISC18   MISC56   SHLD18   CHAN05   PLAT08   PLAT01   HELM11   SHLD04   CLCK31   SHLD03   HELM12  HELM12~
END
ELSE BEGIN
ACTION_IF( src_11=3 ) THEN BEGIN
 APPEND ~RNDMAGIC.2DA~ //20 columns
 ~CTBRND06   MISC56   SW1H70   MISC57   SHLD31   MISC58   BOOT01  MISC59  HELM15  MISC18   MISC56   SHLD18   CHAN05   PLAT08   PLAT01   HELM11   SHLD04   CLCK31   SHLD03   HELM12~
END
ELSE BEGIN
ACTION_IF( src_11=4 ) THEN BEGIN
 APPEND ~RNDTREAS.2DA~  //20 columns
 ~CTBRND06   MISC56   SW1H70   MISC57   SHLD31   MISC58   BOOT01  MISC59  HELM15  MISC18   MISC56   SHLD18   CHAN05   PLAT08   PLAT01   HELM11   SHLD04   CLCK31   SHLD03   HELM12~
END
ELSE BEGIN
ACTION_IF( src_11=5 ) THEN BEGIN
 APPEND ~RNDEQUIP.2DA~  //21 columns
 ~CTBRND06   MISC56   SW1H70   MISC57   SHLD31   MISC58   BOOT01  MISC59  HELM15  MISC18   MISC56   SHLD18   CHAN05   PLAT08   PLAT01   HELM11   SHLD04   CLCK31   SHLD03   HELM12  HELM12~
END END END END END



ACTION_IF( src_12=1 ) THEN BEGIN
 APPEND ~RNDSCROL.2DA~  //21 columns
 ~CTBRND07   STAF01   AX1H17   BLUN07   SPER01   HALB01   AX1H03  HAMM02  DAGG01  SW2H11   HALB07   SW1H73   SW1H01   BOW01    AX1H03   BLUN07   SPER01   STAF18   BLUN02   SW2H11  SW2H11~
END
ELSE BEGIN
ACTION_IF( src_12=2 ) THEN BEGIN
 APPEND ~RNDWEP.2DA~   //21 columns
 ~CTBRND07   STAF01   AX1H17   BLUN07   SPER01   HALB01   AX1H03  HAMM02  DAGG01  SW2H11   HALB07   SW1H73   SW1H01   BOW01    AX1H03   BLUN07   SPER01   STAF18   BLUN02   SW2H11  SW2H11~
END
ELSE BEGIN
ACTION_IF( src_12=3 ) THEN BEGIN
 APPEND ~RNDMAGIC.2DA~ //20 columns
 ~CTBRND07   STAF01   AX1H17   BLUN07   SPER01   HALB01   AX1H03  HAMM02  DAGG01  SW2H11   HALB07   SW1H73   SW1H01   BOW01    AX1H03   BLUN07   SPER01   STAF18   BLUN02   SW2H11~
END
ELSE BEGIN
ACTION_IF( src_12=4 ) THEN BEGIN
 APPEND ~RNDTREAS.2DA~  //20 columns
 ~CTBRND07   STAF01   AX1H17   BLUN07   SPER01   HALB01   AX1H03  HAMM02  DAGG01  SW2H11   HALB07   SW1H73   SW1H01   BOW01    AX1H03   BLUN07   SPER01   STAF18   BLUN02   SW2H11~
END
ELSE BEGIN
ACTION_IF( src_12=5 ) THEN BEGIN
 APPEND ~RNDEQUIP.2DA~  //21 columns
 ~CTBRND07   STAF01   AX1H17   BLUN07   SPER01   HALB01   AX1H03  HAMM02  DAGG01  SW2H11   HALB07   SW1H73   SW1H01   BOW01    AX1H03   BLUN07   SPER01   STAF18   BLUN02   SW2H11  SW2H11~
END END END END END



ACTION_IF( src_13=1 ) THEN BEGIN
 APPEND ~RNDSCROL.2DA~  //21 columns
 ~CTBRND08   BLUN02   BOW05    AX1H03   STAF01   SW1H02   SPER01  SW1H07  BOW01   BOW05    SW2H11   BLUN07   BOW25    DAGG01   BLUN02   BOW05    SW1H05   SPER01   SW1H08   HALB01  HALB01~
END
ELSE BEGIN
ACTION_IF( src_13=2 ) THEN BEGIN
 APPEND ~RNDWEP.2DA~   //21 columns
 ~CTBRND08   BLUN02   BOW05    AX1H03   STAF01   SW1H02   SPER01  SW1H07  BOW01   BOW05    SW2H11   BLUN07   BOW25    DAGG01   BLUN02   BOW05    SW1H05   SPER01   SW1H08   HALB01  HALB01~
END
ELSE BEGIN
ACTION_IF( src_13=3 ) THEN BEGIN
 APPEND ~RNDMAGIC.2DA~ //20 columns
 ~CTBRND08   BLUN02   BOW05    AX1H03   STAF01   SW1H02   SPER01  SW1H07  BOW01   BOW05    SW2H11   BLUN07   BOW25    DAGG01   BLUN02   BOW05    SW1H05   SPER01   SW1H08   HALB01~
END
ELSE BEGIN
ACTION_IF( src_13=4 ) THEN BEGIN
 APPEND ~RNDTREAS.2DA~  //20 columns
 ~CTBRND08   BLUN02   BOW05    AX1H03   STAF01   SW1H02   SPER01  SW1H07  BOW01   BOW05    SW2H11   BLUN07   BOW25    DAGG01   BLUN02   BOW05    SW1H05   SPER01   SW1H08   HALB01~
END
ELSE BEGIN
ACTION_IF( src_13=5 ) THEN BEGIN
 APPEND ~RNDEQUIP.2DA~  //21 columns
 ~CTBRND08   BLUN02   BOW05    AX1H03   STAF01   SW1H02   SPER01  SW1H07  BOW01   BOW05    SW2H11   BLUN07   BOW25    DAGG01   BLUN02   BOW05    SW1H05   SPER01   SW1H08   HALB01  HALB01~
END END END END END



ACTION_IF( src_14=1 ) THEN BEGIN
 APPEND ~RNDSCROL.2DA~  //21 columns
 ~CTBRND09   SW2H20   DAGG01   SW2H11   BOW01    SW1H04   BLUN32  DAGG24  HAMM12  BLUN02   SPER01   BOW05    AX1H03   STAF01   HALB01   SW2H11   SPER06   DAGG01   HAMM02   BLUN07  BLUN07~
END
ELSE BEGIN
ACTION_IF( src_14=2 ) THEN BEGIN
 APPEND ~RNDWEP.2DA~   //21 columns
 ~CTBRND09   SW2H20   DAGG01   SW2H11   BOW01    SW1H04   BLUN32  DAGG24  HAMM12  BLUN02   SPER01   BOW05    AX1H03   STAF01   HALB01   SW2H11   SPER06   DAGG01   HAMM02   BLUN07  BLUN07~
END
ELSE BEGIN
ACTION_IF( src_14=3 ) THEN BEGIN
 APPEND ~RNDMAGIC.2DA~ //20 columns
 ~CTBRND09   SW2H20   DAGG01   SW2H11   BOW01    SW1H04   BLUN32  DAGG24  HAMM12  BLUN02   SPER01   BOW05    AX1H03   STAF01   HALB01   SW2H11   SPER06   DAGG01   HAMM02   BLUN07~
END
ELSE BEGIN
ACTION_IF( src_14=4 ) THEN BEGIN
 APPEND ~RNDTREAS.2DA~  //20 columns
 ~CTBRND09   SW2H20   DAGG01   SW2H11   BOW01    SW1H04   BLUN32  DAGG24  HAMM12  BLUN02   SPER01   BOW05    AX1H03   STAF01   HALB01   SW2H11   SPER06   DAGG01   HAMM02   BLUN07~
END
ELSE BEGIN
ACTION_IF( src_14=5 ) THEN BEGIN
 APPEND ~RNDEQUIP.2DA~  //21 columns
 ~CTBRND09   SW2H20   DAGG01   SW2H11   BOW01    SW1H04   BLUN32  DAGG24  HAMM12  BLUN02   SPER01   BOW05    AX1H03   STAF01   HALB01   SW2H11   SPER06   DAGG01   HAMM02   BLUN07  BLUN07~
END END END END END


//***********************************************************
//  Worldmap
//***********************************************************
PRINT ~Updating Worldmap...~

ACTION_IF FILE_EXISTS ~Worldmap/map_mods_areas.tbl~ THEN BEGIN
  COPY ~Worldmap/map_mods_areas.tbl~  ~Worldmap~
   APPEND_FILE ~CtB/Worldmap/areas.tbl~

  COPY ~Worldmap/map_mods_links.tbl~  ~Worldmap~
   APPEND_FILE ~CtB/Worldmap/links.tbl~
   PATCH_IF (FILE_EXISTS ~data/ROT-RULE.BIF~) BEGIN
     APPEND_FILE ~CtB/Worldmap/rot_links.tbl~
   END
   PATCH_IF (FILE_EXISTS ~data/TDD-RULE.BIF~) BEGIN
     APPEND_FILE ~CtB/Worldmap/tdd_links.tbl~
   END
   PATCH_IF (FILE_EXISTS ~data/SOS-RULE.BIF~) BEGIN
     APPEND_FILE ~CtB/Worldmap/sos_links.tbl~
   END

  //preliminary step - making LANGUAGE temporary file until the new WeiDU
  COPY - ~CtB/Worldmap/%LANGUAGE%/worldmap.tra~  ~tmp_worldmap.tra~
  COPY ~Worldmap/map_mods_trans.tra~  ~Worldmap~
   APPEND_FILE ~tmp_worldmap.tra~

  ACTION_IF FILE_EXISTS ~Worldmap/map_mods_links_patch.tbl~ THEN BEGIN
    COPY ~Worldmap/map_mods_links_patch.tbl~  ~Worldmap~
     APPEND_FILE ~CtB/Worldmap/links_patch.tbl~
  END ELSE BEGIN
    COPY ~CtB/Worldmap/links_patch.tbl~ ~Worldmap/map_mods_links_patch.tbl~
  END
END
ELSE BEGIN
  MKDIR ~Worldmap~
  COPY ~CtB/Worldmap/areas.tbl~ ~Worldmap/map_mods_areas.tbl~
  COPY ~CtB/Worldmap/links.tbl~ ~Worldmap/map_mods_links.tbl~
  COPY ~CtB/Worldmap/%LANGUAGE%/worldmap.tra~ ~Worldmap/map_mods_trans.tra~
  COPY ~CtB/Worldmap/links_patch.tbl~ ~Worldmap/map_mods_links_patch.tbl~
END


//*****************************************************************************************
//*** GUI Switcher v 2.0
//*****************************************************************************************
PRINT ~Registering GUI...~

<<<<<<<< new_gui_switcher.tp2
BACKUP ~GUI_Mods/Backup~
AUTHOR ~King Diamond~

>>>>>>>>
<<<<<<<< GUI_Mods.2DA
NEXT_AVAILABLE_MOD_SLOT      1
CURRENT_ACTIVE_MOD_GUI       0
RESERVED2                    -1
RESERVED3                    -1
RESERVED4                    -1
RESERVED5                    -1
RESERVED6                    -1
RESERVED7                    -1
RESERVED8                    -1
RESERVED9                    -1
>>>>>>>>
<<<<<<<< orig_gui.tp2
//***********************************************************************************
BEGIN ~"Original SoA/ToB"~
SUBCOMPONENT ~Game Graphical User Interface (GUI)~

COPY_EXISTING ~GUI_Mods/GUI_Mods.2DA~ ~GUI_Mods~
 SET_2DA_ENTRY  1 1 2    0   //CURRENT_ACTIVE_MOD_GUI
AT_EXIT ~Setup-GUI.exe --uninstall~

>>>>>>>>
<<<<<<<< mod_gui.tp2
//***********************************************************************************
BEGIN ~"Check The Bodies"~
SUBCOMPONENT ~Game Graphical User Interface (GUI)~

COPY_EXISTING ~GUI_Mods/GUI_Mods.2DA~ ~GUI_Mods~
 SET_2DA_ENTRY  1 1 2   "%gui_slot_name%"  //CURRENT_ACTIVE_MOD_GUI
COPY ~GUI_Mods/%gui_slot_name%~  ~override~

>>>>>>>>

ACTION_IF NOT FILE_EXISTS ~Setup-GUI.tp2~
THEN BEGIN
  MKDIR ~GUI_Mods~
  COPY ~Setup-CtB.exe~ ~Setup-GUI.exe~
  COPY ~GUI_Mods.2DA~ ~GUI_Mods/GUI_Mods.2DA~
  COPY ~new_gui_switcher.tp2~ ~Setup-GUI.tp2~
   APPEND_FILE ~orig_gui.tp2~
END
ELSE BEGIN
  COPY_EXISTING - ~GUI_Mods/GUI_Mods.2DA~ ~GUI_Mods~
   READ_2DA_ENTRY 1 1 2 "active_gui"   //CURRENT_ACTIVE_MOD_GUI

  ACTION_IF ("%active_gui%">0) THEN BEGIN
    UNINSTALL ~Setup-GUI.tp2~ ~%active_gui%~
  END
END

OUTER_SET gui_slot_name=0
COPY_EXISTING ~GUI_Mods/GUI_Mods.2DA~ ~GUI_Mods~
 READ_2DA_ENTRY 0 1 2 gui_slot_name
 SET_2DA_ENTRY  0 1 2 gui_slot_name+1  //NEXT_AVAILABLE_MOD_SLOT

COPY_EXISTING ~Setup-GUI.tp2~ ~Setup-GUI.tp2~
 APPEND_FILE_EVALUATE ~mod_gui.tp2~

MKDIR ~GUI_Mods/%gui_slot_name%~
COPY ~CtB/gui~ ~GUI_Mods/%gui_slot_name%~
//*****************************************************************************************
//*****************************************************************************************

//////////////////////////////
//Adding music
//////////////////////////////
PRINT ~Registering CtB music themes...~

COPY ~CtB/music/84.MUS~ ~music~
     ~CtB/music/85.MUS~ ~music~
     ~CtB/music/86.MUS~ ~music~
     ~CtB/music/87.MUS~ ~music~
     ~CtB/music/88.MUS~ ~music~
     ~CtB/music/89.MUS~ ~music~
     ~CtB/music/90.MUS~ ~music~
     ~CtB/music/91.MUS~ ~music~

OUTER_SET rows_cnt=0
COPY_EXISTING - ~SONGLIST.2da~ ~override~
 COUNT_2DA_ROWS 3 "rows_cnt"

ACTION_IF ("%rows_cnt%"<=92) THEN BEGIN
  APPEND ~SONGLIST.2DA~ ~9999_84      AR3540          84.MUS~
  APPEND ~SONGLIST.2DA~ ~9999_85      AR3545          85.MUS~
  APPEND ~SONGLIST.2DA~ ~9999_86      AR3550          86.MUS~
  APPEND ~SONGLIST.2DA~ ~9999_87      AR3555          87.MUS~
  APPEND ~SONGLIST.2DA~ ~9999_88      AR3500          88.MUS~
  APPEND ~SONGLIST.2DA~ ~9999_89      AR3502          89.MUS~
  APPEND ~SONGLIST.2DA~ ~9999_90      CB3661          90.MUS~
  APPEND ~SONGLIST.2DA~ ~9999_91      CB3661B         91.MUS~

  COPY_EXISTING ~SONGLIST.2da~  ~override~
   SET song_84 = "%rows_cnt%"
   REPLACE_TEXTUALLY ~9999_84~    "%song_84%"
   SET song_85 = "%rows_cnt%"+1
   REPLACE_TEXTUALLY ~9999_85~    "%song_85%"
   SET song_86 = "%rows_cnt%"+2
   REPLACE_TEXTUALLY ~9999_86~    "%song_86%"
   SET song_87 = "%rows_cnt%"+3
   REPLACE_TEXTUALLY ~9999_87~    "%song_87%"
   SET song_88 = "%rows_cnt%"+4
   REPLACE_TEXTUALLY ~9999_88~    "%song_88%"
   SET song_89 = "%rows_cnt%"+5
   REPLACE_TEXTUALLY ~9999_89~    "%song_89%"
   SET song_90 = "%rows_cnt%"+6
   REPLACE_TEXTUALLY ~9999_90~    "%song_90%"
   SET song_91 = "%rows_cnt%"+7
   REPLACE_TEXTUALLY ~9999_91~    "%song_91%"

  COPY_EXISTING ~AR3540.ARE~  ~override~
                ~AR3542.ARE~  ~override~
                ~AR3544.ARE~  ~override~
                ~AR3546.ARE~  ~override~
                ~AR3547.ARE~  ~override~
                ~AR3549.ARE~  ~override~
                ~AR3551.ARE~  ~override~
                ~AR3553.ARE~  ~override~
                ~AR3555.ARE~  ~override~
                ~AR3557.ARE~  ~override~
                ~AR3558.ARE~  ~override~
                ~AR3560.ARE~  ~override~
                ~AR3610.ARE~  ~override~
                ~AR3611.ARE~  ~override~
                ~AR3613.ARE~  ~override~
    READ_LONG  0xbc "song_offset"
    WRITE_LONG ("%song_offset%"+0x0c) "%song_84%"  //battle song
  BUT_ONLY_IF_IT_CHANGES

  COPY_EXISTING ~AR3541.ARE~  ~override~
                ~AR3543.ARE~  ~override~
                ~AR3545.ARE~  ~override~
                ~AR3548.ARE~  ~override~
                ~AR3550.ARE~  ~override~
                ~AR3552.ARE~  ~override~
                ~AR3554.ARE~  ~override~
                ~AR3556.ARE~  ~override~
                ~AR3559.ARE~  ~override~
    READ_LONG  0xbc "song_offset"
    WRITE_LONG ("%song_offset%"+0x0c) "%song_85%"  //battle song
  BUT_ONLY_IF_IT_CHANGES

  COPY_EXISTING ~AR3540.ARE~  ~override~
                ~AR3541.ARE~  ~override~
                ~AR3542.ARE~  ~override~
                ~AR3543.ARE~  ~override~
                ~AR3544.ARE~  ~override~
                ~AR3545.ARE~  ~override~
                ~AR3546.ARE~  ~override~
                ~AR3547.ARE~  ~override~
                ~AR3548.ARE~  ~override~
                ~AR3549.ARE~  ~override~
                ~AR3550.ARE~  ~override~
                ~AR3551.ARE~  ~override~
                ~AR3552.ARE~  ~override~
                ~AR3553.ARE~  ~override~
                ~AR3554.ARE~  ~override~
                ~AR3555.ARE~  ~override~
                ~AR3556.ARE~  ~override~
                ~AR3557.ARE~  ~override~
                ~AR3558.ARE~  ~override~
                ~AR3559.ARE~  ~override~
                ~AR3560.ARE~  ~override~
                ~AR3570.ARE~  ~override~
                ~AR3610.ARE~  ~override~
                ~AR3611.ARE~  ~override~
                ~AR3613.ARE~  ~override~
    READ_LONG  0xbc "song_offset"
    WRITE_LONG ("%song_offset%") "%song_86%"    //day song
  BUT_ONLY_IF_IT_CHANGES
  
  COPY_EXISTING ~AR3570.ARE~  ~override~
                ~AR3610.ARE~  ~override~
                ~AR3611.ARE~  ~override~
                ~AR3613.ARE~  ~override~
    READ_LONG  0xbc "song_offset"
    WRITE_LONG ("%song_offset%"+4) "%song_86%"  //night song
  BUT_ONLY_IF_IT_CHANGES
  
  COPY_EXISTING ~AR3540.ARE~  ~override~
                ~AR3541.ARE~  ~override~
                ~AR3542.ARE~  ~override~
                ~AR3543.ARE~  ~override~
                ~AR3544.ARE~  ~override~
                ~AR3545.ARE~  ~override~
                ~AR3546.ARE~  ~override~
                ~AR3547.ARE~  ~override~
                ~AR3548.ARE~  ~override~
                ~AR3549.ARE~  ~override~
                ~AR3550.ARE~  ~override~
                ~AR3551.ARE~  ~override~
                ~AR3552.ARE~  ~override~
                ~AR3553.ARE~  ~override~
                ~AR3554.ARE~  ~override~
                ~AR3555.ARE~  ~override~
                ~AR3556.ARE~  ~override~
                ~AR3557.ARE~  ~override~
                ~AR3558.ARE~  ~override~
                ~AR3559.ARE~  ~override~
                ~AR3560.ARE~  ~override~
    READ_LONG  0xbc "song_offset"
    WRITE_LONG ("%song_offset%"+4) "%song_87%"    //night song
  BUT_ONLY_IF_IT_CHANGES
  
  COPY_EXISTING ~AR3597.ARE~  ~override~
                ~AR3600.ARE~  ~override~
    READ_LONG  0xbc "song_offset"
    WRITE_LONG ("%song_offset%")   "%song_88%"  //day song
    WRITE_LONG ("%song_offset%"+4) "%song_88%"  //night song
  BUT_ONLY_IF_IT_CHANGES
  
  COPY_EXISTING ~AR3598.ARE~  ~override~
                ~AR3599.ARE~  ~override~
    READ_LONG  0xbc "song_offset"
    WRITE_LONG ("%song_offset%")   "%song_89%"  //day song
  //   WRITE_LONG ("%song_offset%"+4) "%song_89%"  //night song
  BUT_ONLY_IF_IT_CHANGES
  
  COPY_EXISTING ~CB3661.ARE~  ~override~
                ~CB3662.ARE~  ~override~
                ~CB3663.ARE~  ~override~
                ~CB3664.ARE~  ~override~
                ~CB3665.ARE~  ~override~
                ~CB3666.ARE~  ~override~
                ~CB3667.ARE~  ~override~
                ~CB3668.ARE~  ~override~
    READ_LONG  0xbc "song_offset"
    WRITE_LONG ("%song_offset%")      "%song_90%"  //day song
    WRITE_LONG ("%song_offset%"+4)    "%song_90%"  //night song
    WRITE_LONG ("%song_offset%"+0x0c) "%song_91%"  //battle song
  BUT_ONLY_IF_IT_CHANGES
  
END//patch_if <92
ELSE BEGIN  
  //SONGLIST.2DA has less than 8 free slots - we must move the whole music setup to the GUI auto-mod
  MKDIR ~GUI_Mods/%slot_name%/sound~
  COPY ~CtB/RULE/default/SONGLIST.2DA~ ~GUI_Mods/%slot_name%/sound/SONGLIST.2DA~

<<<<<<<< sound1.tp2
OUTER_SET rows_cnt=0
COPY_EXISTING ~GUI_Mods/%gui_slot_name%/sound/SONGLIST.2DA~ ~override~
 COUNT_2DA_ROWS 3 "rows_cnt"

>>>>>>>>
<<<<<<<< sound2.tp2
APPEND ~SONGLIST.2DA~ ~9999_84      AR3540          84.MUS~
APPEND ~SONGLIST.2DA~ ~9999_85      AR3545          85.MUS~
APPEND ~SONGLIST.2DA~ ~9999_86      AR3550          86.MUS~
APPEND ~SONGLIST.2DA~ ~9999_87      AR3555          87.MUS~
APPEND ~SONGLIST.2DA~ ~9999_88      AR3500          88.MUS~
APPEND ~SONGLIST.2DA~ ~9999_89      AR3502          89.MUS~
APPEND ~SONGLIST.2DA~ ~9999_90      CB3661          90.MUS~
APPEND ~SONGLIST.2DA~ ~9999_91      CB3661B         91.MUS~

COPY_EXISTING ~SONGLIST.2da~  ~override~
 SET song_84 = "%rows_cnt%"
 REPLACE_TEXTUALLY ~9999_84~    "%song_84%"
 SET song_85 = "%rows_cnt%"+1
 REPLACE_TEXTUALLY ~9999_85~    "%song_85%"
 SET song_86 = "%rows_cnt%"+2
 REPLACE_TEXTUALLY ~9999_86~    "%song_86%"
 SET song_87 = "%rows_cnt%"+3
 REPLACE_TEXTUALLY ~9999_87~    "%song_87%"
 SET song_88 = "%rows_cnt%"+4
 REPLACE_TEXTUALLY ~9999_88~    "%song_88%"
 SET song_89 = "%rows_cnt%"+5
 REPLACE_TEXTUALLY ~9999_89~    "%song_89%"
 SET song_90 = "%rows_cnt%"+6
 REPLACE_TEXTUALLY ~9999_90~    "%song_90%"
 SET song_91 = "%rows_cnt%"+7
 REPLACE_TEXTUALLY ~9999_91~    "%song_91%"

COPY_EXISTING ~AR3540.ARE~  ~override~
              ~AR3542.ARE~  ~override~
              ~AR3544.ARE~  ~override~
              ~AR3546.ARE~  ~override~
              ~AR3547.ARE~  ~override~
              ~AR3549.ARE~  ~override~
              ~AR3551.ARE~  ~override~
              ~AR3553.ARE~  ~override~
              ~AR3555.ARE~  ~override~
              ~AR3557.ARE~  ~override~
              ~AR3558.ARE~  ~override~
              ~AR3560.ARE~  ~override~
              ~AR3610.ARE~  ~override~
              ~AR3611.ARE~  ~override~
              ~AR3613.ARE~  ~override~
  READ_LONG  0xbc "song_offset"
  WRITE_LONG ("%song_offset%"+0x0c) "%song_84%"  //battle song
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~AR3541.ARE~  ~override~
              ~AR3543.ARE~  ~override~
              ~AR3545.ARE~  ~override~
              ~AR3548.ARE~  ~override~
              ~AR3550.ARE~  ~override~
              ~AR3552.ARE~  ~override~
              ~AR3554.ARE~  ~override~
              ~AR3556.ARE~  ~override~
              ~AR3559.ARE~  ~override~
  READ_LONG  0xbc "song_offset"
  WRITE_LONG ("%song_offset%"+0x0c) "%song_85%"  //battle song
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~AR3540.ARE~  ~override~
              ~AR3541.ARE~  ~override~
              ~AR3542.ARE~  ~override~
              ~AR3543.ARE~  ~override~
              ~AR3544.ARE~  ~override~
              ~AR3545.ARE~  ~override~
              ~AR3546.ARE~  ~override~
              ~AR3547.ARE~  ~override~
              ~AR3548.ARE~  ~override~
              ~AR3549.ARE~  ~override~
              ~AR3550.ARE~  ~override~
              ~AR3551.ARE~  ~override~
              ~AR3552.ARE~  ~override~
              ~AR3553.ARE~  ~override~
              ~AR3554.ARE~  ~override~
              ~AR3555.ARE~  ~override~
              ~AR3556.ARE~  ~override~
              ~AR3557.ARE~  ~override~
              ~AR3558.ARE~  ~override~
              ~AR3559.ARE~  ~override~
              ~AR3560.ARE~  ~override~
              ~AR3570.ARE~  ~override~
              ~AR3610.ARE~  ~override~
              ~AR3611.ARE~  ~override~
              ~AR3613.ARE~  ~override~
  READ_LONG  0xbc "song_offset"
  WRITE_LONG ("%song_offset%") "%song_86%"    //day song
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~AR3570.ARE~  ~override~
              ~AR3610.ARE~  ~override~
              ~AR3611.ARE~  ~override~
              ~AR3613.ARE~  ~override~
  READ_LONG  0xbc "song_offset"
  WRITE_LONG ("%song_offset%"+4) "%song_86%"  //night song
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~AR3540.ARE~  ~override~
              ~AR3541.ARE~  ~override~
              ~AR3542.ARE~  ~override~
              ~AR3543.ARE~  ~override~
              ~AR3544.ARE~  ~override~
              ~AR3545.ARE~  ~override~
              ~AR3546.ARE~  ~override~
              ~AR3547.ARE~  ~override~
              ~AR3548.ARE~  ~override~
              ~AR3549.ARE~  ~override~
              ~AR3550.ARE~  ~override~
              ~AR3551.ARE~  ~override~
              ~AR3552.ARE~  ~override~
              ~AR3553.ARE~  ~override~
              ~AR3554.ARE~  ~override~
              ~AR3555.ARE~  ~override~
              ~AR3556.ARE~  ~override~
              ~AR3557.ARE~  ~override~
              ~AR3558.ARE~  ~override~
              ~AR3559.ARE~  ~override~
              ~AR3560.ARE~  ~override~
  READ_LONG  0xbc "song_offset"
  WRITE_LONG ("%song_offset%"+4) "%song_87%"    //night song
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~AR3597.ARE~  ~override~
              ~AR3600.ARE~  ~override~
 PATCH_IF (~%SOURCE_SIZE%~) BEGIN
  READ_LONG  0xbc "song_offset"
  WRITE_LONG ("%song_offset%")   "%song_88%"  //day song
  WRITE_LONG ("%song_offset%"+4) "%song_88%"  //night song
 END
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~AR3598.ARE~  ~override~
              ~AR3599.ARE~  ~override~
 PATCH_IF (~%SOURCE_SIZE%~) BEGIN
  READ_LONG  0xbc "song_offset"
  WRITE_LONG ("%song_offset%")   "%song_89%"  //day song
  WRITE_LONG ("%song_offset%"+4) "%song_89%"  //night song
 END
BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING ~CB3661.ARE~  ~override~
              ~CB3662.ARE~  ~override~
              ~CB3663.ARE~  ~override~
              ~CB3664.ARE~  ~override~
              ~CB3665.ARE~  ~override~
              ~CB3666.ARE~  ~override~
              ~CB3667.ARE~  ~override~
              ~CB3668.ARE~  ~override~
  READ_LONG  0xbc "song_offset"
  WRITE_LONG ("%song_offset%")      "%song_90%"  //day song
  WRITE_LONG ("%song_offset%"+4)    "%song_90%"  //night song
  WRITE_LONG ("%song_offset%"+0x0c) "%song_91%"  //battle song
BUT_ONLY_IF_IT_CHANGES

ACTION_IF FILE_EXISTS ~data/CTB-CHRS.bif~
THEN BEGIN
  COPY_EXISTING ~AR3500.ARE~  ~override~
    READ_LONG  0xbc "song_offset"
    WRITE_LONG ("%song_offset%")   "%song_88%"  //day song
    WRITE_LONG ("%song_offset%"+4) "%song_88%"  //night song
  BUT_ONLY_IF_IT_CHANGES

  COPY_EXISTING ~AR3505.ARE~  ~override~
                ~AR3508.ARE~  ~override~
    READ_LONG  0xbc "song_offset"
    WRITE_LONG ("%song_offset%")   "%song_89%"  //day song
    WRITE_LONG ("%song_offset%"+4) "%song_89%"  //night song
  BUT_ONLY_IF_IT_CHANGES
END
//***********************************************************************************

>>>>>>>>

//  COPY + ~sound1.tp2~ ~sound.tmp~ EVALUATE_BUFFER
  COPY_EXISTING ~Setup-GUI.tp2~ ~Setup-GUI.tp2~
   APPEND_FILE_EVALUATE ~sound.tp2~
   APPEND_FILE ~sound2.tp2~
END //ELSE



AT_INTERACTIVE_EXIT ~CtB/CtbFinishInstall.bat~
AT_INTERACTIVE_UNINSTALL ~CtB/CtbUninstall.bat~


