
///////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION beholder_cult BEGIN

INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF beholder_cult_scripts END

COPY_EXISTING ~braiwa1.cre~ ~override~ //Blind Priest
              ~braiwa2.cre~ ~override~ //Blind Priest
              ~braiwa3.cre~ ~override~ //Blind Priest
              ~braiwa4.cre~ ~override~ //Blind Priest
              ~braiwa5.cre~ ~override~ //Blind Priest
              ~cguard1.cre~ ~override~ //Cultist Guard
              ~cguard2.cre~ ~override~ //Cultist Guard
              ~ctraitor.cre~ ~override~ //Tad
              ~cultbh1.cre~ ~override~ //Gauth
              ~cultbh2.cre~ ~override~ //Gauth
              ~cultist1.cre~ ~override~ //Cultist
              ~cultist2.cre~ ~override~ //Cultist
              ~unsee.cre~ ~override~ //The Unseeing Eye
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~bguard1.cre~ ~override~ //Guard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
    REPLACE_CRE_ITEM ~HELM01~ #0 #0 #0 ~IDENTIFIED~ ~HELMET~
    REPLACE_CRE_ITEM ~SHLD03~ #0 #0 #0 ~IDENTIFIED~ ~SHIELD~
  END
BUT_ONLY

COPY_EXISTING ~bhalf1.cre~ ~override~ //Stivan the Hunter
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x64 40
    WRITE_BYTE 0x68 45
    WRITE_ASCII 0x248 ~bpthfsht~ #8
    WRITE_ASCII 0x268 ~bpthief~ #8
  END
BUT_ONLY

COPY_EXISTING ~bharval.cre~ ~override~ //High Mornmaster Arval
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x258 ~bpprst6a~ #8
    WRITE_ASCII 0x260 ~bpleader~ #8
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~bhcapt01.cre~ ~override~ //Elite Guard Captain
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x258 ~bpmag10a~ #8
    WRITE_ASCII 0x260 ~bpleader~ #8
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY


COPY_EXISTING ~bhelm.cre~ ~override~ //Guardian Vottnar
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~wsarsgt~ #8 // Default (was WTASIGHT)
    REMOVE_CRE_ITEM ~SCRL25~
    REPLACE_CRE_ITEM ~SCRL5D~ #1 #0 #0 ~NONE~ ~QITEM1~
  END
BUT_ONLY


COPY_EXISTING ~bhgaal01.cre~ ~override~ //Elite Guard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x258 ~bpmage6~ #8 // Race (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~bhghoul1.cre~ ~override~ //Ghoul
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 32 // CurrHP (was 15)
    WRITE_SHORT 0x26 32 // MaxHP (was 15)
    WRITE_ASCII 0x268 ~bpwtsigt~ #8
  END
BUT_ONLY

COPY_EXISTING ~bhghoul2.cre~ ~override~ //Ghast
              ~bhghoul4.cre~ ~override~ //Ghast
              ~ghast01.cre~ ~override~ //Ghast
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 38 // CurrHP (was 29)
    WRITE_SHORT 0x26 38 // MaxHP (was 29)
    WRITE_ASCII 0x268 ~bpwtsigt~ #8
  END
BUT_ONLY

COPY_EXISTING ~bhghoul3.cre~ ~override~ //Zombie
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 24 // CurrHP (was 15)
    WRITE_SHORT 0x26 24 // MaxHP (was 15)
    WRITE_BYTE 0x234 3 // HighestLevelPrimary (was 2)
    WRITE_ASCII 0x268 ~bpwtsigt~ #8
  END
BUT_ONLY

COPY_EXISTING ~bhghoul5.cre~ ~override~ //Zombie
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x63 50 // RstMissl (was 25)
    WRITE_BYTE 0x234 3 // HighestLevelPrimary (was 2)
    WRITE_ASCII 0x268 ~bpwtsigt~ #8
  END
BUT_ONLY

COPY_EXISTING ~bhguard.cre~ ~override~ //Elite Guard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~bpmag10a~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~bhguard2.cre~ ~override~ //Elite Guard
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x250 ~bpmag10a~ #8 // Class (was )
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~bhnalla.cre~ ~override~ //Stormherald Nallabir
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x258 ~bpmag10a~ #8 // Race (was NONE)
    WRITE_ASCII 0x260 ~bp!bard~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~STAF01~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~BULL01~ #40 #0 #0 ~NONE~ ~QUIVER2~
  END
BUT_ONLY

COPY_EXISTING ~bhoisig.cre~ ~override~ //High Watcher Oisig
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~bpleader~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~cltcut01.cre~ ~override~ //Cultist
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x258 ~bppri10a~ #8 // Race (was NONE)
    WRITE_ASCII 0x260 ~bpmag10a~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was NONE)
    REPLACE_CRE_ITEM ~DART01~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~cltcut03.cre~ ~override~ //Elite Guard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~bpmag10a~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REMOVE_KNOWN_SPELL ~sppr603D~
    REMOVE_KNOWN_SPELL ~sppr603~
    REMOVE_KNOWN_SPELL ~spwi112~
    REMOVE_KNOWN_SPELL ~spwi212~
    REMOVE_KNOWN_SPELL ~spwi213~
    REMOVE_KNOWN_SPELL ~spwi217~
    REMOVE_KNOWN_SPELL ~spwi304~
    REMOVE_KNOWN_SPELL ~spwi305~
    REMOVE_KNOWN_SPELL ~spwi308~
    REMOVE_KNOWN_SPELL ~spwi401~
    REMOVE_KNOWN_SPELL ~spwi505~
    REMOVE_KNOWN_SPELL ~spwi503~
    REMOVE_MEMORIZED_SPELL ~sppr603~
    REMOVE_MEMORIZED_SPELL ~sppr603D~
    REMOVE_MEMORIZED_SPELL ~spwi112~
    REMOVE_MEMORIZED_SPELL ~spwi212~
    REMOVE_MEMORIZED_SPELL ~spwi213~
    REMOVE_MEMORIZED_SPELL ~spwi217~
    REMOVE_MEMORIZED_SPELL ~spwi304~
    REMOVE_MEMORIZED_SPELL ~spwi305~
    REMOVE_MEMORIZED_SPELL ~spwi308~
    REMOVE_MEMORIZED_SPELL ~spwi401~
    REMOVE_MEMORIZED_SPELL ~spwi505~
    REMOVE_MEMORIZED_SPELL ~spwi503~
    ADD_MEMORIZED_SPELL ~sppr101~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr111~ #0 ~priest~ (3)
    ADD_MEMORIZED_SPELL ~sppr202~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr208~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr203~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr313~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr315~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr303~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr401~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr411~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr412~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr405~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr514~ #4 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr599~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr605~ #5 ~priest~
    ADD_MEMORIZED_SPELL ~sppr698~ #5 ~priest~
  END
BUT_ONLY

COPY_EXISTING ~prophet1.cre~ ~override~ //Prophet
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 16 // CurrHP (was 6)
    WRITE_SHORT 0x26 16 // MaxHP (was 6)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~prophet2.cre~ ~override~ //Prophet
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 16 // CurrHP (was 6)
    WRITE_SHORT 0x26 16 // MaxHP (was 6)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~STAF01~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED
    SET_BG2_PROFICIENCY ~PROFICIENCYQUARTERSTAFF~ 1
  END
BUT_ONLY

COPY_EXISTING ~prophet3.cre~ ~override~ //Prophet
              ~prophet4.cre~ ~override~ //Prophet
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 16 // CurrHP (was 6)
    WRITE_SHORT 0x26 16 // MaxHP (was 6)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~STAF01~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED
    SET_BG2_PROFICIENCY ~PROFICIENCYQUARTERSTAFF~ 1
  END
BUT_ONLY

COPY_EXISTING ~talmiss.cre~ ~override~ //Mistress Ada
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~bpleader~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~talmiss2.cre~ ~override~ //Mistress Ada
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 40 // CurrHP (was 4)
    WRITE_SHORT 0x26 40 // MaxHP (was 4)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY


///Unseeing Eye Quest Beholders
COPY_EXISTING ~cultbh3.cre~ ~override~ //Beholder
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x260 ~bpbehold~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~cultbh4.cre~ ~override~ //Spectator
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~bpbehspe~ #8 // General (was BEHOLD01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~bheye.cre~ ~override~ //Unseeing Eye
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x260 ~bpbeheld~ #8 // General (was BEHOLD01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY


END

//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION vampires BEGIN

INCLUDE ~bp/lib/bp_main.tph~

LAF vampire_rules END


ACTION_IF NOT FILE_EXISTS_IN_GAME ~humansht.bcs~ BEGIN
  ACTION_IF MOD_IS_INSTALLED ~setup-bp.tp2~ ~175~ BEGIN
    COMPILE ~bp/baf/shouts/no_strings/humansht.baf~
  END ELSE BEGIN
    COMPILE ~bp/baf/shouts/strings/humansht.baf~
  END
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpvamp01.bcs~ BEGIN
  ACTION_IF FILE_EXISTS_IN_GAME ~dd0012.are~ BEGIN
    COMPILE ~bp/tdd/baf/bodhi/bpvamp01.baf~
  END ELSE BEGIN
    COMPILE ~bp/baf/no_tdd/bodhi/bpvamp01.baf~
  END
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpwdasgt.bcs~ BEGIN
  ACTION_IF MOD_IS_INSTALLED ~setup-bp.tp2~ ~175~ BEGIN
    COMPILE ~bp/baf/shouts/no_strings_2/bpwdasgt.baf~
  END ELSE BEGIN
    COMPILE ~bp/baf/re-baf/core/bpwdasgt.baf~
  END
END

// SoA Vampires, generic encounters, etc

COPY_EXISTING ~vampamb.cre~ ~override~
              ~vampif01.cre~ ~override~
              ~vampim01.cre~ ~override~
              ~vampm01.cre~ ~override~
              ~vampyf01.cre~ ~override~
              ~vampym01.cre~ ~override~
              ~vamver01.cre~ ~override~
              ~ivamp01.cre~ ~override~
              ~vamver01.cre~ ~override~
              ~vamanc01.cre~ ~override~
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x260 ~bpvamp01~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY


// ToB Vampires

COPY_EXISTING ~sarvam02.cre~ ~override~
              ~sarvam03.cre~ ~override~
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x250 ~sarvam02~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x260 ~bpvamp01~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~sarvam02.cre~ ~override~
           
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x250 ~sarvam02~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x260 ~bpvamp01~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~vamemi01.cre~ ~override~
           
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x250 ~vamemi01~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x260 ~bpvamp01~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~vamflf01.cre~ ~override~
              ~vamflm01.cre~ ~override~
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x260 ~bpvamp01~ #8 // General (was GAUTH01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY


END

//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION bodhi_chapter_3 BEGIN

INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF bodhi_scripts END


///Bodhi Chapter 3

ACTION_IF ((FILE_EXISTS_IN_GAME ~bodhil.bmp~) AND (FILE_EXISTS_IN_GAME ~bodhis.bmp~)) BEGIN
  COPY_EXISTING ~bodhi.cre~ ~override~ //Bodhi
                ~bodhiamb.cre~ ~override~ //Bodhi
                ~ppbodhi4.cre~ ~override~ //Bodhi
    LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
    PATCH_IF vl BEGIN
      WRITE_ASCII 0x34 ~bodhis~ #8 // SmallPortrait (was NBODHIS)
      WRITE_ASCII 0x3c ~bodhil~ #8 // LargePortrait (was NONE)
    END
  BUT_ONLY
END

COPY_EXISTING ~vvbodhi.cre~ ~override~ //Bodhi
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpvamp01~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~bodhi2.cre~ ~override~ //Bodhi
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    PATCH_IF ((FILE_EXISTS_IN_GAME ~bodhil.bmp~) AND (FILE_EXISTS_IN_GAME ~bodhis.bmp~)) BEGIN
      WRITE_ASCII 0x34 ~bodhis~ #8 // SmallPortrait (was NBODHIS)
      WRITE_ASCII 0x3c ~bodhil~ #8 // LargePortrait (was NONE)
    END
    WRITE_SHORT 0x46 ~-6~ // ACNatul (was -1)
    WRITE_SHORT 0x48 ~-6~ // ACEffec (was -1)
    WRITE_BYTE 0x52 2 // THAC0 (was 4)
    WRITE_BYTE 0x53 4 // NOAtt (was 3)
    WRITE_BYTE 0x54 2 // SaveVDth (was 5)
    WRITE_BYTE 0x55 2 // SaveVWnd (was 5)
    WRITE_BYTE 0x56 2 // SaveVPoly (was 5)
    WRITE_BYTE 0x57 2 // SaveVAtks (was 5)
    WRITE_BYTE 0x58 2 // SaveVspell (was 5)
    WRITE_BYTE 0x59 50 // RstFire (was 0)
    WRITE_BYTE 0x5c 50 // RstAcid (was 0)
    WRITE_BYTE 0x5e 50 // RstMFre (was 0)
    WRITE_BYTE 0x60 70 // RstSlash (was 0)
    WRITE_BYTE 0x61 80 // RstCrush (was 0)
    WRITE_BYTE 0x62 50 // RstPierc (was 0)
    WRITE_BYTE 0x63 90 // RstMissl (was 0)
    WRITE_BYTE 0x235 25 // HighestLevelSecond (was 1)
    WRITE_ASCII 0x250 ~bpbodhi3~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpvamp01~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x271 1 // IDSGeneral (was 4)
    WRITE_BYTE 0x273 14 // IDSClass (was 163)
    REMOVE_CRE_ITEM ~S2-16~
    REMOVE_CRE_ITEM ~VAMP~
    REMOVE_CRE_ITEM ~IMMUNE2~
    REPLACE_CRE_ITEM ~IMMUNE3~ #0 #0 #0 ~NONE~ ~RRING~
    REPLACE_CRE_ITEM ~VAMP2~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~DAGG16~ #20 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY


END

//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION vampire_chapter_3 BEGIN

INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF bodhi_scripts END

COPY_EXISTING ~bodfgt03.cre~ ~override~ //Guild Contact
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~wbasight~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~del.cre~ ~override~ //Del
              ~dellow.cre~ ~override~ //Del
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 40 // DtectIll (was 0)
    WRITE_BYTE 0x68 50 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was NONE)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY


ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpvammag.cre~ BEGIN
  COPY ~bp/cre/bpvammag.cre~ ~override~
END

COPY_EXISTING ~bodtan.cre~ ~override~ //Tanova
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 73 // CurrHP (was 60)
    WRITE_SHORT 0x26 73 // MaxHP (was 60)
    WRITE_SHORT 0x46 0 // ACNatul (was 3)
    WRITE_SHORT 0x48 0 // ACEffec (was 3)
    WRITE_ASCII 0x268 ~bpvamp01~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~vvamn2.cre~ ~override~ //Amnish Soldier
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x238 17 // Str (was 9)
    WRITE_BYTE 0x23d 15 // Con (was 9)
    WRITE_ASCII 0x260 ~bpseenmy~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~vvamn3.cre~ ~override~ //Amnish Soldier
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x258 ~bpseenmy~ #8 // Race (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~vvarkan.cre~ ~override~ //Arkanis Gath
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 90 // DtectIll (was 0)
    WRITE_BYTE 0x234 21 // HighestLevelPrimary (was 7)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spcl913~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl914~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl916~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl917~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spin489~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spin491~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spin493~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (6)
  END
BUT_ONLY

COPY_EXISTING ~vvcat.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 75 // DtectIll (was 0)
    WRITE_ASCII 0x268 ~bpcthi2a~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin489~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spin493~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl913~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl917~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl916~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl914~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (6)
  END
BUT_ONLY

COPY_EXISTING ~vvmadman.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 50 // DtectIll (was 0)
    WRITE_BYTE 0x68 50 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~vvshad1.cre~ ~override~ //Shadow Thief
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x64 25 // DtectIll (was 0)
    WRITE_BYTE 0x68 50 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
    REMOVE_CRE_ITEM ~DAGG01~
  END
BUT_ONLY

COPY_EXISTING ~vvshad10.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 25 // DtectIll (was 0)
    WRITE_BYTE 0x68 45 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~vvshad11.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~vvshad2.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x68 25 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~vvshad3.cre~ ~override~ //Shadow Thief
              ~vvshad7.cre~ ~override~ //Shadow Thief
              ~vvshad8.cre~ ~override~ //Shadow Thief
              ~vvshad9.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x68 40 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~vvshad4.cre~ ~override~ //Shadow Thief
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x68 40 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
    REMOVE_CRE_ITEM ~DAGG01~
  END
BUT_ONLY

COPY_EXISTING ~vvshad5.cre~ ~override~ //Shadow Thief
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x64 50 // DtectIll (was 0)
    WRITE_BYTE 0x68 50 // Stealth (was 0)
    WRITE_BYTE 0x238 18 // Str (was 15)
    WRITE_BYTE 0x239 60 // StrBon (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
    REMOVE_CRE_ITEM ~MISC36~
  END
BUT_ONLY

COPY_EXISTING ~vvshad6.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 40 // DtectIll (was 0)
    WRITE_BYTE 0x68 60 // Stealth (was 0)
    WRITE_BYTE 0x238 17 // Str (was 15)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~vvpriest.cre~ ~override~ //Priest of Talos
              ~vvryokoi.cre~ ~override~ //Ryokoi
              ~vvsansuk.cre~ ~override~ //Sansuki
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~bodfgt01.cre~ ~override~ //Grimwarder
              ~bodfgt02.cre~ ~override~ //Grimward Archer
              ~lassal02.cre~ ~override~ //Lassal
              ~sarprovf.cre~ ~override~ //Courtesan
              ~sarprovm.cre~ ~override~ //Courtesan
              ~ulvaryl.cre~ ~override~ //Ulvaryl
              ~vampire1.cre~ ~override~ //Ulvaryl
              ~vvmale1.cre~ ~override~ //Vampire
              ~vvmale2.cre~ ~override~ //Vampire
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpvamp01~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~vvamn1.cre~ ~override~ //Amnish Soldier
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x238 17 // Str (was 9)
    WRITE_BYTE 0x23d 15 // Con (was 9)
    WRITE_ASCII 0x250 ~bpseenmy~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY


END

//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION bodhi_chapter_6 BEGIN

INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF bodhi_scripts END

COPY_EXISTING ~c6bodhi.cre~ ~override~ //Bodhi
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 180 // CurrHP (was 120)
    WRITE_SHORT 0x26 180 // MaxHP (was 120)
    WRITE_ASCII 0x34 ~bodhis~ #8 // SmallPortrait (was NBODHIS)
    WRITE_SHORT 0x46 ~-8~ // ACNatul (was -1)
    WRITE_SHORT 0x48 ~-8~ // ACEffec (was -1)
    WRITE_SHORT 0x4a ~-3~ // ACCrush (was 0)
    WRITE_SHORT 0x4c ~-4~ // ACMissl (was 0)
    WRITE_SHORT 0x4e 2 // ACPierc (was 0)
    WRITE_SHORT 0x50 ~-2~ // ACSlash (was 0)
    WRITE_BYTE 0x52 ~-2~ // THAC0 (was 4)
    WRITE_BYTE 0x53 4 // NOAtt (was 3)
    WRITE_BYTE 0x54 2 // SaveVDth (was 5)
    WRITE_BYTE 0x55 2 // SaveVWnd (was 5)
    WRITE_BYTE 0x56 2 // SaveVPoly (was 5)
    WRITE_BYTE 0x57 2 // SaveVAtks (was 5)
    WRITE_BYTE 0x58 2 // SaveVspell (was 5)
    WRITE_BYTE 0x59 25 // RstFire (was 0)
    WRITE_BYTE 0x5c 50 // RstAcid (was 0)
    WRITE_BYTE 0x5e 25 // RstMFre (was 0)
    WRITE_BYTE 0x60 75 // RstSlash (was 0)
    WRITE_BYTE 0x61 75 // RstCrush (was 0)
    WRITE_BYTE 0x62 50 // RstPierc (was 0)
    WRITE_BYTE 0x63 90 // RstMissl (was 0)
    WRITE_BYTE 0x235 25 // HighestLevelSecond (was 1)
    WRITE_BYTE 0x23a 21 // Int (was 15)
    WRITE_BYTE 0x23b 21 // Wis (was 15)
    WRITE_ASCII 0x260 ~bpbodhi3~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpvamp01~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x273 14 // IDSClass (was 163)
    ADD_MEMORIZED_SPELL ~sppr301~ #2 ~priest~ (5)
    ADD_MEMORIZED_SPELL ~sppr314~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr411~ #3 ~priest~ (3)
    ADD_MEMORIZED_SPELL ~sppr418~ #3 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr427~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr505~ #4 ~priest~ (3)
    ADD_MEMORIZED_SPELL ~sppr517~ #4 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr613~ #5 ~priest~
    ADD_MEMORIZED_SPELL ~sppr622~ #5 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr715~ #6 ~priest~ (3)
    ADD_MEMORIZED_SPELL ~sppr748~ #6 ~priest~ (3)
    ADD_MEMORIZED_SPELL ~spwi302~ #2 ~wizard~ (3)
    ADD_MEMORIZED_SPELL ~spwi403~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi427~ #3 ~wizard~ (5)
    ADD_MEMORIZED_SPELL ~spwi505~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi513~ #4 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi596~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi612~ #5 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi701~ #6 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi704~ #6 ~wizard~ (3)
    ADD_MEMORIZED_SPELL ~spwi725~ #6 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi815~ #7 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi898~ #7 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi899~ #7 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi902~ #8 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi909~ #8 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi969~ #8 ~wizard~ (2)
    SET_BG2_PROFICIENCY ~PROFICIENCYDAGGER~ 5
    LAUNCH_PATCH_FUNCTION DELETE_CRE_EFFECT
      INT_VAR opcode_to_delete = 31 //Magic Damage Resistance Modifier
    END
    LAUNCH_PATCH_FUNCTION ADD_CRE_EFFECT
      INT_VAR opcode = 31 //Magic Damage Resistance Modifier
      timing = 9 //Permanent after death
      target = 1 //Self
      parameter1 = 50 //Statistic modifier
      resist_dispel = 2 //Not dispellable/bypass resistance
    END
    LAUNCH_PATCH_FUNCTION DELETE_CRE_EFFECT
      INT_VAR opcode_to_delete = 102 //Protection from Spell Levels
    END
    LAUNCH_PATCH_FUNCTION ADD_CRE_EFFECT
      INT_VAR opcode = 102 //Protection from Spell Levels
      timing = 9 //Permanent after death
      target = 1 //Self
      parameter1 = 1 //Spell level
      resist_dispel = 2 //Not dispellable/bypass resistance
    END
    LAUNCH_PATCH_FUNCTION ADD_CRE_EFFECT
      INT_VAR opcode = 102 //Protection from Spell Levels
      timing = 9 //Permanent after death
      target = 1 //Self
      parameter1 = 2 //Spell level
      resist_dispel = 2 //Not dispellable/bypass resistance
    END
    LAUNCH_PATCH_FUNCTION ADD_CRE_EFFECT
      INT_VAR opcode = 102 //Protection from Spell Levels
      timing = 9 //Permanent after death
      target = 1 //Self
      parameter1 = 3 //Spell level
      resist_dispel = 2 //Not dispellable/bypass resistance
    END
    LAUNCH_PATCH_FUNCTION DELETE_CRE_EFFECT
      INT_VAR opcode_to_delete = 292 //Protection from Backstab
    END
    LAUNCH_PATCH_FUNCTION ADD_CRE_EFFECT
      INT_VAR opcode = 292 //Protection from Backstab
      timing = 9 //Permanent after death
      target = 1 //Self
      parameter2 = 1 //Constant value
      resist_dispel = 2 //Not dispellable/bypass resistance
    END
    LAUNCH_PATCH_FUNCTION DELETE_CRE_EFFECT
      INT_VAR opcode_to_delete = 193 //Invisible Detection by Script
    END
    LAUNCH_PATCH_FUNCTION ADD_CRE_EFFECT
      INT_VAR opcode = 193 //Invisible Detection by Script
      timing = 9 //Permanent after death
      target = 1 //Self
      parameter2 = 1 //Constant value
      resist_dispel = 2 //Not dispellable/bypass resistance
    END
  END
BUT_ONLY


END

//////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION vampire_chapter_6 BEGIN

INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF bodhi_scripts END

COPY_EXISTING ~c6bran.cre~ ~override~ //Branet Al-Thon
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x53 7 // NOAtt (was 1)
    WRITE_BYTE 0x238 17 // Str (was 9)
    WRITE_BYTE 0x23a 11 // Int (was 9)
    WRITE_BYTE 0x23b 14 // Wis (was 9)
    WRITE_BYTE 0x23c 10 // Dex (was 9)
    WRITE_BYTE 0x23d 16 // Con (was 9)
    WRITE_BYTE 0x23e 18 // Cha (was 9)
    WRITE_ASCII 0x260 ~bpseenmy~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bppald16~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x27b 17 // Alignment (was 18)
    ADD_MEMORIZED_SPELL ~sppr101~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr210~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr212~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr303~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr313~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr323~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr403~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr406~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr412~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~spcl211~ #0 ~innate~ (3)
    ADD_MEMORIZED_SPELL ~spcl213~ #0 ~innate~ (11)
    REPLACE_CRE_ITEM ~HELMNOAN~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~SHLD05~ #0 #0 #0 ~NONE~ ~SHIELD~
    REPLACE_CRE_ITEM ~BOW03~ #0 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~AROW02~ #40 #0 #0 ~NONE~ ~QUIVER1~
  END
BUT_ONLY

COPY_EXISTING ~c6yean.cre~ ~override~ //Yeanasha
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpally~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~c6del.cre~ ~override~ //Del
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 97 // CurrHP (was 67)
    WRITE_SHORT 0x26 97 // MaxHP (was 67)
    WRITE_BYTE 0x52 9 // THAC0 (was 11)
    WRITE_BYTE 0x53 8 // NOAtt (was 1)
    WRITE_BYTE 0x54 6 // SaveVDth (was 10)
    WRITE_BYTE 0x55 8 // SaveVWnd (was 12)
    WRITE_BYTE 0x56 7 // SaveVPoly (was 11)
    WRITE_BYTE 0x57 8 // SaveVAtks (was 12)
    WRITE_BYTE 0x58 9 // SaveVspell (was 13)
    WRITE_BYTE 0x234 14 // HighestLevelPrimary (was 8)
    WRITE_BYTE 0x239 95 // StrBon (was 76)
    WRITE_BYTE 0x23c 21 // Dex (was 9)
    WRITE_BYTE 0x23d 21 // Con (was 9)
    WRITE_ASCII 0x258 ~bpvamp01~ #8 // Race (was NONE)
    WRITE_ASCII 0x268 ~~ #8 // Default (was WTASIGHT)
    REMOVE_CRE_ITEM ~VAMPREG~
    REPLACE_CRE_ITEM ~VAMPREG1~ #0 #0 #0 ~NONE~ ~LRING~
  END
BUT_ONLY

COPY_EXISTING ~c6harei.cre~ ~override~ //Hareishan
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x52 9 // THAC0 (was 11)
    WRITE_BYTE 0x53 2 // NOAtt (was 1)
    WRITE_BYTE 0x54 8 // SaveVDth (was 10)
    WRITE_BYTE 0x55 11 // SaveVWnd (was 12)
    WRITE_BYTE 0x56 10 // SaveVPoly (was 11)
    WRITE_BYTE 0x57 11 // SaveVAtks (was 12)
    WRITE_BYTE 0x58 12 // SaveVspell (was 13)
    WRITE_BYTE 0x234 12 // HighestLevelPrimary (was 8)
    WRITE_ASCII 0x268 ~bpvamp01~ #8 // Default (was WTASIGHT)
    LAUNCH_PATCH_FUNCTION DELETE_CRE_EFFECT
      INT_VAR opcode_to_delete = 288 //Fist THAC0 Modifier
    END
    LAUNCH_PATCH_FUNCTION ADD_CRE_EFFECT
      INT_VAR opcode = 288 //Fist THAC0 Modifier
      timing = 9 //Permanent after death
      target = 1 //Self
      parameter1 = 2 //Statistic modifier
      resist_dispel = 2 //Not dispellable/bypass resistance
    END
    LAUNCH_PATCH_FUNCTION DELETE_CRE_EFFECT
      INT_VAR opcode_to_delete = 289 //Fist Damage Modifier
    END
    LAUNCH_PATCH_FUNCTION ADD_CRE_EFFECT
      INT_VAR opcode = 289 //Fist Damage Modifier
      timing = 9 //Permanent after death
      target = 1 //Self
      parameter1 = 4 //Statistic modifier
      resist_dispel = 2 //Not dispellable/bypass resistance
    END
  END
BUT_ONLY

COPY_EXISTING ~c6eric.cre~ ~override~ //Eric Vanstraaten
              ~c6eric3.cre~ ~override~ //Eric Vanstraaten
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x238 15 // Str (was 9)
    WRITE_BYTE 0x23b 16 // Wis (was 9)
    WRITE_BYTE 0x23d 12 // Con (was 9)
    WRITE_BYTE 0x23e 18 // Cha (was 9)
    WRITE_ASCII 0x260 ~bpseenmy~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bppald16~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x27b 17 // Alignment (was 18)
    ADD_MEMORIZED_SPELL ~sppr101~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr210~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr212~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr323~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr313~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr303~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr403~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr406~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr412~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~spcl211~ #0 ~innate~ (3)
    ADD_MEMORIZED_SPELL ~spcl213~ #0 ~innate~ (11)
    REPLACE_CRE_ITEM ~AX1H04~ #6 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~c6kalden.cre~ ~override~ //Kalden
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x238 18 // Str (was 9)
    WRITE_BYTE 0x239 47 // StrBon (was 0)
    WRITE_BYTE 0x23b 15 // Wis (was 9)
    WRITE_BYTE 0x23d 16 // Con (was 9)
    WRITE_ASCII 0x260 ~bpseenmy~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bppald16~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x27b 17 // Alignment (was 18)
    ADD_MEMORIZED_SPELL ~sppr101~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr210~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr212~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr323~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr313~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr303~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr403~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr406~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr412~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~spcl211~ #0 ~innate~ (3)
    ADD_MEMORIZED_SPELL ~spcl213~ #0 ~innate~ (11)
    REPLACE_CRE_ITEM ~BOW01~ #0 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~AROW08~ #30 #0 #0 ~NONE~ ~QUIVER1~
  END
BUT_ONLY

COPY_EXISTING ~c6kngt1.cre~ ~override~ //Morning Knight
              ~c6kngt2.cre~ ~override~ //Shield Knight
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~bpprist5~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~c6levin.cre~ ~override~ //Levin Rayn
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x53 2 // NOAtt (was 1)
    WRITE_BYTE 0x238 18 // Str (was 9)
    WRITE_BYTE 0x239 68 // StrBon (was 0)
    WRITE_BYTE 0x23b 14 // Wis (was 9)
    WRITE_BYTE 0x23d 15 // Con (was 9)
    WRITE_BYTE 0x23e 17 // Cha (was 9)
    WRITE_ASCII 0x260 ~bpseenmy~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bppald16~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x27b 17 // Alignment (was 18)
    ADD_MEMORIZED_SPELL ~sppr101~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr210~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr212~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr323~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr313~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr303~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr403~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr406~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr412~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~spcl211~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl213~ #0 ~innate~ (11)
    REPLACE_CRE_ITEM ~HELM11~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~BOW02~ #0 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~AROW08~ #30 #0 #0 ~NONE~ ~QUIVER1~
  END
BUT_ONLY

COPY_EXISTING ~c6mere.cre~ ~override~ //Meredath
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 107 // CurrHP (was 67)
    WRITE_SHORT 0x26 107 // MaxHP (was 67)
    WRITE_SHORT 0x46 ~-2~ // ACNatul (was 1)
    WRITE_SHORT 0x48 ~-2~ // ACEffec (was 1)
    WRITE_BYTE 0x53 2 // NOAtt (was 1)
    WRITE_BYTE 0x234 12 // HighestLevelPrimary (was 8)
    WRITE_BYTE 0x23c 23 // Dex (was 9)
    WRITE_ASCII 0x268 ~bpvamp01~ #8 // Default (was WTASIGHT)
    REMOVE_CRE_ITEM ~VAMPREG~
    REPLACE_CRE_ITEM ~VAMPREG2~ #0 #0 #0 ~NONE~ ~LRING~
    REPLACE_CRE_ITEM ~MAGE01~ #0 #0 #0 ~NONE~ ~RRING~
    LAUNCH_PATCH_FUNCTION DELETE_CRE_EFFECT
      INT_VAR opcode_to_delete = 16 //Haste
    END
    LAUNCH_PATCH_FUNCTION ADD_CRE_EFFECT
      INT_VAR opcode = 16 //Haste
      timing = 9 //Permanent after death
      target = 1 //Self
      resist_dispel = 2 //Not dispellable/bypass resistance
    END
  END
BUT_ONLY

COPY_EXISTING ~c6nerit.cre~ ~override~ //Nerit
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x238 17 // Str (was 9)
    WRITE_BYTE 0x23b 15 // Wis (was 9)
    WRITE_BYTE 0x23d 16 // Con (was 9)
    WRITE_BYTE 0x23e 17 // Cha (was 9)
    WRITE_ASCII 0x260 ~bpseenmy~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bppald16~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x27b 17 // Alignment (was 18)
    ADD_MEMORIZED_SPELL ~sppr101~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr210~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr212~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr323~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr313~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr303~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr403~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr406~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr412~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~spcl211~ #0 ~innate~ (3)
    ADD_MEMORIZED_SPELL ~spcl213~ #0 ~innate~ (11)
    REPLACE_CRE_ITEM ~HELMNOAN~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~AX1H04~ #6 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~c6salia.cre~ ~override~ //Salia
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 89 // CurrHP (was 67)
    WRITE_SHORT 0x26 89 // MaxHP (was 67)
    WRITE_BYTE 0x53 2 // NOAtt (was 1)
    WRITE_BYTE 0x234 10 // HighestLevelPrimary (was 8)
    WRITE_ASCII 0x268 ~bpvamp01~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~c6squire.cre~ ~override~ //Squire Cathras
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 48 // CurrHP (was 40)
    WRITE_SHORT 0x26 48 // MaxHP (was 40)
    WRITE_BYTE 0x238 16 // Str (was 9)
    WRITE_BYTE 0x23c 17 // Dex (was 9)
    WRITE_BYTE 0x23d 16 // Con (was 9)
    WRITE_BYTE 0x23e 17 // Cha (was 9)
    WRITE_ASCII 0x268 ~bppald10~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x27b 17 // Alignment (was 18)
    ADD_MEMORIZED_SPELL ~spcl211~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl213~ #0 ~innate~ (3)
    REPLACE_CRE_ITEM ~HELM01~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~CHAN01~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SW2H01~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED
    REPLACE_CRE_ITEM ~AX1H04~ #6 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~POTN52~ #3 #0 #0 ~NONE~ ~QITEM1~
  END
BUT_ONLY

COPY_EXISTING ~c6tanov.cre~ ~override~ //Tanova
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x46 ~-1~ // ACNatul (was 1)
    WRITE_SHORT 0x48 ~-1~ // ACEffec (was 1)
    WRITE_BYTE 0x52 7 // THAC0 (was 11)
    WRITE_BYTE 0x53 8 // NOAtt (was 1)
    WRITE_BYTE 0x234 12 // HighestLevelPrimary (was 8)
    WRITE_BYTE 0x238 20 // Str (was 18)
    WRITE_BYTE 0x239 0 // StrBon (was 76)
    WRITE_BYTE 0x23c 18 // Dex (was 9)
    WRITE_BYTE 0x23d 23 // Con (was 9)
    WRITE_ASCII 0x268 ~bpvamp01~ #8 // Default (was WTASIGHT)
    REMOVE_CRE_ITEM ~VAMPREG~ ~VAMP1~
    REPLACE_CRE_ITEM ~VAMPREG2~ #0 #0 #0 ~NONE~ ~LRING~
    REPLACE_CRE_ITEM ~VAMP2~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
  END
BUT_ONLY

COPY_EXISTING ~c6valen.cre~ ~override~ //Valen
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 84 // CurrHP (was 67)
    WRITE_SHORT 0x26 84 // MaxHP (was 67)
    WRITE_BYTE 0x53 7 // NOAtt (was 1)
    WRITE_BYTE 0x234 10 // HighestLevelPrimary (was 8)
    WRITE_ASCII 0x268 ~bpvamp01~ #8 // Default (was WTASIGHT)
    REMOVE_CRE_ITEM ~VAMPREG~
    REPLACE_CRE_ITEM ~VAMPREG1~ #0 #0 #0 ~NONE~ ~LRING~
  END
BUT_ONLY

COPY_EXISTING ~c6will.cre~ ~override~ //William Reirrac
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x53 2 // NOAtt (was 1)
    WRITE_BYTE 0x238 18 // Str (was 9)
    WRITE_BYTE 0x239 73 // StrBon (was 0)
    WRITE_BYTE 0x23a 11 // Int (was 9)
    WRITE_BYTE 0x23b 16 // Wis (was 9)
    WRITE_BYTE 0x23c 12 // Dex (was 9)
    WRITE_BYTE 0x23d 14 // Con (was 9)
    WRITE_BYTE 0x23e 18 // Cha (was 9)
    WRITE_ASCII 0x268 ~bppald16~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x27b 17 // Alignment (was 18)
    ADD_MEMORIZED_SPELL ~sppr101~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr210~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr212~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr323~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr313~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr303~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr403~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr406~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr412~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~spcl211~ #0 ~innate~ (3)
    ADD_MEMORIZED_SPELL ~spcl213~ #0 ~innate~ (11)
    REPLACE_CRE_ITEM ~HELM12~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~BOW02~ #0 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~AROW10~ #20 #0 #0 ~NONE~ ~QUIVER1~
  END
BUT_ONLY

COPY_EXISTING ~c6arkan.cre~ ~override~ //Arkanis
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 60 // DtectIll (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (5)
  END
BUT_ONLY

COPY_EXISTING ~c6arkan3.cre~ ~override~ //Arkanis
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 79 // CurrHP (was 72)
    WRITE_SHORT 0x26 79 // MaxHP (was 72)
    WRITE_BYTE 0x64 60 // DtectIll (was 0)
    WRITE_BYTE 0x235 17 // HighestLevelSecond (was 1)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (5)
  END
BUT_ONLY

COPY_EXISTING ~c6gofus.cre~ ~override~ //Gofus
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 84 // CurrHP (was 72)
    WRITE_SHORT 0x26 84 // MaxHP (was 72)
    WRITE_BYTE 0x64 60 // DtectIll (was 0)
    WRITE_BYTE 0x68 80 // Stealth (was 20)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (4)
  END
BUT_ONLY

COPY_EXISTING ~c6mess.cre~ ~override~ //Shadow Thief
              ~c6natas.cre~ ~override~ //Natas
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x64 60 // DtectIll (was 0)
    WRITE_BYTE 0x68 80 // Stealth (was 20)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (4)
  END
BUT_ONLY

COPY_EXISTING ~c6bguard.cre~ ~override~ //Guard
              ~c6cler1.cre~ ~override~ //Cleric Of Lathander
              ~c6cler2.cre~ ~override~ //Cleric Of Helm
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpvamp01~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~c6alyra.cre~ ~override~ //Alyra
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 80 // DtectIll (was 0)
    WRITE_BYTE 0x68 90 // Stealth (was 20)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (4)
  END
BUT_ONLY

COPY_EXISTING ~c6cler3.cre~ ~override~ //Cleric Of Talos
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 44 // CurrHP (was 40)
    WRITE_SHORT 0x26 44 // MaxHP (was 40)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY


END

/////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION brown_dragon BEGIN

COPY ~bp/browndragon/items/btnseed.itm~ ~override~        
  SAY NAME1 #6633 
  SAY NAME2 @10500 
  SAY UNIDENTIFIED_DESC #6756 
  SAY DESC @10501 
  SAY 0x10e #1474 
  SAY 0x19e #47835 

COPY ~bp/browndragon/items/c-cs.itm~ ~override~        
  SAY NAME1 #6701 
  SAY NAME2 @10502 
  SAY UNIDENTIFIED_DESC #6703
  SAY DESC @10503 

COPY ~bp/browndragon/filedump~  ~override~ // File Copy 

COPY ~bp/browndragon/cre/bpdrgbrn.cre~ ~override~
  SAY NAME1 @10504 
  SAY NAME2 @10504 

EXTEND_BOTTOM ~AR1900.BCS~ ~bp/browndragon/baf/bAR1900.baf~

COMPILE ~bp/browndragon/baf/krdrgbrn.baf~

COMPILE ~bp/browndragon/baf/krsummon.baf~

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpwdasgt.bcs~ BEGIN
  ACTION_IF MOD_IS_INSTALLED ~setup-bp.tp2~ ~175~ BEGIN
    COMPILE ~bp/baf/shouts/no_strings_2/bpwdasgt.baf~
  END ELSE BEGIN
    COMPILE ~bp/baf/re-baf/core/bpwdasgt.baf~
  END
END


END

//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION drizzt BEGIN

INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF drizzt_scripts END 

COPY_EXISTING ~c6coran.cre~ ~override~ //Coran
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 87 // CurrHP (was 27)
    WRITE_SHORT 0x26 87 // MaxHP (was 27)
    WRITE_ASCII 0x260 ~bpthief~ #8 // General (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (4)
    REMOVE_CRE_ITEM ~BOW03~
    REPLACE_CRE_ITEM ~BOW04~ #0 #0 #0 ~UNSTEALABLE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~c6drizz.cre~ ~override~ //Drizzt
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~~ #8 // General (was USEITEM)
    WRITE_BYTE 0x274 5 // IDSSpecifc (was 0)
  END
BUT_ONLY

COPY_EXISTING ~c6harp.cre~ ~override~ //Malchor Harpell
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    REPLACE_CRE_ITEM ~STAF07~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED
    REPLACE_CRE_ITEM ~DART04~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~c6lanf.cre~ ~override~ //Lanfear
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 86 // CurrHP (was 66)
    WRITE_SHORT 0x26 86 // MaxHP (was 66)
    WRITE_BYTE 0x234 13 // HighestLevelPrimary (was 11)
    WRITE_ASCII 0x250 ~bpleader~ #8 // Class (was GPSHOUT)
    WRITE_ASCII 0x260 ~humansht~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~c6regis.cre~ ~override~ //Regis
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 40 // DtectIll (was 0)
    WRITE_BYTE 0x68 60 // Stealth (was 0)
    WRITE_ASCII 0x260 ~wsasight~ #8 // General (was USEITEM)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~c6regis2.cre~ ~override~ //Regis
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 40 // DtectIll (was 0)
    WRITE_BYTE 0x68 60 // Stealth (was 0)
    WRITE_ASCII 0x260 ~bpthief~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~wsasight~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~c6wulf.cre~ ~override~ //Wulfgar
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~~ #8 // General (was USEITEM)
    WRITE_ASCII 0x268 ~bpally~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~c6wulf2.cre~ ~override~ //Wulfgar
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpally~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~c6bruen.cre~ ~override~ //Bruenor
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x46 6 // ACNatul (was -3)
    WRITE_SHORT 0x48 6 // ACEffec (was -3)
    WRITE_SHORT 0x4a 1 // ACCrush (was 0)
    WRITE_SHORT 0x4c 4 // ACMissl (was 0)
    WRITE_SHORT 0x4e 2 // ACPierc (was 0)
    WRITE_SHORT 0x50 3 // ACSlash (was 0)
    WRITE_ASCII 0x260 ~~ #8 // General (was USEITEM)
    WRITE_ASCII 0x268 ~wbasight~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~c6bruen2.cre~ ~override~ //Bruenor
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x46 6 // ACNatul (was -3)
    WRITE_SHORT 0x48 6 // ACEffec (was -3)
    WRITE_SHORT 0x4a 1 // ACCrush (was 0)
    WRITE_SHORT 0x4c 4 // ACMissl (was 0)
    WRITE_SHORT 0x4e 2 // ACPierc (was 0)
    WRITE_SHORT 0x50 3 // ACSlash (was 0)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~c6drizz2.cre~ ~override~ //Drizzt
              ~c6drizz3.cre~ ~override~ //Drizzt
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY


END


//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION coronet_slavers BEGIN

INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF coronet_slavers_scripts END


COPY_EXISTING ~beast.cre~ ~override~ //Beastmaster
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 65
    WRITE_SHORT 0x26 65
    WRITE_BYTE 0x52 13
    WRITE_BYTE 0x53 2
    WRITE_BYTE 0x54 10
    WRITE_BYTE 0x55 12
    WRITE_BYTE 0x56 11
    WRITE_BYTE 0x57 12
    WRITE_BYTE 0x58 13
    WRITE_ASCII 0x268 ~bpwtrsgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~AROW05~ #20 #0 #0 ~UNSTEALABLE~ ~QUIVER1~
    SET_BG2_PROFICIENCY ~PROFICIENCYSHORTBOW~ 4
    SET_BG2_PROFICIENCY ~PROFICIENCYSPEAR~ 1
  END
BUT_ONLY

COPY_EXISTING ~bernard.cre~ ~override~ //Bernard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~wgarsgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~haegan.cre~ ~override~ //Captain Haegan
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~~ #8 // use to be haegan, which was a very simple attack script (useless)
    WRITE_ASCII 0x268 ~wbasight~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~hendak.cre~ ~override~ //Hendak
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~~ #8 // Override (was GPSHOUT)
    WRITE_ASCII 0x260 ~bp!plot~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~icyuan01.cre~ ~override~ //Yuan-Ti
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 57 // CurrHP (was 48)
    WRITE_SHORT 0x26 57 // MaxHP (was 48)
    WRITE_SHORT 0x46 2 // ACNatul (was 0)
    WRITE_SHORT 0x48 2 // ACEffec (was 0)
    WRITE_ASCII 0x248 ~gensht01~ #8 // Override (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x274 102 // IDSSpecifc (was 0)
  END
BUT_ONLY

COPY_EXISTING ~lehtin.cre~ ~override~ //Lehtinan
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x258 ~bpwdasgt~ #8 // Race (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~llynis.cre~ ~override~ //Llynis
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 30 // DtectIll (was 0)
    WRITE_BYTE 0x68 45 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTARSGT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~rufpal1.cre~ ~override~ //Ruffian
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    // WRITE_BYTE 0x74 2 // Unu6(Axe prof) (was 0)
    WRITE_ASCII 0x260 ~bpwdasgt~ #8 // General (was WTASIGHT)
    SET_BG2_PROFICIENCY ~PROFICIENCYAXE~ 2
  END
BUT_ONLY

COPY_EXISTING ~rufpal2.cre~ ~override~ //Ruffian
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    // WRITE_BYTE 0x72 3 // Unu4(Blunt prof) (was 0)
    WRITE_ASCII 0x260 ~bpwdasgt~ #8 // General (was WTASIGHT)
    SET_BG2_PROFICIENCY ~EXTRAPROFICIENCY1~ 3
  END
BUT_ONLY

COPY_EXISTING ~salvanas.cre~ ~override~ //Salvanas
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~~ #8 // Class (was GPUSE)
    WRITE_ASCII 0x260 ~bp!bard~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~wbasight~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~slapri.cre~ ~override~ //Priest of Cyric
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~HELM11~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~PLAT01~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SHLD03~ #0 #0 #0 ~NONE~ ~SHIELD~
    REPLACE_CRE_ITEM ~HAMM01~ #0 #0 #0 ~NONE~ ~WEAPON1~
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
    REPLACE_CRE_ITEM ~BULL01~ #20 #0 #0 ~NONE~ ~QUIVER1~
    SET_BG2_PROFICIENCY ~PROFICIENCYSLING~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYWARHAMMER~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYSWORDANDSHIELD~ 1
  END
BUT_ONLY

COPY_EXISTING ~slaver1.cre~ ~override~ //Slaver Guard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~bpwdasgt~ #8 // Class (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~slaver2.cre~ ~override~ //Slaver Guard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 45 // CurrHP (was 25)
    WRITE_SHORT 0x26 45 // MaxHP (was 25)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~slaver3.cre~ ~override~ //Slaver Guard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 36 // CurrHP (was 16)
    WRITE_SHORT 0x26 36 // MaxHP (was 16)
    WRITE_BYTE 0x68 30 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~slaver4.cre~ ~override~ //Slaver Guard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 42 // CurrHP (was 22)
    WRITE_SHORT 0x26 42 // MaxHP (was 22)
    WRITE_ASCII 0x260 ~bpwdasgt~ #8 // General (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~gorf.cre~ ~override~ //Gorf the Squisher
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 65 // CurrHP (was 45)
    WRITE_SHORT 0x26 65 // MaxHP (was 45)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~gorf03.cre~ ~override~ //Gorf the Squisher
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 65 // CurrHP (was 25)
    WRITE_SHORT 0x26 65 // MaxHP (was 25)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~ccguard2.cre~ ~override~ //Copper Coronet Guard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

// Slaver Lords, AR0907

COPY_EXISTING ~hlketta2.cre~ ~override~ //Ketta
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 70 // DtectIll (was 0)
    WRITE_BYTE 0x68 95 // Stealth (was 20)
    WRITE_ASCII 0x268 ~bpcthi2a~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin486~ #0 ~innate~ (5)
    ADD_MEMORIZED_SPELL ~spcl913~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl914~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl916~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl917~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~hlkoshi.cre~ ~override~ //Koshi
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    // SAY NAME1 #53215 // LongName (was 53213)
    REMOVE_CRE_ITEM ~SCRL3I~
    REPLACE_CRE_ITEM ~SCRL3I~ #1 #0 #0 ~NONE~ ~INV~
  END
BUT_ONLY

COPY_EXISTING ~hlmafer.cre~ ~override~ //Maferan
              ~hlolaf.cre~ ~override~ //Olaf Rassmusen
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~~ #8 // Class (was GPUSE)
    WRITE_ASCII 0x268 ~wbasight~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~hlsion.cre~ ~override~ //Sion
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    REPLACE_CRE_ITEM ~STAF01~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED
    REPLACE_CRE_ITEM ~DART01~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY


END

///////////////////Improved Crypt King/////////////////////////
//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION crypt_king BEGIN

INCLUDE ~bp/lib/bp_main.tph~

<<<<<<<< BHCRYPT.TBL
CREATURE_NAME    SPELL     NUM  TYPE     LVL

BHCRYPT.CRE      SPWI105    1   WIZARD   0
BHCRYPT.CRE      SPWI106    2   WIZARD   0
BHCRYPT.CRE      SPWI118    3   WIZARD   0
BHCRYPT.CRE      SPWI125    2   WIZARD   0
BHCRYPT.CRE      SPWI205    2   WIZARD   1
BHCRYPT.CRE      SPWI213    1   WIZARD   1
BHCRYPT.CRE      SPWI218    2   WIZARD   1
BHCRYPT.CRE      SPWI312    1   WIZARD   2
BHCRYPT.CRE      SPWI314    2   WIZARD   2
BHCRYPT.CRE      SPWI316    2   WIZARD   2
BHCRYPT.CRE      SPWI318    1   WIZARD   2
BHCRYPT.CRE      SPWI401    1   WIZARD   3
BHCRYPT.CRE      SPWI408    2   WIZARD   3
BHCRYPT.CRE      SPWI409    1   WIZARD   3
BHCRYPT.CRE      SPWI412    1   WIZARD   3
BHCRYPT.CRE      SPWI501    2   WIZARD   4
BHCRYPT.CRE      SPWI506    1   WIZARD   4
BHCRYPT.CRE      SPWI508    1   WIZARD   4
BHCRYPT.CRE      SPWI509    1   WIZARD   4
BHCRYPT.CRE      SPWI601    1   WIZARD   5
BHCRYPT.CRE      SPWI604    1   WIZARD   5
BHCRYPT.CRE      SPWI605    1   WIZARD   5
BHCRYPT.CRE      SPWI611    1   WIZARD   5
BHCRYPT.CRE      SPWI701    1   WIZARD   6
BHCRYPT.CRE      SPWI704    1   WIZARD   6
BHCRYPT.CRE      SPWI707    1   WIZARD   6
BHCRYPT.CRE      SPWI713    1   WIZARD   6
BHCRYPT.CRE      SPWI715    1   WIZARD   6
BHCRYPT.CRE      SPWI807    1   WIZARD   7
BHCRYPT.CRE      SPWI897    1   WIZARD   7
BHCRYPT.CRE      SPWI899    1   WIZARD   7
>>>>>>>>

COPY_EXISTING ~BHCRYPT.CRE~       ~override~
  WRITE_SHORT 0x24 ~186~
  WRITE_SHORT 0x26 ~186~
  WRITE_BYTE 0x2c ~29~
  WRITE_BYTE 0x2d ~36~
  WRITE_BYTE 0x2e ~23~
  WRITE_BYTE 0x2f ~16~
  WRITE_BYTE 0x30 ~91~
  WRITE_BYTE 0x31 ~30~
  WRITE_BYTE 0x32 ~0~
  WRITE_SHORT 0x46 ~5~
  WRITE_SHORT 0x48 ~5~
  WRITE_BYTE 0x52 ~7~
  WRITE_BYTE 0x53 ~3~
  WRITE_BYTE 0x54 ~3~
  WRITE_BYTE 0x55 ~6~
  WRITE_BYTE 0x56 ~7~
  WRITE_BYTE 0x57 ~6~
  WRITE_BYTE 0x58 ~7~
  WRITE_BYTE 0x59 ~50~
  WRITE_BYTE 0x5a ~100~
  WRITE_BYTE 0x5b ~100~
  WRITE_BYTE 0x5d ~65~
  WRITE_BYTE 0x5e ~25~
  WRITE_BYTE 0x5f ~100~
  WRITE_BYTE 0x60 ~25~
  WRITE_BYTE 0x62 ~50~
  WRITE_BYTE 0x63 ~90~
  WRITE_BYTE 0x234 ~18~
  WRITE_BYTE 0x238 ~18~
  WRITE_BYTE 0x239 ~76~
  WRITE_BYTE 0x23a ~11~
  WRITE_BYTE 0x23b ~14~
  WRITE_BYTE 0x23c ~17~
  WRITE_BYTE 0x23e ~13~
  WRITE_BYTE 0x23f ~20~
  WRITE_BYTE 0x240 ~3~
  WRITE_BYTE 0x242 ~30~
  WRITE_ASCII 0x248 ~BPCRYPT~ #8
  WRITE_ASCII 0x250 ~SHOUTDL2~
  WRITE_ASCII 0x258 ~BPMAG14M~
  WRITE_ASCII 0x260 ~BPLEADER~ #8
  WRITE_ASCII 0x268 ~BPUNDEAD~
  WRITE_BYTE 0x27b ~19~
  WRITE_ASCII 0x280 ~BHCRYPT~ #8

  REPLACE_CRE_ITEM ~SHLD05~ #0 #0 #0 ~NONE~ ~SHIELD~

  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 found1 = 0
  SET found2 = 0
  SET "info_ext" = 0

  FOR( cnt=0; cnt<"%effects_num%"; cnt=cnt+1 ) BEGIN
    READ_LONG ("%effects_offset%"+cnt*0x108+8)  "type"
    PATCH_IF( "%type%"=233 ) BEGIN
      READ_LONG ("%effects_offset%"+cnt*0x108+24) "prof_type"
      PATCH_IF ("%prof_type%"=90) BEGIN
        SET found1=1
        READ_LONG ("%effects_offset%"+cnt*0x108+20) "stars"
        PATCH_IF("%stars%" != 3) BEGIN
          WRITE_LONG ("%effects_offset%"+cnt*0x108+20) 3
        END
      END
      PATCH_IF ("%prof_type%"=112) BEGIN
        SET found2=1
        READ_LONG ("%effects_offset%"+cnt*0x108+20) "stars"
        PATCH_IF("%stars%" != 2) BEGIN
          WRITE_LONG ("%effects_offset%"+cnt*0x108+20) 2
        END
      END
    END
  END
  PATCH_IF( found1=0 ) THEN BEGIN
    SET offset = ("%effects_offset%"+0x108*"%effects_num%")
    INSERT_BYTES offset    0x108
    WRITE_LONG   offset+8  233
    WRITE_LONG   offset+12 0
    WRITE_LONG   offset+20 3
    WRITE_LONG   offset+24 90
    WRITE_LONG   offset+28 9
    WRITE_LONG   offset+36 100
    SET "effects_num"="%effects_num%"+1
    WRITE_LONG  0x2c8  "%effects_num%"
    SET "info_ext"="%info_ext%"+0x108
  END
  PATCH_IF( found2=0 ) THEN BEGIN
    SET offset = ("%effects_offset%"+0x108*"%effects_num%")
    INSERT_BYTES offset    0x108
    WRITE_LONG   offset+8  233
    WRITE_LONG   offset+12 0
    WRITE_LONG   offset+20 2
    WRITE_LONG   offset+24 112
    WRITE_LONG   offset+28 9
    WRITE_LONG   offset+36 100
    SET "effects_num"="%effects_num%"+1
    WRITE_LONG  0x2c8  "%effects_num%"
    SET "info_ext"="%info_ext%"+0x108
  END

  PATCH_IF ("%info_ext%">0) BEGIN
    PATCH_IF ("%known_spells_offset%">="%effects_offset%") BEGIN
      "known_spells_offset"="%known_spells_offset%"+"%info_ext%"
      WRITE_LONG  0x2a0 "%known_spells_offset%"
    END
    PATCH_IF ("%spell_memorization_offset%">="%effects_offset%") BEGIN
      "spell_memorization_offset"="%spell_memorization_offset%"+"%info_ext%"
      WRITE_LONG  0x2a8  "%spell_memorization_offset%"
    END
    PATCH_IF ("%item_slots_offset%">="%effects_offset%") BEGIN
      "item_slots_offset"="%item_slots_offset%"+"%info_ext%"
      WRITE_LONG  0x2b8  "%item_slots_offset%"
    END
    PATCH_IF ("%items_offset%">="%effects_offset%") BEGIN
      "items_offset"="%items_offset%"+"%info_ext%"
      WRITE_LONG  0x2bc  "%items_offset%"
    END
    PATCH_IF ("%spell_memorized_offset%">="%effects_offset%") BEGIN
      "spell_memorized_offset"="%spell_memorized_offset%"+"%info_ext%"
      WRITE_LONG  0x2b0  "%spell_memorized_offset%"
    END
  END
BUT_ONLY_IF_IT_CHANGES


//**************************************************************************************************
//configuring creatures' spell system
//**************************************************************************************************
  PRINT @373

  COPY + ~BHCRYPT.TBL~  ~BP/tmp.tbl~
  COUNT_2DA_ROWS 5 "rows_cnt"
  FOR( cntg=0; cntg<"%rows_cnt%"; cntg=cntg+1 ) BEGIN
    READ_2DA_ENTRY cntg  0 5 "table_file_name"
    READ_2DA_ENTRY cntg  1 5 "spell_name"
    READ_2DA_ENTRY cntg  2 5 "number"
    READ_2DA_ENTRY cntg  3 5 "spell_type_str"
    READ_2DA_ENTRY cntg  4 5 "spell_level"

    SET fileExistsInGame = 0
    INNER_PATCH_FILE "%table_file_name%" BEGIN
      PATCH_IF (~%SOURCE_SIZE%~) BEGIN
        SET fileExistsInGame = 1
      END
    END
    PATCH_IF fileExistsInGame=1 AND FILE_EXISTS_IN_GAME "%spell_name%.SPL" THEN BEGIN
      INNER_ACTION BEGIN
        COPY_EXISTING "%table_file_name%"  ~override~  //patching the file from the current table entry
          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 spell_type = 0  //Priest spell by default
          PATCH_IF (("%spell_type_str%" STRING_COMPARE_CASE "WIZARD")=0) BEGIN
            SET spell_type = 1
          END
          PATCH_IF (("%spell_type_str%" STRING_COMPARE_CASE "INNATE")=0) BEGIN
            SET spell_type = 2
          END

          //**********************************************************************************************************
          // 1st protection : it's necessary to reset yet unused memo-slots to point behind existing memorized spells
          FOR(count=0; count<17; count=count+1) BEGIN
             READ_SHORT ("%spell_memorization_offset%" + count*0x10 + 12) sp2_cnt
             PATCH_IF( sp2_cnt=0 ) BEGIN
               WRITE_SHORT ("%spell_memorization_offset%" + count*0x10 + 8) "%spell_memorized_num%"
             END
          END

          //**********************************************************************************************************
          // 2nd protection : it's necessary to set a valid offset for "spell_memorized_offset"
          //                  it could contain some invalid values
          PATCH_IF (("%effects_num%" == 0)
                AND (("%effects_offset%" < 0x2d4)
                  OR ("%effects_offset%" > BUFFER_LENGTH))) BEGIN
            "effects_offset" = "%spell_memorized_offset%"+"%spell_memorized_num%"*0x10
             WRITE_LONG  0x2c4 "%effects_offset%"
          END
          //**********************************************************************************************************

          FOR(count=0; count<17; count=count+1) BEGIN
             READ_SHORT ("%spell_memorization_offset%" + count*0x10 + 12) sp2_cnt
             PATCH_IF( sp2_cnt=0 ) BEGIN
               WRITE_SHORT ("%spell_memorization_offset%" + count*0x10 + 8) "%spell_memorized_num%"
             END
          END
          //**********************************************************************************************************

          //***********************************************************************************************
          // adding new KNOWN spell if necessary
          //***********************************************************************************************
          SET necessary=1
          FOR (count=0; count<"%known_spells_num%"; count=count+1) BEGIN
            READ_ASCII ("%known_spells_offset%"+count*0x0c) "known_spell_name"
            PATCH_IF (("%known_spell_name%" STRING_COMPARE_CASE "%spell_name%")=0) BEGIN
              SET necessary=0
            END
          END
          PATCH_IF (necessary=1) BEGIN  //adding new known spell
//            //ADD_KNOWN_SPELL ~%spell_name%~ ~%spell_level%~ ~%spell_type%~  ------ for the future WeiDU

            SET offset = "%known_spells_offset%" + "%known_spells_num%"*0x0c
            INSERT_BYTES offset 0x0c
            WRITE_EVALUATED_ASCII offset      ~%spell_name%~ #8
            WRITE_SHORT           offset+8    spell_level
            WRITE_SHORT           offset+10   spell_type
            WRITE_LONG   0x2a4  "%known_spells_num%"+1

            SET info_ext = 0x0c
            PATCH_IF ("%spell_memorized_offset%">="%known_spells_offset%") BEGIN
              "spell_memorized_offset"="%spell_memorized_offset%"+"%info_ext%"
              WRITE_LONG  0x2b0 "%spell_memorized_offset%"
            END
            PATCH_IF ("%spell_memorization_offset%">="%known_spells_offset%") BEGIN
              "spell_memorization_offset"="%spell_memorization_offset%"+"%info_ext%"
              WRITE_LONG  0x2a8  "%spell_memorization_offset%"
            END
            PATCH_IF ("%item_slots_offset%">="%known_spells_offset%") BEGIN
              "item_slots_offset"="%item_slots_offset%"+"%info_ext%"
              WRITE_LONG  0x2b8  "%item_slots_offset%"
            END
            PATCH_IF ("%items_offset%">="%known_spells_offset%") BEGIN
              "items_offset"="%items_offset%"+"%info_ext%"
              WRITE_LONG  0x2bc  "%items_offset%"
            END
            PATCH_IF ("%effects_offset%">="%known_spells_offset%") BEGIN
              "effects_offset"="%effects_offset%"+"%info_ext%"
              WRITE_LONG  0x2c4  "%effects_offset%"
            END
          END
          //***********************************************************************************************/
          //***********************************************************************************************/

          SET slot_idx = "%spell_level%"
          PATCH_IF (("%spell_type_str%" STRING_COMPARE_CASE "WIZARD")=0) BEGIN
            SET slot_idx = "%spell_level%"+7
          END
          PATCH_IF (("%spell_type_str%" STRING_COMPARE_CASE "INNATE")=0) BEGIN
            SET slot_idx = 16
          END
          SET offset_memorization = "%spell_memorization_offset%" + "%slot_idx%"*0x10

          //***********************************************************************************************/
          // adding a necessary quantity of MEMORIZED new spells
          //***********************************************************************************************/
          SET total_add = 0
          FOR (count=0; count<"%spell_memorized_num%"; count=count+1) BEGIN
            READ_ASCII ("%spell_memorized_offset%"+count*0xc) "mem_spell_name"
            PATCH_IF (("%mem_spell_name%" STRING_COMPARE_CASE "%spell_name%")=0) BEGIN
              SET "number" = "%number%" - 1
            END
          END
          //ADD_MEMORIZED_SPELL "%spell_name%" (~%spell_level%~) "%spell_type_str%" (~%number%~)

          READ_LONG offset_memorization+8  current_slot_spell_index
          SET offset = "%spell_memorized_offset%" + current_slot_spell_index*0x0c//"%spell_memorized_num%"
          WHILE ("%number%">0) BEGIN
            INSERT_BYTES offset    0x0c
            WRITE_EVALUATED_ASCII  offset  ~%spell_name%~ #8
            WRITE_SHORT  offset+8  1      //memorized
            SET "number" = "%number%" - 1
            SET total_add = total_add + 1
            SET offset = offset + 0x0c
         END

          PATCH_IF(total_add>0) BEGIN
            SET info_ext = 0x0c * total_add
            WRITE_LONG 0x2b4 "%spell_memorized_num%"+total_add

            READ_SHORT  (offset_memorization+12) innate_spell_count
            WRITE_SHORT (offset_memorization+12) innate_spell_count + total_add
            WRITE_SHORT (offset_memorization+2)  innate_spell_count + total_add
            WRITE_SHORT (offset_memorization+4)  innate_spell_count + total_add
            WRITE_SHORT (offset_memorization+6)  ~%spell_type%~

            FOR(count=0; count<17; count=count+1) BEGIN
                READ_SHORT ("%spell_memorization_offset%" + count*0x10 + 8)  sp2_index
                READ_SHORT ("%spell_memorization_offset%" + count*0x10 + 12) sp2_cnt
                PATCH_IF( count!=slot_idx AND sp2_cnt>0 AND sp2_index>=current_slot_spell_index ) BEGIN
                  WRITE_SHORT ("%spell_memorization_offset%" + count*0x10 + 8)  sp2_index+total_add
                END
            END

            PATCH_IF ("%known_spells_offset%">="%spell_memorized_offset%") BEGIN
              "known_spells_offset"="%known_spells_offset%"+"%info_ext%"
              WRITE_LONG  0x2a0 "%known_spells_offset%"
            END
            PATCH_IF ("%spell_memorization_offset%">="%spell_memorized_offset%") BEGIN
              "spell_memorization_offset"="%spell_memorization_offset%"+"%info_ext%"
              WRITE_LONG  0x2a8  "%spell_memorization_offset%"
            END
            PATCH_IF ("%item_slots_offset%">="%spell_memorized_offset%") BEGIN
              "item_slots_offset"="%item_slots_offset%"+"%info_ext%"
              WRITE_LONG  0x2b8  "%item_slots_offset%"
            END
            PATCH_IF ("%items_offset%">="%spell_memorized_offset%") BEGIN
              "items_offset"="%items_offset%"+"%info_ext%"
              WRITE_LONG  0x2bc  "%items_offset%"
            END
            PATCH_IF ("%effects_offset%">="%spell_memorized_offset%") BEGIN
              "effects_offset"="%effects_offset%"+"%info_ext%"
              WRITE_LONG  0x2c4  "%effects_offset%"
            END
          END
        BUT_ONLY_IF_IT_CHANGES

      END
    END
  END

  LAF undead_rules END

  ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpundead.bcs~ BEGIN
    COMPILE ~bp/baf/new_bad/bpundead.baf~
  END

  ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpcrypt.bcs~ BEGIN
    COMPILE ~bp/baf/re-baf/misc/bpcrypt.baf~
  END  

  ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpmag14m.bcs~ BEGIN
    COMPILE ~bp/baf/re-baf/core/bpmag14m.baf~
  END

  ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpleader.bcs~ BEGIN
    COMPILE ~bp/baf/new_baf/core/bpleader.baf~
  END

END

//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION druid_encounter BEGIN

INCLUDE ~bp/lib/bp_main.tph~
INCLUDE ~bp/lib/bp_creatures.tph~


LAF treant_spell     END


  // Must be done here instead of in the rules, because the creatures used are only here
  // What if some other component just needs the rules &/or scripts?
APPEND_COL ~spawngrp.2da~ ~9999 9999 RDSDruid--- 150!!!!--- bpdru10a--- bpdru8a!!!! bpdrufg2--- bpdrufg1--- bpdrumg1--- bpdru8b!!!! bpdrudt1--- *=======--- ~
  UNLESS ~RDSDruid~
     
COPY_EXISTING ~spawngrp.2da~ ~override~
   REPLACE_TEXTUALLY ~9999~    ~~
   REPLACE_TEXTUALLY ~---~     ~   ~
   REPLACE_TEXTUALLY ~!!!!~    ~    ~
   REPLACE_TEXTUALLY ~++++++~  ~      ~
   REPLACE_TEXTUALLY ~+++++~   ~     ~
   REPLACE_TEXTUALLY ~=======~ ~       ~
   REPLACE_TEXTUALLY ~++~ ~  ~     


COPY ~bp/cre/bpdrpr18.cre~ ~override~
     ~bp/cre/bpdru10a.cre~ ~override~
     ~bp/cre/bpdru8a.cre~ ~override~
     ~bp/cre/bpdru8b.cre~ ~override~
     ~bp/cre/bpdru8ba.cre~ ~override~
     ~bp/cre/bpdrudt1.cre~ ~override~
     ~bp/cre/bpdrufg1.cre~ ~override~
     ~bp/cre/bpdrufg2.cre~ ~override~
     ~bp/cre/bpdrumg1.cre~ ~override~
	 
COMPILE ~bp/d/rtdr10a.d~
     
LAF druid_scripts END

END

//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION treant_encounter BEGIN
INCLUDE ~bp/lib/bp_creatures.tph~

LAF treants END

COPY_EXISTING ~ar1900.bcs~ ~override~
  REPLACE_TEXTUALLY ~IF
  Global("DruidQuest1","GLOBAL",1)
  Global("DruidStronghold","GLOBAL",1)
  Global("Nilthspawn","AR1900",0)
THEN
  RESPONSE #100
    SetGlobal("Nilthspawn","AR1900",1)
    CreateCreature("Drshnl01",[2320.2648],N)
    CreateCreature("Troll01",[2135.2509],NW)
    CreateCreature("Troll01",[2528.2511],NE)
    CreateCreature("Troll01",[2283.2541],16)
END~ ~~
BUT_ONLY

EXTEND_BOTTOM ~ar1900.bcs~ ~bp/snip/nar1900.baf~

END

//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION druids_grove BEGIN

INCLUDE ~bp/lib/bp_main.tph~
INCLUDE ~bp/lib/bp_creatures.tph~

LAF druid_rules END
LAF druid_encounter END


//More spawns and rest interrupts added
COPY_EXISTING ~ar1900.are~ ~override~
  READ_LONG 0x60 spn_off //Spawn offset
  READ_LONG 0x64 spn_cnt //Spawn count
  FOR (i = 0; i < spn_cnt; i += 1) BEGIN //Cycle through spawns
    READ_SHORT (i * 0xc8 + spn_off + 0x20) txc //X coordinate
    READ_SHORT (i * 0xc8 + spn_off + 0x22) tyc //Y coordinate
    READ_ASCII (i * 0xc8 + spn_off + 0x24) tcre //Creature
    PATCH_IF (~%tcre%~ STRING_EQUAL_CASE ~etter01~ = 1) BEGIN
      WRITE_ASCII (i * 0xc8 + spn_off + 0x24) ~rdetter1~ #8
    END
    PATCH_IF (~%tcre%~ STRING_EQUAL_CASE ~troll01~ = 1) BEGIN
      WRITE_ASCII (i * 0xc8 + spn_off + 0x24) ~rdtroll3~ #8
    END
    PATCH_IF (txc = 2622) AND (tyc = 2531) BEGIN
      WRITE_SHORT (i * 0xc8 + spn_off + 0x20) 2925
      WRITE_SHORT (i * 0xc8 + spn_off + 0x22) 2475
    END
  END
  LPF fj_are_structure
    INT_VAR
    fj_loc_x          = 775
    fj_loc_y          = 2575
    fj_spawn_num      = 1
    fj_base_num       = 2
    fj_delay          = 1
    fj_method         = 2
    fj_wander_distance = 1000
    fj_mvmt_distance   = 1000
    fj_max_num        = 1
    STR_VAR
    fj_structure_type = spawn
    fj_name           = ~Spawn Point 10~
    fj_cre_resref0    = rdtroll2
  END
  LPF fj_are_structure
    INT_VAR
    fj_loc_x          = 2155
    fj_loc_y          = 2530
    fj_spawn_num      = 1
    fj_base_num       = 2
    fj_delay          = 1
    fj_method         = 2
    fj_wander_distance = 1000
    fj_mvmt_distance   = 1000
    fj_max_num        = 1
    STR_VAR
    fj_structure_type = spawn
    fj_name           = ~Spawn Point 11~
    fj_cre_resref0    = rdspid3
  END
  LPF fj_are_structure
    INT_VAR
    fj_loc_x          = 350
    fj_loc_y          = 1500
    fj_spawn_num      = 1
    fj_base_num       = 2
    fj_delay          = 1
    fj_method         = 2
    fj_wander_distance = 1000
    fj_mvmt_distance   = 1000
    fj_max_num        = 1
    STR_VAR
    fj_structure_type = spawn
    fj_name           = ~Spawn Point 12~
    fj_cre_resref0    = rdtroll
  END
  LPF fj_are_structure
    INT_VAR
    fj_loc_x          = 3870
    fj_loc_y          = 250
    fj_spawn_num      = 1
    fj_base_num       = 2
    fj_delay          = 1
    fj_method         = 2
    fj_wander_distance = 1000
    fj_mvmt_distance   = 1000
    fj_max_num        = 1
    STR_VAR
    fj_structure_type = spawn
    fj_name           = ~Spawn Point 13~
    fj_cre_resref0    = rdsdruid
  END
  LPF fj_are_structure
    INT_VAR
    fj_cre_strref0    = 10134
    fj_cre_strref1    = 10134
    fj_cre_strref2    = 10134
    fj_cre_strref3    = 10134
    fj_cre_strref4    = 10134
    fj_cre_strref5    = 10134
    fj_spawn_num      = 6
    fj_duration       = 1000
    fj_wander_distance = 1000
    fj_mvmt_distance   = 1000
    fj_difficulty     = 2
    fj_max_num        = 8
    fj_enable         = 1
    fj_day_prob       = 4
    fj_night_prob     = 4
    STR_VAR
    fj_structure_type = interrupts
    fj_cre_resref0    = rdtroll
    fj_cre_resref1    = rdspid2
    fj_cre_resref2    = rdwere
    fj_cre_resref3    = rdetter1
    fj_cre_resref4    = rdspider
    fj_cre_resref5    = rdsdruid
  END
BUT_ONLY


COPY_EXISTING ~dgdru01.bcs~ ~override~
  DECOMPILE_BCS_TO_BAF
   REPLACE_TEXTUALLY ~NearestMyGroupOfType~ ~[NEUTRAL]~
  COMPILE_BAF_TO_BCS
BUT_ONLY

COPY_EXISTING ~drshnl01.cre~ ~override~ //Nilthiri
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x234 12 // HighestLevelPrimary (was 6)
    WRITE_BYTE 0x235 12 // HighestLevelSecond (was 6)
    WRITE_BYTE 0x241 255 // Racial (was 0)
    WRITE_ASCII 0x258 ~drshnl01~ #8 // Race (was NONE)
    WRITE_ASCII 0x260 ~bppri10a~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REMOVE_KNOWN_SPELL ~sppr510~
    REMOVE_MEMORIZED_SPELL ~sppr208~
    REMOVE_MEMORIZED_SPELL ~sppr506~
    REMOVE_MEMORIZED_SPELL ~sppr510~
    REMOVE_MEMORIZED_SPELL ~spwi115~
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr111~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr208~ #1 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr211~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr301~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr310~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr403~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr506~ #4 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr699~ #5 ~priest~
    ADD_MEMORIZED_SPELL ~spwi115~ #0 ~wizard~ (2)
  END
BUT_ONLY

COPY_EXISTING ~druid10a.cre~ ~override~ //Zorl
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    SAY NAME1 #1080
    SAY NAME2 #1080
    WRITE_ASCII 0x250 ~bpdru10a~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~LEAT01~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SW1H20~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~BULL01~ #40 #0 #0 ~NONE~ ~QUIVER1~
    SET_BG2_PROFICIENCY ~PROFICIENCYSCIMITARWAKISASHININJATO~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYSLING~ 1
  END
BUT_ONLY

COPY_EXISTING ~druid10b.cre~ ~override~ //Zorl
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    SAY NAME1 #1080
    SAY NAME2 #1080
    WRITE_ASCII 0x250 ~bpdru10b~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~LEAT01~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SW1H20~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~BULL01~ #40 #0 #0 ~NONE~ ~QUIVER1~
    SET_BG2_PROFICIENCY ~PROFICIENCYSCIMITARWAKISASHININJATO~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYSLING~ 1
  END
BUT_ONLY

COPY_EXISTING ~druid12a.cre~ ~override~ //Zorl
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    SAY NAME1 #1080
    SAY NAME2 #1080
    WRITE_ASCII 0x250 ~bpdru12a~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~LEAT01~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SW1H20~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~BULL01~ #40 #0 #0 ~NONE~ ~QUIVER1~
    SET_BG2_PROFICIENCY ~PROFICIENCYSCIMITARWAKISASHININJATO~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYSLING~ 1
  END
BUT_ONLY

COPY_EXISTING ~druid12b.cre~ ~override~ //Zorl
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    SAY NAME1 #1080
    SAY NAME2 #1080
    WRITE_ASCII 0x250 ~bpdru12b~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~LEAT01~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SW1H20~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~BULL01~ #40 #0 #0 ~NONE~ ~QUIVER1~
    SET_BG2_PROFICIENCY ~PROFICIENCYSCIMITARWAKISASHININJATO~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYSLING~ 1
  END
BUT_ONLY

COPY_EXISTING ~druid6a.cre~ ~override~ //Zorl
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    SAY NAME1 #1080
    SAY NAME2 #1080
    WRITE_ASCII 0x250 ~bpdrud6a~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~LEAT01~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SW1H20~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~BULL01~ #40 #0 #0 ~NONE~ ~QUIVER1~
    SET_BG2_PROFICIENCY ~PROFICIENCYSCIMITARWAKISASHININJATO~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYSLING~ 1
  END
BUT_ONLY

COPY_EXISTING ~druid8a.cre~ ~override~ //Zorl
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    SAY NAME1 #1080
    SAY NAME2 #1080
    WRITE_ASCII 0x250 ~bpdrud8a~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~LEAT01~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SW1H20~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~BULL01~ #40 #0 #0 ~NONE~ ~QUIVER1~
    SET_BG2_PROFICIENCY ~PROFICIENCYSCIMITARWAKISASHININJATO~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYSLING~ 1
  END
BUT_ONLY

COPY_EXISTING ~druid8b.cre~ ~override~ //Zorl
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    SAY NAME1 #1080
    SAY NAME2 #1080
    WRITE_ASCII 0x250 ~bpdrud8b~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~LEAT01~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SW1H20~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~BULL01~ #40 #0 #0 ~NONE~ ~QUIVER1~
    SET_BG2_PROFICIENCY ~PROFICIENCYSCIMITARWAKISASHININJATO~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYSLING~ 1
  END
BUT_ONLY

COPY_EXISTING ~dgdru01.cre~ ~override~ //Druid
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REMOVE_MEMORIZED_SPELL ~sppr401~
    ADD_MEMORIZED_SPELL ~sppr105~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr110~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr111~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr208~ #1 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr306~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr312~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr319~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr401~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr407~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr410~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr411~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr503~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr506~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr602~ #5 ~priest~
    REPLACE_CRE_ITEM ~HELM01~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~STAF02~ #0 #0 #0 ~NONE~ ~WEAPON1~
    REPLACE_CRE_ITEM ~DART01~ #30 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
    REPLACE_CRE_ITEM ~RNDTRE03~ #0 #0 #0 ~NONE~ ~INV~
    SET_BG2_PROFICIENCY ~PROFICIENCYQUARTERSTAFF~ 2
    SET_BG2_PROFICIENCY ~PROFICIENCYDART~ 3
  END
BUT_ONLY

COPY ~bp/cre/dgdru02.cre~ ~override~

COPY_EXISTING ~dgfig01.cre~ ~override~ //Fighter
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~dgtrol01.cre~ ~override~ //Troll
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x239 100 // StrBon (was 0)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~dgtrol02.cre~ ~override~ //Troll
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x239 100 // StrBon (was 0)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~dgmag01.cre~ ~override~ //Mage
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spwi217~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi309~ #2 ~wizard~
    REPLACE_CRE_ITEM ~DART01~ #30 #0 #0 ~NONE~ ~WEAPON1~
    REPLACE_CRE_ITEM ~STAF01~ #0 #0 #0 ~NONE~ ~WEAPON2~ EQUIP TWOHANDED
  END
BUT_ONLY

COPY_EXISTING ~cedruid2.cre~ ~override~ //Dalok
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_LONG 0x1c 26 // Goldcarried (was 0)
    WRITE_SHORT 0x24 82 // CurrHP (was 80)
    WRITE_SHORT 0x26 82 // MaxHP (was 80)
    WRITE_BYTE 0x238 16 // Str (was 13)
    WRITE_BYTE 0x23a 10 // Int (was 12)
    WRITE_BYTE 0x23d 15 // Con (was 13)
    WRITE_ASCII 0x250 ~bpdru12b~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~sppr101~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr105~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr111~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr202~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr203~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr204~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr208~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr210~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr211~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr302~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr303~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr310~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr315~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr319~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr306~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr401~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr405~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr407~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr410~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr411~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr501~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr505~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr505d~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr506~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr517~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr605~ #5 ~priest~
    ADD_MEMORIZED_SPELL ~sppr607~ #5 ~priest~
    ADD_MEMORIZED_SPELL ~sppr613~ #5 ~priest~
    REPLACE_CRE_ITEM ~HELM01~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~LEAT10~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SHLD09~ #0 #0 #0 ~NONE~ ~SHIELD~
    REPLACE_CRE_ITEM ~DART01~ #30 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
    SET_BG2_PROFICIENCY ~PROFICIENCYDART~ 2
    SET_BG2_PROFICIENCY ~PROFICIENCYSWORDANDSHIELD~ 2
    SET_BG2_PROFICIENCY ~EXTRAPROFICIENCY1~ 2
  END
BUT_ONLY

COPY_EXISTING ~cefald01.cre~ ~override~ //Faldorn
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x260 ~~ #8 // General (was WTASIGHT)
    REMOVE_MEMORIZED_SPELL ~sppr103~
    REMOVE_MEMORIZED_SPELL ~sppr319~
    REMOVE_MEMORIZED_SPELL ~sppr506~
    ADD_MEMORIZED_SPELL ~sppr103~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr102~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr111~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr113~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr202~ #1 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr204~ #1 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr212~ #1 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr319~ #2 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr306~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr310~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr315~ #2 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr401~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr402~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr411~ #3 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr506~ #4 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr503~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr508~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr711~ #6 ~priest~
    SET_BG2_PROFICIENCY ~PROFICIENCYQUARTERSTAFF~ 2
  END
BUT_ONLY

COPY_EXISTING ~cefald02.cre~ ~override~ //Faldorn
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 66 // CurrHP (was 33)
    WRITE_SHORT 0x26 66 // MaxHP (was 33)
    WRITE_ASCII 0x248 ~cefald02~ #8 // Override (was GENSHT01)
  END
BUT_ONLY

COPY_EXISTING ~cefald04.cre~ ~override~ //Faldorn
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_LONG 0x18 3000000 // PowerLevel (was 13197)
    WRITE_LONG 0x1c 0 // Goldcarried (was 10)
    WRITE_SHORT 0x24 84 // CurrHP (was 30)
    WRITE_SHORT 0x26 84 // MaxHP (was 30)
    WRITE_SHORT 0x46 3 // ACNatul (was 10)
    WRITE_SHORT 0x48 3 // ACEffec (was 10)
    WRITE_BYTE 0x52 12 // THAC0 (was 18)
    WRITE_BYTE 0x54 5 // SaveVDth (was 9)
    WRITE_BYTE 0x55 9 // SaveVWnd (was 13)
    WRITE_BYTE 0x56 8 // SaveVPoly (was 12)
    WRITE_BYTE 0x57 11 // SaveVAtks (was 15)
    WRITE_BYTE 0x58 10 // SaveVspell (was 14)
    WRITE_BYTE 0x66 0 // Lore (was 5)
    WRITE_BYTE 0x234 15 // HighestLevelPrimary (was 5)
    WRITE_BYTE 0x23f 20 // Mor (was 10)
    WRITE_BYTE 0x240 1 // Morbrk (was 5)
    WRITE_ASCII 0x258 ~bpdru14g~ #8 // Race (was CEFALD03)
    WRITE_ASCII 0x260 ~~ #8 // General (was WTASIGHT)
    REMOVE_KNOWN_SPELL ~sppr101~
    REMOVE_KNOWN_SPELL ~sppr104~
    REMOVE_KNOWN_SPELL ~sppr105~
    REMOVE_KNOWN_SPELL ~sppr108~
    REMOVE_KNOWN_SPELL ~sppr110~
    REMOVE_KNOWN_SPELL ~sppr205~
    REMOVE_KNOWN_SPELL ~sppr206~
    REMOVE_KNOWN_SPELL ~sppr207~
    REMOVE_KNOWN_SPELL ~sppr209~
    REMOVE_KNOWN_SPELL ~sppr210~
    REMOVE_KNOWN_SPELL ~sppr305~
    REMOVE_KNOWN_SPELL ~sppr309~
    REMOVE_KNOWN_SPELL ~sppr404~
    REMOVE_MEMORIZED_SPELL ~sppr105~
    REMOVE_MEMORIZED_SPELL ~sppr108~
    REMOVE_MEMORIZED_SPELL ~sppr103~
    REMOVE_MEMORIZED_SPELL ~sppr209~
    REMOVE_MEMORIZED_SPELL ~sppr207~
    REMOVE_MEMORIZED_SPELL ~sppr206~
    REMOVE_MEMORIZED_SPELL ~sppr302~
    ADD_MEMORIZED_SPELL ~sppr103~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr111~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr113~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr204~ #1 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr212~ #1 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr302~ #2 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr319~ #2 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr306~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr310~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr315~ #2 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr410~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr401~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr402~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr411~ #3 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr506~ #4 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr503~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr508~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr607~ #5 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr604~ #5 ~priest~
    ADD_MEMORIZED_SPELL ~sppr711~ #6 ~priest~
    ADD_MEMORIZED_SPELL ~sppr702~ #6 ~priest~
    REMOVE_CRE_ITEM ~LEAT01~ ~BLUN01~
    REPLACE_CRE_ITEM ~BLUN31~ #0 #0 #0 ~NONE~ ~WEAPON1~
    REPLACE_CRE_ITEM ~SLNG02~ #0 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
    REPLACE_CRE_ITEM ~BULL02~ #40 #0 #0 ~NONE~ ~QUIVER1~
    REPLACE_CRE_ITEM ~HELM01~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~LEAT07~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SHLD17~ #0 #0 #0 ~NONE~ ~SHIELD~
    SET_BG2_PROFICIENCY ~EXTRAPROFICIENCY1~ 2
    SET_BG2_PROFICIENCY ~PROFICIENCYSLING~ 2
  END
BUT_ONLY

COPY_EXISTING ~cefaldor.cre~ ~override~ //Faldorn
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~shoutdlg~ #8 // Override (was FALDORN)
    WRITE_ASCII 0x250 ~drdsht01~ #8 // Class (was CEFALDOR)
    WRITE_ASCII 0x258 ~faldorn~ #8 // Race (was SHOUTDLG)
    WRITE_ASCII 0x260 ~cefaldor~ #8 // General (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was DRDSHT01)
  END
BUT_ONLY

COPY_EXISTING ~cefgt01.cre~ ~override~ //Adherent
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x46 6 // ACNatul (was 10)
    WRITE_SHORT 0x48 6 // ACEffec (was 10)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~cefgt02.cre~ ~override~ //Shadow Druid
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REMOVE_MEMORIZED_SPELL ~sppr202~
    REMOVE_MEMORIZED_SPELL ~sppr514~
    ADD_MEMORIZED_SPELL ~sppr105~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr110~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr111~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr113~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr202~ #1 ~priest~ (4)
    ADD_MEMORIZED_SPELL ~sppr213~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr208~ #1 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr310~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr315~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr319~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr402~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr411~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr514~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr503~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr506~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr610~ #5 ~priest~
    REPLACE_CRE_ITEM ~SHLD08~ #0 #0 #0 ~NONE~ ~SHIELD~
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
    REPLACE_CRE_ITEM ~BULL01~ #30 #0 #0 ~NONE~ ~QUIVER1~
  END
BUT_ONLY

COPY_EXISTING ~cefgt04.cre~ ~override~ //Shadow Druid
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REMOVE_KNOWN_SPELL ~sppr502~
    REMOVE_KNOWN_SPELL ~sppr605~
    REMOVE_MEMORIZED_SPELL ~sppr202~
    REMOVE_MEMORIZED_SPELL ~sppr502~
    REMOVE_MEMORIZED_SPELL ~sppr605~
    ADD_MEMORIZED_SPELL ~sppr105~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr111~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr113~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr202~ #1 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr203~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr206~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr302~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr306~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr319~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr410~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr411~ #3 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr506~ #4 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr514~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr517~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr604~ #5 ~priest~
    ADD_MEMORIZED_SPELL ~sppr607~ #5 ~priest~
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
    REPLACE_CRE_ITEM ~BULL01~ #30 #0 #0 ~NONE~ ~QUIVER1~
    SET_BG2_PROFICIENCY ~PROFICIENCYQUARTERSTAFF~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYSLING~ 1
  END
BUT_ONLY

COPY_EXISTING ~gdruid.cre~ ~override~ //Great Druid
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    SAY NAME1 #2539
    SAY NAME2 #2539
    WRITE_SHORT 0x24 98 // CurrHP (was 90)
    WRITE_SHORT 0x26 98 // MaxHP (was 90)
    WRITE_SHORT 0x46 4 // ACNatul (was 10)
    WRITE_SHORT 0x48 4 // ACEffec (was 10)
    WRITE_BYTE 0x59 50 // RstFire (was 0)
    WRITE_BYTE 0x5a 20 // RstCold (was 0)
    WRITE_BYTE 0x5b 80 // RstElec (was 0)
    WRITE_BYTE 0x5c 20 // RstAcid (was 0)
    WRITE_BYTE 0x5d 20 // RstMagc (was 0)
    WRITE_BYTE 0x5e 80 // RstMFre (was 0)
    WRITE_BYTE 0x5f 50 // RstMCld (was 0)
    WRITE_BYTE 0x60 25 // RstSlash (was 0)
    WRITE_BYTE 0x61 25 // RstCrush (was 0)
    WRITE_BYTE 0x62 25 // RstPierc (was 0)
    WRITE_BYTE 0x63 40 // RstMissl (was 0)
    WRITE_BYTE 0x234 20 // HighestLevelPrimary (was 14)
    WRITE_BYTE 0x23a 15 // Int (was 14)
    WRITE_BYTE 0x23b 21 // Wis (was 16)
    WRITE_BYTE 0x23d 14 // Con (was 9)
    WRITE_BYTE 0x23e 19 // Cha (was 13)
    WRITE_ASCII 0x248 ~gdruid~ #8 // Override (was DRUID14G)
    WRITE_ASCII 0x268 ~~ #8 // Default (was WTASIGHT)
    REMOVE_KNOWN_SPELL ~sppr604~
    REMOVE_MEMORIZED_SPELL ~sppr319~
    REMOVE_MEMORIZED_SPELL ~sppr315~
    REMOVE_MEMORIZED_SPELL ~sppr401~
    REMOVE_MEMORIZED_SPELL ~sppr610~
    REMOVE_MEMORIZED_SPELL ~sppr604~
    REMOVE_MEMORIZED_SPELL ~sppr711~
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~ (3)
    ADD_MEMORIZED_SPELL ~sppr110~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr111~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr113~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr202~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr210~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr212~ #1 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr211~ #1 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr319~ #2 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr315~ #2 ~priest~ (3)
    ADD_MEMORIZED_SPELL ~sppr401~ #3 ~priest~ (4)
    ADD_MEMORIZED_SPELL ~sppr410~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr503~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr506~ #4 ~priest~ (4)
    ADD_MEMORIZED_SPELL ~sppr505~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr610~ #5 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr711~ #6 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr716~ #6 ~priest~ (2)
    REPLACE_CRE_ITEM ~HELMNOAN~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~LEAT10~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SHLD17~ #0 #0 #0 ~NONE~ ~SHIELD~
    REPLACE_CRE_ITEM ~SW1H22~ #0 #0 #0 ~NONE~ ~WEAPON1~
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
    REPLACE_CRE_ITEM ~BULL02~ #40 #0 #0 ~NONE~ ~QUIVER1~
    SET_BG2_PROFICIENCY ~PROFICIENCYSCIMITARWAKISASHININJATO~ 3
    SET_BG2_PROFICIENCY ~PROFICIENCYSLING~ 3
    SET_BG2_PROFICIENCY ~PROFICIENCYSWORDANDSHIELD~ 2
  END
BUT_ONLY

COPY_EXISTING ~trrak02.cre~ ~override~ //Saadat
              ~trrak03.cre~ ~override~ //Jalaal
              ~trrak04.cre~ ~override~ //Ruhk
              ~trevil01.cre~ ~override~ //Lord Khellon Menold
              ~trevil02.cre~ ~override~ //Guardian of the Source
              ~trevil03.cre~ ~override~ //Master Verthan
              ~trrak01.cre~ ~override~ //Adratha
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    // WRITE_BYTE 0x270 255 // EnemyAlly (was 128)
  END
BUT_ONLY

COPY_EXISTING ~tdr10a.cre~ ~override~ //Kyland Lind
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x258 ~bpdru10a~ #8 // Yes I put your "mod-stick" in the script, BWP boys :P
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~sppr101~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr105~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr111~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~spin107~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr202~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr204~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr302~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr310~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr410~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr411~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr506~ #4 ~priest~
    REPLACE_CRE_ITEM ~HELM01~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~LEAT11~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SHLD17~ #0 #0 #0 ~NONE~ ~SHIELD~
    REPLACE_CRE_ITEM ~SW1H22~ #0 #0 #0 ~NONE~ ~WEAPON1~
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
    REPLACE_CRE_ITEM ~BULL03~ #12 #0 #0 ~NONE~ ~QUIVER1~
    SET_BG2_PROFICIENCY ~PROFICIENCYSCIMITARWAKISASHININJATO~ 2
    SET_BG2_PROFICIENCY ~PROFICIENCYSLING~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYSWORDANDSHIELD~ 2
  END
BUT_ONLY

COPY_EXISTING ~tdr10b.cre~ ~override~ //Shadow Druid
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x250 ~bpdru10a~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr110~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr111~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr113~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr202~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr203~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr204~ #1 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr211~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr302~ #2 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr310~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr315~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr401~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr406~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr503~ #4 ~priest~
    REPLACE_CRE_ITEM ~HELM01~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~LEAT10~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SPER02~ #0 #0 #0 ~NONE~ ~WEAPON1~
    REPLACE_CRE_ITEM ~DAGG05~ #20 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
    SET_BG2_PROFICIENCY ~PROFICIENCYDAGGER~ 2
    SET_BG2_PROFICIENCY ~PROFICIENCYSPEAR~ 2
  END
BUT_ONLY

COPY_EXISTING ~tdr6a.cre~ ~override~ //Shadow Druid
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x250 ~bpdrud6a~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REMOVE_MEMORIZED_SPELL ~sppr111~
    REMOVE_MEMORIZED_SPELL ~sppr208~
    ADD_MEMORIZED_SPELL ~sppr105~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr111~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr202~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr213~ #1 ~priest~
    REPLACE_CRE_ITEM ~LEAT10~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~BLUN01~ #0 #0 #0 ~NONE~ ~WEAPON1~
    REPLACE_CRE_ITEM ~DART01~ #25 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
    SET_BG2_PROFICIENCY ~PROFICIENCYDART~ 1
    SET_BG2_PROFICIENCY ~EXTRAPROFICIENCY1~ 1
  END
BUT_ONLY

COPY_EXISTING ~tdr8a.cre~ ~override~ //Shadow Druid
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x250 ~bpdrud8a~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr110~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr113~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr202~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr206~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr315~ #2 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr410~ #3 ~priest~
    REPLACE_CRE_ITEM ~HELM01~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~LEAT10~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SW1H20~ #0 #0 #0 ~NONE~ ~WEAPON1~
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
    REPLACE_CRE_ITEM ~BULL01~ #30 #0 #0 ~NONE~ ~QUIVER1~
    SET_BG2_PROFICIENCY ~PROFICIENCYSCIMITARWAKISASHININJATO~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYDART~ 1
    SET_BG2_PROFICIENCY ~EXTRAPROFICIENCY1~ 1
  END
BUT_ONLY

COPY_EXISTING ~tdr8b.cre~ ~override~ //Shadow Druid
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x238 16 // Str (was 13)
    WRITE_ASCII 0x250 ~bpdrud8b~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~sppr105~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr108~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr109~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr113~ #0 ~priest~
    ADD_MEMORIZED_SPELL ~sppr202~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr204~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr206~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr212~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr310~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr315~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr312~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr411~ #3 ~priest~
    REPLACE_CRE_ITEM ~HELM01~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~LEAT10~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SW1H20~ #0 #0 #0 ~NONE~ ~SHIELD~
    REPLACE_CRE_ITEM ~SW1H20~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    SET_BG2_PROFICIENCY ~PROFICIENCYSCIMITARWAKISASHININJATO~ 2
    SET_BG2_PROFICIENCY ~PROFICIENCY2WEAPON~ 2
  END
BUT_ONLY


ACTION_IF NOT FILE_EXISTS_IN_GAME ~bppri10a.bcs~ BEGIN
  COMPILE ~bp/baf/re-baf/core/bppri10a.baf~
END


ACTION_IF NOT FILE_EXISTS_IN_GAME ~cefald02.bcs~ BEGIN
  COMPILE ~bp/baf/new_baf/druid/cefald02.baf~
END

EXTEND_BOTTOM ~ar1904.bcs~ ~bp/snip/bar1904.baf~

COPY_EXISTING ~trevil.bcs~ ~override~
  REPLACE_TEXTUALLY ~bp/SNIP/oTREVIL.baf~ ~bp/SNIP/nTREVIL.baf~
BUT_ONLY


END

////////////Gnome Fighter/Illusionist, by Kensai Ryu///////////
//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION gnome_fighter_illusionist BEGIN


COPY ~BP/KRGNOME/KRFAM01.cre~       ~override/KRFAM01.cre~        

COPY ~BP/KRGNOME/KRFAM02.cre~       ~override/KRFAM02.cre~        

COPY ~BP/KRGNOME/KRGNOME.cre~       ~override/KRGNOME.cre~        

COMPILE ~BP/KRGNOME/COMPILE~

ACTION_IF NOT FILE_EXISTS_IN_GAME ~KRGNOME.bcs~ BEGIN
  COMPILE ~bp/krgnome/krgnome.baf~
END

ACTION_IF FILE_EXISTS_IN_GAME ~AR0326.BCS~ THEN BEGIN
  EXTEND_BOTTOM ~AR0326.BCS~  ~BP/KRGNOME/AR0326.BAF~
END
ELSE BEGIN
  COMPILE ~BP/KRGNOME/AR0326.BAF~
END


END

//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION hell_trials BEGIN

INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF hell_trial_scripts END

COPY_EXISTING ~beheld01.cre~ ~override~ //Elder Orb
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~cresht01~ #8
    WRITE_ASCII 0x260 ~bpbeheld~ #8
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
    ADD_MEMORIZED_SPELL ~spwi112~ #0 ~wizard~ (5)
    ADD_MEMORIZED_SPELL ~spwi219~ #1 ~wizard~ (3)
    ADD_MEMORIZED_SPELL ~spwi311~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi408~ #3 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi509~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi609~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi611~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi612~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi702~ #6 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi716~ #6 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi813~ #7 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi815~ #7 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi898~ #7 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi909~ #8 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi912~ #8 ~wizard~
  END
BUT_ONLY

COPY_EXISTING ~behgau01.cre~ ~override~ //Gauth
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~cresht01~ #8
    WRITE_ASCII 0x260 ~bpgauth1~ #8
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~hellgree.cre~ ~override~ //Greed
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpdemon~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~hdragsil.cre~ ~override~ //Dragon
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x250 ~bpmag10b~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~hellfear.cre~ ~override~ //Fear
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~bpdemon~ #8 // Override (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~hellgen.cre~ ~override~ //Enslaved Genie
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~initin15~ #8 // Class (was HELLGEN)
    WRITE_ASCII 0x258 ~bpmag20b~ #8 // Race (was INITIN15)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~hellsare.cre~ ~override~ //Wraith Sarevok
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    // ADD_CRE_ITEM ~PLATSAR~ #0 #0 #0 ~NONE~ ~ARMOR~ - INVALID ITEM
  END
BUT_ONLY

COPY_EXISTING ~hellslay.cre~ ~override~ //Slayer
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~bpmag20a~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~hellbeh1.cre~ ~override~ //Elder Orb
              ~hellbeh2.cre~ ~override~ //Elder Orb
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~cresht01~ #8
    WRITE_ASCII 0x260 ~bpbeheld~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY



COPY_EXISTING ~chevil01.cre~ ~override~ //Doppleganger
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwtrsgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~chevil02.cre~ ~override~ //Doppleganger
              ~chevil04.cre~ ~override~ //Sahuagin
              ~chgood01.cre~ ~override~ //Commoner
              ~chgood02.cre~ ~override~ //Commoner
              ~chgood03.cre~ ~override~ //Commoner
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~chevil03.cre~ ~override~ //Ogre Mage
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 83 // CurrHP (was 25)
    WRITE_SHORT 0x26 83 // MaxHP (was 25)
    WRITE_SHORT 0x46 4 // ACNatul (was 6)
    WRITE_SHORT 0x48 4 // ACEffec (was 6)
    WRITE_BYTE 0x52 12 // THAC0 (was 15)
    WRITE_BYTE 0x54 9 // SaveVDth (was 11)
    WRITE_BYTE 0x55 11 // SaveVWnd (was 13)
    WRITE_BYTE 0x58 10 // SaveVspell (was 14)
    WRITE_BYTE 0x5a 100 // RstCold (was 0)
    WRITE_BYTE 0x5b 50 // RstElec (was 0)
    WRITE_BYTE 0x5f 50 // RstMCld (was 0)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 5)
    WRITE_ASCII 0x258 ~bpmage3~ #8 // Race (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was OGMAGI01)
    REMOVE_KNOWN_SPELL ~spwi316~
    REMOVE_MEMORIZED_SPELL ~spwi112~
    REMOVE_MEMORIZED_SPELL ~spwi308~
    REMOVE_MEMORIZED_SPELL ~spwi316~
    ADD_MEMORIZED_SPELL ~spwi105~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi112~ #0 ~wizard~ (3)
    ADD_MEMORIZED_SPELL ~spwi118~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi206~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi212~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi308~ #2 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi311~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi305~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi404~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi405~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi408~ #3 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi508~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi607~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi609~ #5 ~wizard~
    REPLACE_CRE_ITEM ~RNDTRE03~ #0 #0 #0 ~NONE~ ~INV~
    REPLACE_CRE_ITEM ~RNDTRE04~ #0 #0 #0 ~NONE~ ~INV~
  END
BUT_ONLY

COPY_EXISTING ~chevil05.cre~ ~override~ //Gnoll Captain
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~bpleader~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~chevil06.cre~ ~override~ //Drow Wizard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8
    WRITE_ASCII 0x268 ~bpwtsigt~ #8
    REPLACE_CRE_ITEM ~DART05~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~chevil07.cre~ ~override~ //Drow Wizard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8
    WRITE_ASCII 0x260 ~bpdrow~   #8
    WRITE_ASCII 0x268 ~bppri12a~ #8
    REPLACE_CRE_ITEM ~DART05~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~chevil08.cre~ ~override~ //Bodhi
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8
    WRITE_ASCII 0x260 ~~ #8 // General (was USEITEM)
    WRITE_ASCII 0x268 ~bpvamp01~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~chevil09.cre~ ~override~ //Jon Irenicus
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 136 // CurrHP (was 96)
    WRITE_SHORT 0x26 136 // MaxHP (was 96)
    WRITE_ASCII 0x250 ~humansht~ #8
    WRITE_ASCII 0x258 ~aesgar~ #8 // Race (was USEITEM)
    WRITE_ASCII 0x268 ~wgarsgt~ #8 // Default (was AESGAR)
  END
BUT_ONLY

COPY_EXISTING ~chevil10.cre~ ~override~ //Sarevok
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8
    WRITE_ASCII 0x268 ~sarevtob~ #8 // Default (was CFIGH20A)
    WRITE_BYTE 0x274 0 // IDSSpecifc (was 66)
    ADD_MEMORIZED_SPELL ~spcl900~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl901~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl904~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl905~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl906~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl907~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~chgood04.cre~ ~override~ //Knight of the Order
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8 
    WRITE_ASCII 0x268 ~bpcfig2b~ #8 // Default (was CFIGH20B)
  END
BUT_ONLY

COPY_EXISTING ~chgood05.cre~ ~override~ //Knight of the Order
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8 
    WRITE_ASCII 0x268 ~bpwtrsgt~ #8 // Default (was CFIGH20B)
  END
BUT_ONLY

COPY_EXISTING ~chgood06.cre~ ~override~ //Knight of the Order
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8 
    WRITE_ASCII 0x268 ~bpcpal2a~ #8 // Default (was CFIGH20B)
    ADD_MEMORIZED_SPELL ~spcl211~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl213~ #0 ~innate~ (5)
  END
BUT_ONLY

COPY_EXISTING ~chgood07.cre~ ~override~ //Knight of the Order
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8 
  END
BUT_ONLY

COPY_EXISTING ~chgood08.cre~ ~override~ //Aran Linvail
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8 
    WRITE_ASCII 0x258 ~~ #8 // Race (was USEITEM)
    WRITE_ASCII 0x268 ~bpcpal2a~ #8 // Default (was CFIGH20B)
  END
BUT_ONLY

COPY_EXISTING ~chgood09.cre~ ~override~ //Ellesime
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8 
    WRITE_ASCII 0x268 ~bpccle2b~ #8
    REMOVE_KNOWN_SPELL ~sppr502~
    REMOVE_KNOWN_SPELL ~sppr702~
    REMOVE_KNOWN_SPELL ~sppr707~
    REMOVE_KNOWN_SPELL ~sppr708~
    REMOVE_KNOWN_SPELL ~sppr717~
    REMOVE_MEMORIZED_SPELL ~sppr208~
    REMOVE_MEMORIZED_SPELL ~sppr401~
    REMOVE_MEMORIZED_SPELL ~sppr502~
    REMOVE_MEMORIZED_SPELL ~sppr506~
    REMOVE_MEMORIZED_SPELL ~sppr514~
    REMOVE_MEMORIZED_SPELL ~sppr708~
    REMOVE_MEMORIZED_SPELL ~sppr717~
    REMOVE_MEMORIZED_SPELL ~sppr707~
    ADD_MEMORIZED_SPELL ~sppr208~ #1 ~priest~ (4)
    ADD_MEMORIZED_SPELL ~sppr310~ #2 ~priest~ (4)
    ADD_MEMORIZED_SPELL ~sppr401~ #3 ~priest~ (3)
    ADD_MEMORIZED_SPELL ~sppr416~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr517~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr506~ #4 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr514~ #4 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr698~ #5 ~priest~
    ADD_MEMORIZED_SPELL ~sppr601~ #5 ~priest~
    ADD_MEMORIZED_SPELL ~sppr605~ #5 ~priest~
    ADD_MEMORIZED_SPELL ~sppr709~ #6 ~priest~
    ADD_MEMORIZED_SPELL ~sppr710~ #6 ~priest~
    ADD_MEMORIZED_SPELL ~sppr721~ #6 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr722~ #6 ~priest~
  END
BUT_ONLY

COPY_EXISTING ~chsam01.cre~ ~override~ //Semaj
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x2cc ~~ #8 // Dlg (was CHSAM01)
    WRITE_ASCII 0x250 ~humansht~ #8 
    WRITE_ASCII 0x268 ~bpgpmag1~ #8
    SET_BG2_PROFICIENCY ~PROFICIENCYQUARTERSTAFF~ 1
  END
BUT_ONLY

COPY_EXISTING ~chsam02.cre~ ~override~ //Semaj
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8 
    WRITE_ASCII 0x268 ~bpgpmag1~ #8
    WRITE_ASCII 0x2cc ~~ #8 // Dlg (was CHSAM01)
    REMOVE_KNOWN_SPELL ~spwi813~
    SET_BG2_PROFICIENCY ~PROFICIENCYQUARTERSTAFF~ 1
  END
BUT_ONLY

COPY_EXISTING ~chtaz01.cre~ ~override~ //Tazok
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8 
    WRITE_ASCII 0x268 ~bpcfig2b~ #8
    WRITE_ASCII 0x2cc ~~ #8 // Dlg (was CHTAZ01)
  END
BUT_ONLY

COPY_EXISTING ~chwraith.cre~ ~override~ //Child Spirit
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8 
    WRITE_ASCII 0x258 ~bpmag14m~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpwtsigt~ #8
  END
BUT_ONLY


END

//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION horreds_lair BEGIN

COPY ~bp/bam/lizard~ ~override~
COPY ~bp/bam/itm~    ~override~
COPY ~bp/sfx/horred~ ~override~


INCLUDE ~bp/lib/bp_main.tph~


LAF tooltip_horreds_lair END 
LAF telekinesis END
LAF demon_rules END
LAF thief_rules END
LAF undead_rules END


COPY ~bp/spl/spin460.spl~ ~override~
  SAY NAME1 @150 //Enemy Summon Ghast

COPY ~bp/spl/spin461.spl~ ~override~
  SAY NAME1 @150 //Enemy Summon Ghast

COPY ~bp/spl/sumshad.spl~ ~override~
  SAY NAME1 @155 //Summon Shadow Fiends


COPY ~bp/cre/lshadfi.cre~ ~override~

COPY ~bp/cre/lshadow.cre~ ~override~

COPY ~bp/cre/bpghast.cre~ ~override~
  SAY NAME1 @359 //Greater Ghast
  SAY NAME2 @359 //Greater Ghast


COPY ~bp/itm/bpratbit.itm~ ~override~
  SAY NAME1 @48 //Rat Bite
  SAY NAME2 @48 //Rat Bite
  SAY UNIDENTIFIED_DESC @49
  SAY DESC @49



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

//Has a travel trigger added---to Horred's Lair
COPY_EXISTING ~ar0020.are~ ~override~
 READ_LONG  0x54  "actors_offset"
 READ_LONG  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"

// Adding our new entrance

 SET "new_enter" ="%entrances_offset%" + (0x68*"%entrances_num%")
  INSERT_BYTES "%new_enter%" 0x68
  WRITE_ASCII "%new_enter%" ~Exit8050~ #32    //changing entrance name
  WRITE_SHORT "%new_enter%"+0x20 ~502~
  WRITE_SHORT "%new_enter%"+0x22 ~626~
  WRITE_SHORT "%new_enter%"+0x24 ~8~
  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 ("%infotrig_offset%">="%entrances_offset%") BEGIN
   "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
   WRITE_LONG  0x5c  "%infotrig_offset%"
 END
 PATCH_IF ("%spawns_offset%">="%entrances_offset%") BEGIN
   "spawns_offset"="%spawns_offset%"+"%info_ext%"
   WRITE_LONG  0x60  "%spawns_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 ("%vert_offset%">="%entrances_offset%") BEGIN
   "vert_offset"="%vert_offset%"+"%info_ext%"
   WRITE_LONG  0x7c  "%vert_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

//adding new Travel trigger  *******************************
   SET offset = ("%infotrig_offset%"+0xc4*"%infotrig_num%")
   INSERT_BYTES offset 0xc4
   WRITE_ASCII offset ~TRAN8050~
   WRITE_SHORT (offset+0x20) 2            //travel trigger
   WRITE_SHORT (offset+0x22) 457         //bounding box
   WRITE_SHORT (offset+0x24) 646         //bounding box
   WRITE_SHORT (offset+0x26) 499         //bounding box
   WRITE_SHORT (offset+0x28) 678         //bounding box
   WRITE_SHORT (offset+0x2a) 17            //vertices number
   WRITE_LONG  (offset+0x2c) "%vert_num%" //first vertex index
   WRITE_LONG  (offset+0x34) 28           //cursor frame number
   WRITE_ASCII (offset+0x38) ~AR8050~    //destination area
   WRITE_ASCII (offset+0x40) ~Exit0020~   //entrance name
   WRITE_LONG  (offset+0x60) 4            //party required flag
   WRITE_ASCII (offset+0x7c) ~~ #8      //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 vertices for the new trigger
   SET offset = ("%vert_offset%"+0x04*"%vert_num%")
   INSERT_BYTES offset (0x04*17)
   WRITE_SHORT  offset      498
   WRITE_SHORT  (offset+2)  657
   WRITE_SHORT  (offset+4)  499
   WRITE_SHORT  (offset+6)  664
   WRITE_SHORT  (offset+8)  499
   WRITE_SHORT  (offset+10) 668
   WRITE_SHORT  (offset+12) 495
   WRITE_SHORT  (offset+14) 672
   WRITE_SHORT  (offset+16) 490
   WRITE_SHORT  (offset+18) 676
   WRITE_SHORT  (offset+20) 483
   WRITE_SHORT  (offset+22) 678
   WRITE_SHORT  (offset+24) 475
   WRITE_SHORT  (offset+26) 678
   WRITE_SHORT  (offset+28) 466
   WRITE_SHORT  (offset+30) 676
   WRITE_SHORT  (offset+32) 459
   WRITE_SHORT  (offset+34) 670
   WRITE_SHORT  (offset+36) 457
   WRITE_SHORT  (offset+38) 663
   WRITE_SHORT  (offset+40) 459
   WRITE_SHORT  (offset+42) 654
   WRITE_SHORT  (offset+44) 463
   WRITE_SHORT  (offset+46) 649
   WRITE_SHORT  (offset+48) 469
   WRITE_SHORT  (offset+50) 647
   WRITE_SHORT  (offset+52) 477
   WRITE_SHORT  (offset+54) 646
   WRITE_SHORT  (offset+56) 484
   WRITE_SHORT  (offset+58) 646
   WRITE_SHORT  (offset+60) 492
   WRITE_SHORT  (offset+62) 649
   WRITE_SHORT  (offset+64) 498
   WRITE_SHORT  (offset+66) 657
   SET "vert_num"="%vert_num%"+17
   WRITE_SHORT 0x80  "%vert_num%"


 SET "info_ext"=(0x04*17)
 PATCH_IF ("%actors_offset%">="%vert_offset%") BEGIN
   "actors_offset"="%actors_offset%"+"%info_ext%"
   WRITE_LONG  0x54 "%actors_offset%"
 END
 PATCH_IF ("%infotrig_offset%">="%vert_offset%") BEGIN
   "infotrig_offset"="%infotrig_offset%"+"%info_ext%"
   WRITE_LONG  0x5c  "%infotrig_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 ("%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
BUT_ONLY

//All below are customs--Horred's Lair
COPY ~bp/are/ar8050.are~ ~override~
     ~bp/are/ar8051.are~ ~override~
     ~bp/are/ar8052.are~ ~override~


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


COPY ~bp/itm/bplksper.itm~ ~override~

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpratbit.itm~ BEGIN
  COPY ~bp/itm/bpratbit.itm~ ~override~
END

COPY ~bp/itm/gravboot.itm~ ~override~
  SAY NAME1 @67 //Heavy Boots
  SAY NAME2 @68 //Boots of Gravity
  SAY UNIDENTIFIED_DESC @69
  SAY DESC @70

COPY ~bp/itm/helmlife.itm~ ~override~
  SAY NAME2 @75 //Helm of Sacred Life
  SAY UNIDENTIFIED_DESC @76
  SAY DESC @77

COPY ~bp/itm/key60.itm~ ~override~
  SAY NAME1 @82 //Sewer Key
  SAY NAME2 @82 //Sewer Key
  SAY UNIDENTIFIED_DESC @83

COPY ~bp/itm/key66.itm~ ~override~
  SAY NAME1 @82 //Sewer Key
  SAY NAME2 @84 //Demon-Head Key
  SAY UNIDENTIFIED_DESC @85
  SAY DESC @86

COPY ~bp/itm/shadlnth.itm~ ~override~
  SAY NAME1 @115 //Lantern
  SAY NAME2 @116 //Shadow Lanthorn
  SAY UNIDENTIFIED_DESC @117
  SAY DESC @118

////////SPELLS/////////////
COPY ~bp/spl/spin158.spl~ ~override~
  SAY NAME1 @27 //Life Protection
  SAY UNIDENTIFIED_DESC @138

COPY ~bp/spl/spin159.spl~ ~override~
  SAY NAME1 @28 //Chaotic Commander
  SAY UNIDENTIFIED_DESC @139

COPY ~bp/spl/spin504.spl~ ~override~
  SAY NAME1 @154 //Horred's Evil Clones
  SAY UNIDENTIFIED_DESC @154


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

COPY ~bp/cre/bpflskul.cre~ ~override~

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpghast.cre~ BEGIN
  COPY ~bp/cre/bpghast.cre~ ~override~
    SAY NAME1 @359 //Greater Ghast
    SAY NAME2 @359 //Greater Ghast
END

COPY ~bp/cre/bpkuoarc.cre~ ~override~
  SAY NAME1 @360 //Kuo-Toan Archer
  SAY NAME2 @360 //Kuo-Toan Archer

COPY ~bp/cre/bpkuopre.cre~ ~override~
  SAY NAME1 @361 //Kuo-Toa Priest
  SAY NAME2 @361 //Kuo-Toa Priest

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bplizgrd.cre~ BEGIN
  COPY ~bp/cre/bplizgrd.cre~ ~override~
END

COPY ~bp/cre/bplizkng.cre~ ~override~
  SAY NAME1 @362 //Lizard King
  SAY NAME2 @362 //Lizard King

COPY ~bp/cre/bplizman.cre~ ~override~

COPY ~bp/cre/bplizsha.cre~ ~override~
  SAY NAME1 @363 //Lizard Shaman
  SAY NAME2 @363 //Lizard Shaman

COPY ~bp/cre/bpotyugh.cre~ ~override~
  SAY NAME1 @364 //Pyro-Tyugh
  SAY NAME2 @364 //Pyro-Tyugh

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bprat.cre~ BEGIN
  COPY ~bp/cre/bprat.cre~ ~override~
    SAY NAME1 @365 //Sumatran Rat
    SAY NAME2 @365 //Sumatran Rat
END

COPY ~bp/cre/bpsahugi.cre~ ~override~
  
COPY ~bp/cre/bpskelar.cre~ ~override~

COPY ~bp/cre/bpskully.cre~ ~override~
  SAY NAME1 @366 //Skullen Crossbones
  SAY NAME2 @367 //Skulley

COPY ~bp/cre/bpskuly2.cre~ ~override~
  SAY NAME1 @366 //Skullen Crossbones
  SAY NAME2 @367 //Skulley

COPY ~bp/cre/horred.cre~ ~override~
  SAY NAME1 @222 //Horred the Plague
  SAY NAME2 @223 //Horred

COPY ~bp/cre/horred2.cre~ ~override~
  SAY NAME1 @222 //Horred the Plague
  SAY NAME2 @223 //Horred


COPY_EXISTING ~sevpat03.cre~ ~override~ //Pooky
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    ADD_CRE_ITEM ~KEY60~ #0 #0 #0 ~NONE~ ~INV~
  END   
BUT_ONLY


COPY_EXISTING ~firkra02.cre~ ~override~ //Firkraag
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    ADD_CRE_ITEM ~KEY66~ #0 #0 #0 ~NONE~ ~INV~
  END
BUT_ONLY

COPY_EXISTING ~udphae01.cre~ ~override~ //Phaere
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    ADD_CRE_ITEM ~KEY66~ #0 #0 #0 ~NONE~ ~INV~
  END
BUT_ONLY

COPY_EXISTING ~udphae02.cre~ ~override~ //Phaere
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    ADD_CRE_ITEM ~KEY66~ #0 #0 #0 ~NONE~ ~INV~
  END
BUT_ONLY


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

EXTEND_BOTTOM ~ar0020.bcs~ ~bp/snip/bar0020.baf~

ACTION_IF NOT FILE_EXISTS_IN_GAME ~gb-smage.bcs~ BEGIN
  COMPILE ~bp/baf/new_baf/core/gb-smage.baf~
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~gb-summ.bcs~ BEGIN
  COMPILE ~bp/baf/new_baf/core/gb-summ.baf~
END

COMPILE ~bp/baf/new_baf/horred~

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpundead.bcs~ BEGIN
  COMPILE ~bp/baf/new_baf/undead/bpundead.baf~
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpghast.bcs~ BEGIN
  COMPILE ~bp/baf/new_baf/undead/bpghast.baf~
END

ACTION_IF FILE_EXISTS_IN_GAME ~dd0012.are~ BEGIN
  COMPILE ~bp/tdd/baf/horred~
END ELSE BEGIN
  COMPILE ~bp/baf/no_tdd/horred~
END

ACTION_IF FILE_EXISTS_IN_GAME ~dd0012.are~ BEGIN
  COMPILE ~bp/tdd/baf/demon/bpdemon.baf~
END ELSE BEGIN
  COMPILE ~bp/baf/no_tdd/demon/bpdemon.baf~
END

ACTION_IF FILE_EXISTS_IN_GAME ~dd0012.are~ BEGIN
  COMPILE ~bp/tdd/baf/demon/bpdemthf.baf~
END ELSE BEGIN
  COMPILE ~bp/baf/no_tdd/demon/bpdemthf.baf~
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpgparch.bcs~ BEGIN
  COMPILE ~bp/baf/re-baf/core/bpgparch.baf~
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bppri12a.bcs~ BEGIN
  COMPILE ~bp/baf/re-baf/core/bppri12a.baf~
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~wbasight.bcs~ BEGIN
  ACTION_IF MOD_IS_INSTALLED ~setup-bp.tp2~ ~175~ BEGIN
    COMPILE ~bp/baf/shouts/no_strings_2/wbasight.baf~
  END ELSE BEGIN
    COMPILE ~bp/baf/new_baf/core/wbasight.baf~
  END
END


ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpwdasgt.bcs~ BEGIN
  ACTION_IF MOD_IS_INSTALLED ~setup-bp.tp2~ ~175~ BEGIN
    COMPILE ~bp/baf/shouts/no_strings_2/bpwdasgt.baf~
  END ELSE BEGIN
    COMPILE ~bp/baf/re-baf/core/bpwdasgt.baf~
  END
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~humansht.bcs~ BEGIN
  COMPILE ~bp/baf/shouts/strings/humansht.baf~
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpleader.bcs~ BEGIN
  COMPILE ~bp/baf/new_baf/core/bpleader.baf~
END

EXTEND_TOP ~baldur.bcs~ ~bp/snip/tbaldur.baf~

  
///////DIALOG////////
COMPILE ~bp/d/horred~


END

//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION irenicus_dungeon BEGIN
INCLUDE ~bp/lib/bp_main.tph~

LAF trap_projectiles END


ACTION_IF NOT FILE_EXISTS_IN_GAME ~ilychhp1.itm~ BEGIN
  COPY ~bp/itm/ilychhp1.itm~ ~override~
END

EXTEND_BOTTOM ~ar0602.bcs~ ~bp/snip/tar0602.baf~
EXTEND_BOTTOM ~ar0603.bcs~ ~bp/snip/bar0603.baf~
EXTEND_TOP ~ILYICH.bcs~ ~bp/baf/re-baf/iren_dung/tilyich.baf~

COMPILE ~bp/baf/new_baf/iren_dung~


  COPY_EXISTING ~ar0602.are~ ~override~
    READ_LONG  0xc0  "rest_spawns_offset"
    SET offset = "%rest_spawns_offset%"
    WRITE_ASCII offset+0x48 ~RDGOB~ #8
    WRITE_ASCII offset+0x50 ~RDBUGB~ #8
    WRITE_ASCII offset+0x58 ~RDBPTHF~ #8
    WRITE_SHORT offset+0x98 ~3~
    WRITE_SHORT offset+0x9a ~2~
    WRITE_SHORT offset+0xa4 ~4~
    WRITE_SHORT offset+0xa8 ~3~
    WRITE_SHORT offset+0xaa ~3~
  BUT_ONLY

  COPY_EXISTING ~ar0603.are~ ~override~
    READ_LONG  0xc0  "rest_spawns_offset"
    SET offset = "%rest_spawns_offset%"
    WRITE_ASCII offset+0x48 ~RDBPTHF~ #8
    WRITE_ASCII offset+0x50 ~RDBUGB~ #8
    WRITE_ASCII offset+0x58 ~RDMEPHIT~ #8
    WRITE_SHORT offset+0x98 ~3~
    WRITE_SHORT offset+0x9a ~2~
    WRITE_SHORT offset+0xa4 ~4~
    WRITE_SHORT offset+0xa8 ~4~
    WRITE_SHORT offset+0xaa ~4~
  BUT_ONLY

  LAF irenicus_check_spawngrp END





COPY_EXISTING ~clone1.cre~ ~override~ //Escaped Clone
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    ADD_CRE_ITEM ~SCRLPET~ #1 #0 #0 ~NONE~ ~QITEM3~
  END
BUT_ONLY

COPY_EXISTING ~duecla01.cre~ ~override~ //Ilyich
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 78 // CurrHP (was 38)
    WRITE_SHORT 0x26 78 // MaxHP (was 38)
    WRITE_BYTE 0x54 8 // SaveVDth (was 10)
    WRITE_BYTE 0x55 6 // SaveVWnd (was 12)
    WRITE_BYTE 0x56 9 // SaveVPoly (was 11)
    WRITE_BYTE 0x57 10 // SaveVAtks (was 12)
    WRITE_BYTE 0x58 7 // SaveVspell (was 13)
    WRITE_BYTE 0x59 25 // RstFire (was 0)
    WRITE_BYTE 0x5a 25 // RstCold (was 0)
    WRITE_BYTE 0x5b 40 // RstElec (was 0)
    WRITE_BYTE 0x5c 40 // RstAcid (was 0)
    WRITE_BYTE 0x5d 40 // RstMagc (was 0)
    WRITE_BYTE 0x5e 40 // RstMFre (was 0)
    WRITE_BYTE 0x5f 40 // RstMCld (was 0)
    WRITE_BYTE 0x60 20 // RstSlash (was 0)
    WRITE_BYTE 0x61 20 // RstCrush (was 0)
    WRITE_BYTE 0x62 20 // RstPierc (was 0)
    WRITE_BYTE 0x63 20 // RstMissl (was 0)
    WRITE_BYTE 0x234 12 // HighestLevelPrimary (was 7)
    WRITE_BYTE 0x238 18 // Str (was 17)
    WRITE_BYTE 0x239 76 // StrBon (was 0)
    WRITE_BYTE 0x23c 15 // Dex (was 14)
    WRITE_BYTE 0x23d 18 // Con (was 16)
    WRITE_BYTE 0x241 255 // Racial (was 0)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~BULL01~ #20 #0 #0 ~NONE~ ~QUIVER2~
    REPLACE_CRE_ITEM ~ILYCHHP1~ #0 #0 #0 ~UNDROPPABLE~ ~AMULET~
  END
BUT_ONLY

COPY ~bp/cre/duecla02.cre~ ~override~

COPY_EXISTING ~duearc01.cre~ ~override~ //Duergar
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 52 // CurrHP (was 22)
    WRITE_SHORT 0x26 52 // MaxHP (was 22)
    WRITE_BYTE 0x54 9 // SaveVDth (was 11)
    WRITE_BYTE 0x55 7 // SaveVWnd (was 13)
    WRITE_BYTE 0x56 10 // SaveVPoly (was 12)
    WRITE_BYTE 0x57 11 // SaveVAtks (was 13)
    WRITE_BYTE 0x58 8 // SaveVspell (was 14)
    WRITE_BYTE 0x5b 25 // RstElec (was 0)
    WRITE_BYTE 0x5c 25 // RstAcid (was 0)
    WRITE_BYTE 0x5d 25 // RstMagc (was 0)
    WRITE_BYTE 0x5e 25 // RstMFre (was 0)
    WRITE_BYTE 0x5f 25 // RstMCld (was 0)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 5)
    WRITE_BYTE 0x241 255 // Racial (was 0)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REMOVE_CRE_ITEM ~AX1H01~
    REPLACE_CRE_ITEM ~DAGG01~ #0 #0 #0 ~NONE~ ~WEAPON2~
    SET_BG2_PROFICIENCY ~PROFICIENCYDAGGER~ 2
  END
BUT_ONLY

COPY_EXISTING ~duergar1.cre~ ~override~ //Duergar
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 51 // CurrHP (was 41)
    WRITE_SHORT 0x26 51 // MaxHP (was 41)
    WRITE_BYTE 0x54 9 // SaveVDth (was 11)
    WRITE_BYTE 0x55 7 // SaveVWnd (was 13)
    WRITE_BYTE 0x56 10 // SaveVPoly (was 12)
    WRITE_BYTE 0x57 11 // SaveVAtks (was 13)
    WRITE_BYTE 0x58 8 // SaveVspell (was 14)
    WRITE_BYTE 0x5b 25 // RstElec (was 0)
    WRITE_BYTE 0x5c 25 // RstAcid (was 0)
    WRITE_BYTE 0x5d 25 // RstMagc (was 0)
    WRITE_BYTE 0x5e 25 // RstMFre (was 0)
    WRITE_BYTE 0x5f 25 // RstMCld (was 0)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 5)
    WRITE_BYTE 0x241 255 // Racial (was 0)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~duegau01.cre~ ~override~ //Duergar
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 55 // CurrHP (was 25)
    WRITE_SHORT 0x26 55 // MaxHP (was 25)
    WRITE_BYTE 0x54 9 // SaveVDth (was 11)
    WRITE_BYTE 0x55 7 // SaveVWnd (was 13)
    WRITE_BYTE 0x56 10 // SaveVPoly (was 12)
    WRITE_BYTE 0x57 11 // SaveVAtks (was 13)
    WRITE_BYTE 0x58 8 // SaveVspell (was 14)
    WRITE_BYTE 0x5b 25 // RstElec (was 0)
    WRITE_BYTE 0x5c 25 // RstAcid (was 0)
    WRITE_BYTE 0x5d 25 // RstMagc (was 0)
    WRITE_BYTE 0x5e 25 // RstMFre (was 0)
    WRITE_BYTE 0x5f 25 // RstMCld (was 0)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 5)
    WRITE_BYTE 0x241 255 // Racial (was 0)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~duegau02.cre~ ~override~ //Duergar
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 54 // CurrHP (was 24)
    WRITE_SHORT 0x26 54 // MaxHP (was 24)
    WRITE_BYTE 0x54 9 // SaveVDth (was 11)
    WRITE_BYTE 0x55 7 // SaveVWnd (was 13)
    WRITE_BYTE 0x56 10 // SaveVPoly (was 12)
    WRITE_BYTE 0x57 11 // SaveVAtks (was 13)
    WRITE_BYTE 0x58 8 // SaveVspell (was 14)
    WRITE_BYTE 0x5b 25 // RstElec (was 0)
    WRITE_BYTE 0x5c 25 // RstAcid (was 0)
    WRITE_BYTE 0x5d 25 // RstMagc (was 0)
    WRITE_BYTE 0x5e 25 // RstMFre (was 0)
    WRITE_BYTE 0x5f 25 // RstMCld (was 0)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 5)
    WRITE_BYTE 0x241 255 // Racial (was 0)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~duemag01.cre~ ~override~ //Mage
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 42 // CurrHP (was 16)
    WRITE_SHORT 0x26 42 // MaxHP (was 16)
    WRITE_BYTE 0x54 12 // SaveVDth (was 14)
    WRITE_BYTE 0x55 5 // SaveVWnd (was 11)
    WRITE_BYTE 0x56 11 // SaveVPoly (was 13)
    WRITE_BYTE 0x57 13 // SaveVAtks (was 15)
    WRITE_BYTE 0x58 6 // SaveVspell (was 12)
    WRITE_BYTE 0x5b 25 // RstElec (was 0)
    WRITE_BYTE 0x5c 25 // RstAcid (was 0)
    WRITE_BYTE 0x5d 25 // RstMagc (was 0)
    WRITE_BYTE 0x5e 25 // RstMFre (was 0)
    WRITE_BYTE 0x5f 25 // RstMCld (was 0)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 5)
    WRITE_BYTE 0x241 255 // Racial (was 0)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~BULL01~ #20 #0 #0 ~NONE~ ~QUIVER2~
  END
BUT_ONLY

COPY_EXISTING ~duemag02.cre~ ~override~ //Mage
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 42 // CurrHP (was 16)
    WRITE_SHORT 0x26 42 // MaxHP (was 16)
    WRITE_BYTE 0x54 12 // SaveVDth (was 14)
    WRITE_BYTE 0x55 5 // SaveVWnd (was 11)
    WRITE_BYTE 0x56 11 // SaveVPoly (was 13)
    WRITE_BYTE 0x57 13 // SaveVAtks (was 15)
    WRITE_BYTE 0x58 6 // SaveVspell (was 12)
    WRITE_BYTE 0x5b 25 // RstElec (was 0)
    WRITE_BYTE 0x5c 25 // RstAcid (was 0)
    WRITE_BYTE 0x5d 25 // RstMagc (was 0)
    WRITE_BYTE 0x5e 25 // RstMFre (was 0)
    WRITE_BYTE 0x5f 25 // RstMCld (was 0)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 5)
    WRITE_BYTE 0x241 255 // Racial (was 0)
    WRITE_BYTE 0x27b 19 // Alignment (was 18)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~BULL01~ #20 #0 #0 ~NONE~ ~QUIVER2~
  END
BUT_ONLY


COPY_EXISTING ~icgob02.cre~ ~override~ //Goblin
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    SAY NAME1 #2511 // LongName (~Goblin~)
    SAY NAME2 #2511 // ShortName (~Goblin~)
    WRITE_SHORT 0x24 15 // CurrHP (was 9)
    WRITE_SHORT 0x26 15 // MaxHP (was 9)
    WRITE_SHORT 0x28 58384 // AnimationID (was 58416)
    WRITE_BYTE 0x52 18 // THAC0 (was 19)
    WRITE_BYTE 0x54 13 // SaveVDth (was 16)
    WRITE_BYTE 0x55 16 // SaveVWnd (was 18)
    WRITE_BYTE 0x56 14 // SaveVPoly (was 17)
    WRITE_BYTE 0x57 18 // SaveVAtks (was 20)
    WRITE_BYTE 0x58 17 // SaveVspell (was 19)
    WRITE_BYTE 0x242 30 // MrlReco (was 60)
    WRITE_LONG 0x244 1073741824 // KitInfo (was 0)
    WRITE_ASCII 0x248 ~thfsht01~ #8 // Override (was NONE)
    WRITE_ASCII 0x260 ~~ #8 // General (was KBARCH01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REMOVE_CRE_ITEM ~BOW01~
    REPLACE_CRE_ITEM ~BOW05~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED
    REPLACE_CRE_ITEM ~DAGG01~ #0 #0 #0 ~NONE~ ~WEAPON2~
    SET_BG2_PROFICIENCY ~PROFICIENCYSHORTBOW~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYDAGGER~ 1
  END
BUT_ONLY

COPY_EXISTING ~icgob03.cre~ ~override~ //Goblin
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 13 // CurrHP (was 7)
    WRITE_SHORT 0x26 13 // MaxHP (was 7)
    WRITE_BYTE 0x52 18 // THAC0 (was 19)
    WRITE_BYTE 0x54 13 // SaveVDth (was 16)
    WRITE_BYTE 0x55 15 // SaveVWnd (was 18)
    WRITE_BYTE 0x56 14 // SaveVPoly (was 17)
    WRITE_BYTE 0x57 18 // SaveVAtks (was 20)
    WRITE_BYTE 0x58 17 // SaveVspell (was 19)
    WRITE_ASCII 0x248 ~thfsht01~ #8 // Override (was NONE)
    WRITE_ASCII 0x258 ~~ #8 // Race (was KOBOLDF)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~idemon01.cre~ ~override~ //Cambion
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 70 // DtectIll (was 0)
    WRITE_BYTE 0x68 90 // Stealth (was 0)
  END
BUT_ONLY

COPY_EXISTING ~idemon02.cre~ ~override~ //Cambion
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwtrsgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~idryad01.cre~ ~override~ //Ulene
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~bp!plot~ #8 // Class (was ULENE)
    WRITE_ASCII 0x258 ~ulene~ #8 // Race (was SHOUT)
    WRITE_ASCII 0x260 ~shout~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~idryad02.cre~ ~override~ //Cania
              ~idryad03.cre~ ~override~ //Elyme
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~bp!plot~ #8 // Override (was SHOUT)
    WRITE_ASCII 0x250 ~shout~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~igibber.cre~ ~override~ //Gibberling
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    SAY NAME1 #8758 // LongName (~Gibberling~)
    SAY NAME2 #8758 // ShortName (~Gibberling~)
    WRITE_LONG 0x18 4 // PowerLevel (was 0)
    WRITE_SHORT 0x24 13 // CurrHP (was 16)
    WRITE_SHORT 0x26 13 // MaxHP (was 16)
    WRITE_SHORT 0x46 10 // ACNatul (was 8)
    WRITE_SHORT 0x48 10 // ACEffec (was 8)
    WRITE_BYTE 0x52 19 // THAC0 (was 15)
    WRITE_BYTE 0x53 1 // NOAtt (was 7)
    WRITE_BYTE 0x235 30 // HighestLevelSecond (was 1)
    WRITE_BYTE 0x238 9 // Str (was 15)
    WRITE_BYTE 0x23f 10 // Mor (was 1)
    WRITE_BYTE 0x242 60 // MrlReco (was 10)
    WRITE_ASCII 0x248 ~gibber~ #8 // Override (was AATAQFGT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x280 ~igibber~ #32 // DeathVariable (was AATAQAHGIBBER)
    REMOVE_CRE_ITEM ~S1-8~
    REPLACE_CRE_ITEM ~GOPOOF~ #0 #0 #0 ~NONE~ ~AMULET~
    REPLACE_CRE_ITEM ~GIBBERIL~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    ADD_CRE_ITEM ~RNDTRE02~ #0 #0 #0 ~NONE~ ~INV~
  END
BUT_ONLY

COPY_EXISTING ~igolfle1.cre~ ~override~ //Lesser Clay Golem
              ~igolfle2.cre~ ~override~ //Lesser Clay Golem
              ~igolfle3.cre~ ~override~ //Lesser Clay Golem
              ~igolfle4.cre~ ~override~ //Lesser Clay Golem
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~iogremag.cre~ ~override~ //Ogre Mage
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 83 // CurrHP (was 41)
    WRITE_SHORT 0x26 83 // MaxHP (was 41)
    WRITE_BYTE 0x55 12 // SaveVWnd (was 13)
    WRITE_BYTE 0x56 11 // SaveVPoly (was 12)
    WRITE_BYTE 0x58 10 // SaveVspell (was 14)
    WRITE_BYTE 0x5a 100 // RstCold (was 0)
    WRITE_BYTE 0x5b 50 // RstElec (was 0)
    WRITE_BYTE 0x5f 50 // RstMCld (was 0)
    WRITE_ASCII 0x250 ~bpmage3~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REMOVE_MEMORIZED_SPELL ~spwi308~
    ADD_MEMORIZED_SPELL ~spwi118~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi104~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi105~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi206~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi212~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi308~ #2 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi311~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi305~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi405~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi408~ #3 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi404~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi503~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi508~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi607~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi609~ #5 ~wizard~
    ADD_CRE_ITEM ~RNDTRE03~ #0 #0 #0 ~NONE~ ~INV~
  END
BUT_ONLY

COPY_EXISTING ~irethf03.cre~ ~override~ //Assassin
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 25 // DtectIll (was 0)
    WRITE_BYTE 0x68 30 // Stealth (was 0)
    WRITE_BYTE 0x234 3 // HighestLevelPrimary (was 1)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spcl423~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~irethf04.cre~ ~override~ //Assassin
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 45 // CurrHP (was 10)
    WRITE_SHORT 0x26 45 // MaxHP (was 10)
    WRITE_BYTE 0x64 40 // DtectIll (was 0)
    WRITE_BYTE 0x68 50 // Stealth (was 0)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 1)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spcl423~ #0 ~innate~ (2)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~irethf05.cre~ ~override~ //Assassin
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~DAGG02~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~DAGG05~ #20 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~ishadft1.cre~ ~override~ //Assassin
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_LONG 0x1c 36 // Goldcarried (was 55)
    WRITE_SHORT 0x24 66 // CurrHP (was 31)
    WRITE_SHORT 0x26 66 // MaxHP (was 31)
    WRITE_SHORT 0x28 32566 // AnimationID (was 25344)
    WRITE_SHORT 0x46 5 // ACNatul (was 10)
    WRITE_SHORT 0x48 5 // ACEffec (was 10)
    WRITE_BYTE 0x52 12 // THAC0 (was 18)
    WRITE_BYTE 0x53 7 // NOAtt (was 1)
    WRITE_BYTE 0x54 10 // SaveVDth (was 13)
    WRITE_BYTE 0x55 11 // SaveVWnd (was 14)
    WRITE_BYTE 0x56 9 // SaveVPoly (was 12)
    WRITE_BYTE 0x57 13 // SaveVAtks (was 16)
    WRITE_BYTE 0x58 12 // SaveVspell (was 15)
    WRITE_BYTE 0x64 40 // DtectIll (was 0)
    WRITE_BYTE 0x68 50 // Stealth (was 98)
    WRITE_BYTE 0x6a 70 // PickPoct (was 20)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 5)
    WRITE_BYTE 0x235 8 // HighestLevelSecond (was 5)
    WRITE_BYTE 0x238 16 // Str (was 14)
    WRITE_BYTE 0x23a 11 // Int (was 12)
    WRITE_BYTE 0x23b 9 // Wis (was 12)
    WRITE_BYTE 0x23c 19 // Dex (was 10)
    WRITE_BYTE 0x23e 9 // Cha (was 10)
    WRITE_BYTE 0x23f 13 // Mor (was 10)
    WRITE_BYTE 0x240 6 // Morbrk (was 5)
    WRITE_BYTE 0x242 30 // MrlReco (was 60)
    WRITE_ASCII 0x248 ~waitpc2~ #8 // Override (was SHOUT)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTARSGT)
    WRITE_BYTE 0x270 255 // EnemyAlly (was 128)
    WRITE_BYTE 0x272 2 // IDSRace (was 1)
    WRITE_BYTE 0x274 8 // IDSSpecifc (was 0)
    WRITE_BYTE 0x27b 35 // Alignment (was 50)
    WRITE_ASCII 0x2cc ~~ #8 // Dlg (was ISHADFT1)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
    REMOVE_CRE_ITEM ~SW1H04~ ~LEAT01~ ~BOW01~ ~AROW01~ ~MAGE01~
    REPLACE_CRE_ITEM ~LEAT04~ #0 #0 #0 ~IDENTIFIED~ ~ARMOR~
    REPLACE_CRE_ITEM ~DAGG03~ #0 #0 #0 ~IDENTIFIED~ ~WEAPON1~
    REPLACE_CRE_ITEM ~XBOW04~ #0 #0 #0 ~IDENTIFIED~ ~WEAPON2~ EQUIP TWOHANDED
    REPLACE_CRE_ITEM ~BOLT03~ #6 #0 #0 ~IDENTIFIED~ ~QUIVER1~
    REPLACE_CRE_ITEM ~BOLT01~ #20 #0 #0 ~IDENTIFIED~ ~QUIVER2~
    ADD_CRE_ITEM ~POTN10~ #3 #0 #0 ~NONE~ ~QITEM1~
    ADD_CRE_ITEM ~POTN52~ #5 #0 #0 ~NONE~ ~QITEM2~
    ADD_CRE_ITEM ~POTN14~ #2 #0 #0 ~NONE~ ~QITEM3~
    ADD_CRE_ITEM ~RNDTRE04~ #0 #0 #0 ~NONE~ ~INV~
    SET_BG2_PROFICIENCY ~PROFICIENCYDAGGER~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYCROSSBOW~ 1
  END
BUT_ONLY

COPY_EXISTING ~ishadmt1.cre~ ~override~ //Assassin
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 25 // DtectIll (was 0)
    WRITE_BYTE 0x68 35 // Stealth (was 20)
    WRITE_ASCII 0x248 ~shoutdlg~ #8 // Override (was SHOUT)
    WRITE_ASCII 0x250 ~~ #8 // Class (was SHOUTDLG)
    WRITE_ASCII 0x260 ~bpmage6a~ #8 // General (was SHADMT01)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    REMOVE_MEMORIZED_SPELL ~spwi119~
    ADD_MEMORIZED_SPELL ~spwi119~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi112~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi212~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi213~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spcl423~ #0 ~innate~ (2)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
    ADD_CRE_ITEM ~POTN08~ #4 #0 #0 ~NONE~ ~QITEM3~
  END
BUT_ONLY

COPY_EXISTING ~ishadth1.cre~ ~override~ //Assassin
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_LONG 0x1c 36 // Goldcarried (was 38)
    WRITE_SHORT 0x24 46 // CurrHP (was 22)
    WRITE_SHORT 0x26 46 // MaxHP (was 22)
    WRITE_SHORT 0x28 32566 // AnimationID (was 25344)
    WRITE_SHORT 0x46 5 // ACNatul (was 10)
    WRITE_SHORT 0x48 5 // ACEffec (was 10)
    WRITE_BYTE 0x52 12 // THAC0 (was 18)
    WRITE_BYTE 0x54 10 // SaveVDth (was 13)
    WRITE_BYTE 0x55 11 // SaveVWnd (was 14)
    WRITE_BYTE 0x56 9 // SaveVPoly (was 12)
    WRITE_BYTE 0x57 13 // SaveVAtks (was 16)
    WRITE_BYTE 0x58 12 // SaveVspell (was 15)
    WRITE_BYTE 0x64 40 // DtectIll (was 0)
    WRITE_BYTE 0x68 50 // Stealth (was 98)
    WRITE_BYTE 0x6a 70 // PickPoct (was 20)
    WRITE_BYTE 0x234 10 // HighestLevelPrimary (was 5)
    WRITE_BYTE 0x235 1 // HighestLevelSecond (was 2)
    WRITE_BYTE 0x238 16 // Str (was 12)
    WRITE_BYTE 0x23a 11 // Int (was 12)
    WRITE_BYTE 0x23b 9 // Wis (was 12)
    WRITE_BYTE 0x23c 19 // Dex (was 10)
    WRITE_BYTE 0x23e 9 // Cha (was 10)
    WRITE_BYTE 0x23f 13 // Mor (was 10)
    WRITE_BYTE 0x240 6 // Morbrk (was 5)
    WRITE_BYTE 0x242 30 // MrlReco (was 60)
    WRITE_ASCII 0x248 ~waitpc2~ #8 // Override (was SHOUT)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x270 255 // EnemyAlly (was 128)
    WRITE_BYTE 0x272 2 // IDSRace (was 1)
    WRITE_BYTE 0x274 8 // IDSSpecifc (was 0)
    WRITE_BYTE 0x27b 35 // Alignment (was 19)
    WRITE_ASCII 0x2cc ~~ #8 // Dlg (was ISHADTH1)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
    REMOVE_CRE_ITEM ~SW1H04~ ~LEAT01~ ~BOW01~ ~AROW01~ ~MAGE01~
    REPLACE_CRE_ITEM ~LEAT04~ #0 #0 #0 ~IDENTIFIED~ ~ARMOR~
    REPLACE_CRE_ITEM ~DAGG03~ #0 #0 #0 ~IDENTIFIED~ ~WEAPON1~
    REPLACE_CRE_ITEM ~XBOW04~ #0 #0 #0 ~IDENTIFIED~ ~WEAPON2~ EQUIP TWOHANDED
    REPLACE_CRE_ITEM ~BOLT03~ #6 #0 #0 ~IDENTIFIED~ ~QUIVER1~
    REPLACE_CRE_ITEM ~BOLT01~ #20 #0 #0 ~IDENTIFIED~ ~QUIVER2~
    ADD_CRE_ITEM ~POTN10~ #3 #0 #0 ~NONE~ ~QITEM1~
    ADD_CRE_ITEM ~POTN52~ #5 #0 #0 ~NONE~ ~QITEM2~
    ADD_CRE_ITEM ~POTN14~ #2 #0 #0 ~NONE~ ~QITEM3~
    ADD_CRE_ITEM ~RNDTRE04~ #0 #0 #0 ~NONE~ ~INV~
    SET_BG2_PROFICIENCY ~PROFICIENCYDAGGER~ 1
    SET_BG2_PROFICIENCY ~PROFICIENCYCROSSBOW~ 1
  END
BUT_ONLY

COPY_EXISTING ~ishclo01.cre~ ~override~ //Assassin
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 25 // DtectIll (was 0)
    WRITE_BYTE 0x68 25 // Stealth (was 0)
    WRITE_BYTE 0x234 3 // HighestLevelPrimary (was 1)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spcl423~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~ishthf01.cre~ ~override~ //Assassin
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x68 25 // Stealth (was 0)
    WRITE_BYTE 0x234 3 // HighestLevelPrimary (was 1)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spcl423~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~ishthf02.cre~ ~override~ //Assassin
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~bpmage6a~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~STAF01~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED
    REPLACE_CRE_ITEM ~DART01~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~ishthf03.cre~ ~override~ //Assassin
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 12 // CurrHP (was 10)
    WRITE_SHORT 0x26 12 // MaxHP (was 10)
    WRITE_BYTE 0x68 20 // Stealth (was 0)
    WRITE_BYTE 0x234 2 // HighestLevelPrimary (was 1)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spcl423~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~iotyugh.cre~ ~override~ //Otyugh
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY


ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpmage3.bcs~ BEGIN
  COMPILE ~bp/baf/re-baf/core/bpmage3.baf~
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpmage6a.bcs~ BEGIN
  COMPILE ~bp/baf/re-baf/core/bpmage6a.baf~
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpthief.bcs~ BEGIN
  COMPILE ~bp/baf/new_baf/core/bpthief.baf~
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpwdasgt.bcs~ BEGIN
  ACTION_IF MOD_IS_INSTALLED ~setup-bp.tp2~ ~175~ BEGIN
    COMPILE ~bp/baf/shouts/no_strings_2/bpwdasgt.baf~
  END ELSE BEGIN
    COMPILE ~bp/baf/re-baf/core/bpwdasgt.baf~
  END
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bp!plot.bcs~ BEGIN
  COMPILE ~bp/baf/new_baf/core/bp!plot.baf~
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpwtrsgt.bcs~ BEGIN
  ACTION_IF MOD_IS_INSTALLED ~setup-bp.tp2~ ~175~ BEGIN
    COMPILE ~bp/baf/shouts/no_strings_2/bpwtrsgt.baf~
  END ELSE BEGIN
    COMPILE ~bp/baf/re-baf/core/bpwtrsgt.baf~
  END
END


END


////////////Gebhard Blucher's Lich in the Docks////////////////
//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION lich_in_docks BEGIN

COPY ~BP/GBLICH/GBLICH01.cre~      ~override/GBLICH01.cre~

COPY ~BP/GBLICH/gblichob.CRE~      ~override/gblichob.CRE~

COMPILE ~BP/GBLICH/COMPILE~

ACTION_IF FILE_EXISTS_IN_GAME ~AR0318.BCS~ THEN BEGIN
  EXTEND_BOTTOM ~AR0318.BCS~  ~BP/GBLICH/AR0318.BAF~
END
ELSE BEGIN
  COMPILE ~BP/GBLICH/AR0318.BAF~
END


END

/////////////////////IMPROVED KANGAXX//////////////////////////
//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION kangaxx BEGIN


ACTION_IF NOT FILE_EXISTS_IN_GAME ~SPMISLED.spl~ BEGIN
  COPY ~bp/spl/SPMISLED.spl~ ~override~
END

COPY ~bp/spl/SPMISLED.spl~ ~override/MARW127.spl~

COPY ~BP/KRLICH/ARCHLICH.cre~      ~override/ARCHLICH.cre~       

COPY ~BP/KRLICH/KRDUALWF.cre~      ~override/KRDUALWF.cre~       

COPY ~BP/KRLICH/krdwarf.cre~       ~override/krdwarf.cre~        

COPY ~BP/KRLICH/KRFIGHT.cre~       ~override/KRFIGHT.cre~

COPY ~BP/KRLICH/KRLICH2.cre~       ~override/KRLICH2.cre~ 

ACTION_IF NOT FILE_EXISTS_IN_GAME ~KRGNOME.bcs~ BEGIN
  COMPILE ~bp/krgnome/krgnome.baf~
END

COMPILE ~BP/KRLICH/COMPILE~

ACTION_IF FILE_EXISTS_IN_GAME ~AR0330.BCS~ THEN BEGIN
  EXTEND_BOTTOM ~AR0330.BCS~  ~BP/KRLICH/AR0330.BAF~
END ELSE BEGIN
  COMPILE ~BP/KRLICH/AR0330.BAF~
END


END

//////////////////////KUROISAN, by Westley Weimer//////////////
//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION kuroisan BEGIN

COPY ~BP/KUROI/solak1.cre~        ~override/solak1.cre~         
  SAY NAME1 @410 
  SAY NAME2 @410 
  
COPY ~BP/KUROI/solak1.spl~        ~override/solak1.spl~         
  SAY NAME1 @411 
  SAY NAME2 @411 

COPY ~BP/KUROI/solak1.itm~        ~override/solak1.itm~         
  SAY NAME2 @412 
  SAY DESC @413 

COPY ~BP/KUROI/solak1b.itm~       ~override/solak1b.itm~        

COMPILE ~BP/KUROI/COMPILE~

EXTEND_TOP  ~BALDUR.BCS~          ~BP/KUROI/tBALDUR.baf~

EXTEND_TOP  ~BALDUR25.BCS~        ~BP/KUROI/tBALDR25.baf~


END

//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION maevar BEGIN

INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF maevar_scripts END


COPY ~bp/cre/mvguard2.cre~ ~override~

COPY ~bp/cre/mvmage.cre~ ~override~

COPY ~bp/cre/mvpries2.cre~ ~override~

COPY_EXISTING ~maeguy02.cre~ ~override~ //Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~bpthfsht~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTARSGT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~maevar.cre~ ~override~ //Mae'Var
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    SAY NAME1 #22345 // LongName (~Mae'Var~)
    SAY NAME2 #22345 // ShortName (~Mae'Var~)
    WRITE_SHORT 0x24 120 // CurrHP (was 60)
    WRITE_SHORT 0x26 120 // MaxHP (was 60)
    WRITE_ASCII 0x34 ~maevars~ #8 // SmallPortrait (was NONE)
    WRITE_BYTE 0x52 10 // THAC0 (was 13)
    WRITE_BYTE 0x53 2 // NOAtt (was 1)
    WRITE_BYTE 0x54 8 // SaveVDth (was 10)
    WRITE_BYTE 0x55 5 // SaveVWnd (was 7)
    WRITE_BYTE 0x56 7 // SaveVPoly (was 9)
    WRITE_BYTE 0x57 9 // SaveVAtks (was 11)
    WRITE_BYTE 0x58 6 // SaveVspell (was 8)
    WRITE_BYTE 0x59 25 // RstFire (was 0)
    WRITE_BYTE 0x5a 25 // RstCold (was 0)
    WRITE_BYTE 0x5b 25 // RstElec (was 0)
    WRITE_BYTE 0x5c 25 // RstAcid (was 0)
    WRITE_BYTE 0x5d 25 // RstMagc (was 0)
    WRITE_BYTE 0x5e 25 // RstMFre (was 0)
    WRITE_BYTE 0x5f 25 // RstMCld (was 0)
    WRITE_BYTE 0x60 25 // RstSlash (was 0)
    WRITE_BYTE 0x61 25 // RstCrush (was 0)
    WRITE_BYTE 0x62 25 // RstPierc (was 0)
    WRITE_BYTE 0x63 25 // RstMissl (was 0)
    WRITE_BYTE 0x64 75 // DtectIll (was 0)
    WRITE_BYTE 0x65 50 // SetTraps (was 0)
    WRITE_BYTE 0x66 25 // Lore (was 0)
    WRITE_BYTE 0x67 75 // Lock (was 0)
    WRITE_BYTE 0x68 90 // Stealth (was 0)
    WRITE_BYTE 0x69 75 // FDTraps (was 0)
    WRITE_BYTE 0x6a 75 // PickPoct (was 0)
    WRITE_BYTE 0x6d 4 // Luck (was 0)
    WRITE_BYTE 0x238 16 // Str (was 9)
    WRITE_BYTE 0x23a 18 // Int (was 17)
    WRITE_BYTE 0x23c 19 // Dex (was 17)
    WRITE_BYTE 0x23f 20 // Mor (was 15)
    WRITE_ASCII 0x248 ~maevar~ #8 // Override (was GPSHOUT)
    WRITE_ASCII 0x250 ~initrg10~ #8 // Class (was USEITEM)
    WRITE_ASCII 0x258 ~bp!plot~ #8 // Race (was MAEVAR)
    WRITE_ASCII 0x260 ~bpmag14d~ #8 // General (was INITRG10)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTARSGT)
    REMOVE_KNOWN_SPELL ~spwi618~
    REMOVE_KNOWN_SPELL ~spwi605~
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (4)
    REMOVE_CRE_ITEM ~SW1H07~ ~AROW01~
    REPLACE_CRE_ITEM ~SW1H08~ #0 #0 #0 ~UNSTEALABLE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~AROW05~ #20 #0 #0 ~UNSTEALABLE~ ~QUIVER1~
  END
BUT_ONLY

COPY_EXISTING ~mvguard1.cre~ ~override~ //Assassin
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 84 // CurrHP (was 58)
    WRITE_SHORT 0x26 84 // MaxHP (was 58)
    WRITE_BYTE 0x52 12 // THAC0 (was 20)
    WRITE_BYTE 0x54 11 // SaveVDth (was 13)
    WRITE_BYTE 0x55 12 // SaveVWnd (was 14)
    WRITE_BYTE 0x56 10 // SaveVPoly (was 12)
    WRITE_BYTE 0x57 14 // SaveVAtks (was 16)
    WRITE_BYTE 0x58 13 // SaveVspell (was 15)
    WRITE_BYTE 0x64 50 // DtectIll (was 0)
    WRITE_BYTE 0x68 40 // Stealth (was 20)
    WRITE_BYTE 0x23b 10 // Wis (was 12)
    WRITE_BYTE 0x23d 16 // Con (was 9)
    WRITE_BYTE 0x23e 8 // Cha (was 10)
    WRITE_BYTE 0x23f 20 // Mor (was 10)
    WRITE_ASCII 0x250 ~~ #8 // Class (was GPARCHER)
    WRITE_ASCII 0x248 ~bpthfsht~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spcl423~ #0 ~innate~ (3)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
    REMOVE_CRE_ITEM ~LEAT01~ ~AROW01~
    REPLACE_CRE_ITEM ~HELM01~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~LEAT04~ #0 #0 #0 ~UNSTEALABLE~ ~ARMOR~
    REPLACE_CRE_ITEM ~AROW05~ #10 #0 #0 ~UNSTEALABLE~ ~QUIVER1~
    REPLACE_CRE_ITEM ~AROW08~ #20 #0 #0 ~NONE~ ~QUIVER2~
    ADD_CRE_ITEM ~POTN10~ #3 #0 #0 ~NONE~ ~QITEM1~
    ADD_CRE_ITEM ~POTN14~ #2 #0 #0 ~NONE~ ~QITEM2~
    ADD_CRE_ITEM ~POTN52~ #3 #0 #0 ~NONE~ ~QITEM3~
  END
BUT_ONLY

COPY_EXISTING ~mvpries.cre~ ~override~ //Priest of Cyric
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 76 // CurrHP (was 64)
    WRITE_SHORT 0x26 76 // MaxHP (was 64)
    WRITE_BYTE 0x52 14 // THAC0 (was 16)
    WRITE_BYTE 0x234 10 // HighestLevelPrimary (was 8)
    WRITE_BYTE 0x23d 15 // Con (was 9)
    WRITE_ASCII 0x248 ~humansht~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x250 ~bpprie8b~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REMOVE_MEMORIZED_SPELL ~sppr101~
    REMOVE_MEMORIZED_SPELL ~sppr308~
    REMOVE_MEMORIZED_SPELL ~sppr401~
    ADD_MEMORIZED_SPELL ~sppr101~ #0 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr203~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr214~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr208~ #1 ~priest~
    ADD_MEMORIZED_SPELL ~sppr309~ #2 ~priest~
    ADD_MEMORIZED_SPELL ~sppr401~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr411~ #3 ~priest~
    ADD_MEMORIZED_SPELL ~sppr503~ #4 ~priest~
    ADD_MEMORIZED_SPELL ~sppr502~ #4 ~priest~
    REMOVE_CRE_ITEM ~CHAN01~
    REPLACE_CRE_ITEM ~HELM01~ #0 #0 #0 ~NONE~ ~HELMET~
    REPLACE_CRE_ITEM ~PLAT01~ #0 #0 #0 ~NONE~ ~ARMOR~
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
    REPLACE_CRE_ITEM ~BULL01~ #40 #0 #0 ~NONE~ ~QUIVER1~
  END
BUT_ONLY



END


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

DEFINE_ACTION_FUNCTION nalia_quests BEGIN

INCLUDE ~bp/lib/bp_main.tph~
INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF bp_boulder END
LAF nalia_quest_scripts END


COPY_EXISTING ~icyuan01.cre~ ~override~ //Yuan-Ti
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 57 // CurrHP (was 48)
    WRITE_SHORT 0x26 57 // MaxHP (was 48)
    WRITE_SHORT 0x46 2 // ACNatul (was 0)
    WRITE_SHORT 0x48 2 // ACEffec (was 0)
    WRITE_ASCII 0x248 ~gensht01~ #8 // Override (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x274 102 // IDSSpecifc (was 0)
  END
BUT_ONLY

COPY_EXISTING ~icyuan02.cre~ ~override~ //Greater Yuan-Ti
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 88 // CurrHP (was 72)
    WRITE_SHORT 0x26 88 // MaxHP (was 72)
    WRITE_SHORT 0x46 ~-2~ // ACNatul (was 0)
    WRITE_SHORT 0x48 ~-2~ // ACEffec (was 0)
    WRITE_BYTE 0x234 11 // HighestLevelPrimary (was 7)
    WRITE_ASCII 0x248 ~gensht01~ #8 // Override (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~icyuan03.cre~ ~override~ //Yuan-Ti  mage
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x238 16 // Str (was 18)
    WRITE_BYTE 0x23a 17 // Int (was 9)
    WRITE_BYTE 0x23c 17 // Dex (was 9)
    WRITE_ASCII 0x250 ~gensht01~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x274 101 // IDSSpecifc (was 102)
    REPLACE_CRE_ITEM ~SW1H04~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
  END
BUT_ONLY

COPY_EXISTING ~icyuan04.cre~ ~override~ //Yuan-Ti Elite
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    // SAY NAME1 #72138 // LongName (was 72137)
    WRITE_SHORT 0x24 136 // CurrHP (was 132)
    WRITE_SHORT 0x26 136 // MaxHP (was 132)
    WRITE_SHORT 0x46 ~-4~ // ACNatul (was -2)
    WRITE_SHORT 0x48 ~-4~ // ACEffec (was -2)
    WRITE_BYTE 0x53 8 // NOAtt (was 2)
    WRITE_BYTE 0x234 16 // HighestLevelPrimary (was 10)
    WRITE_BYTE 0x238 20 // Str (was 19)
    WRITE_BYTE 0x23c 19 // Dex (was 18)
    WRITE_BYTE 0x23d 17 // Con (was 16)
    WRITE_BYTE 0x23f 12 // Mor (was 10)
    WRITE_BYTE 0x240 5 // Morbrk (was 6)
    WRITE_ASCII 0x248 ~gensht01~ #8 // Override (was NONE)
    WRITE_ASCII 0x260 ~bpleader~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x274 102 // IDSSpecifc (was 0)
    REMOVE_CRE_ITEM ~SW1H73~
    REPLACE_CRE_ITEM ~SW1H06~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
  END
BUT_ONLY

COPY_EXISTING ~kpglai01.cre~ ~override~ //Glaicas
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x258 ~~ #8 // Race (was GPUSE)
    WRITE_ASCII 0x268 ~wsasight~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY


ACTION_IF NOT FILE_EXISTS_IN_GAME ~kpglai02.cre~ BEGIN
  COPY ~bp/cre/kpglai02.cre~ ~override~
END ELSE BEGIN
  COPY_EXISTING ~kpglai02.cre~ ~override~
    PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
      WRITE_ASCII 0x248 ~bpglac~ #8 // Race (was GPUSE)
      WRITE_ASCII 0x250 ~humansht~ #8 // Race (was GPUSE)
      WRITE_ASCII 0x258 ~bpmag12c~ #8 // Race (was GPUSE)
      WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    END
  BUT_ONLY
END

COPY ~bp/cre/kpglai03.cre~ ~override~

COPY ~bp/cre/kpglai04.cre~ ~override~

COPY_EXISTING ~kpgol01.cre~ ~override~ //Flesh Golem
              ~kpgol06.cre~ ~override~ //Flesh Golem
              ~kpgol03.cre~ ~override~ //Stone Golem
              ~kpgol05.cre~ ~override~ //Stone Golem
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~bpgolsto~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY ~bp/cre/kpgol07.cre~ ~override~
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~bpgoliro~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~kpgol04.cre~ ~override~ //Iron Golem
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~bpgoliro~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~kprang01.cre~ ~override~ //Jessup
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~SW1H04~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
  END
BUT_ONLY

COPY_EXISTING ~kproen01.cre~ ~override~ //Lord Roenall
              ~kproen04.cre~ ~override~ //Roenall Soldier
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x53 2 // NOAtt (was 7)
    WRITE_ASCII 0x248 ~humansht~ #8 // Override (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~kproen02.cre~ ~override~ //Lord Roenall
              ~kproen05.cre~ ~override~ //Roenall Soldier
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x53 2 // NOAtt (was 7)
    WRITE_ASCII 0x248 ~humansht~ #8 // Override (was NONE)
    WRITE_ASCII 0x268 ~bpwtrsgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~kproen03.cre~ ~override~ //Roenall Guard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8 // Override (was NONE)
    WRITE_ASCII 0x258 ~bpmag14d~ #8 // Race (was NONE)
    WRITE_ASCII 0x268 ~wbasight~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~kpsham01.cre~ ~override~ //Yuan-Ti  mage
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 67 // CurrHP (was 63)
    WRITE_SHORT 0x26 67 // MaxHP (was 63)
    WRITE_ASCII 0x248 ~shoutdlg~ #8 
    WRITE_ASCII 0x250 ~creshout~ #8 
    WRITE_ASCII 0x258 ~bpmag14d~ #8 
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x273 1 //Class (mage, was 201 long_sword)
    REPLACE_CRE_ITEM ~STAF01~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED
  END
BUT_ONLY

COPY_EXISTING ~kpsold01.cre~ ~override~ //de'Arnise Guard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~bp!plot~ #8 // Override (was SHOUT)
    WRITE_ASCII 0x260 ~bpseenmy~ #8 // Override (was SHOUT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~kpsold02.cre~ ~override~ //de'Arnise Guard
              ~kpsold05.cre~ ~override~
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8 // General (was TROLIC01)
    WRITE_ASCII 0x260 ~bpseenmy~ #8 // Override (was SHOUT)
    WRITE_ASCII 0x268 ~bpwtrsgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~kpsold03.cre~ ~override~ //de'Arnise Guard
              ~kpsold07.cre~ ~override~ //Roenall Soldier
              ~kpsold08.cre~ ~override~ //Roenall Soldier
              ~kpsold10.cre~ ~override~ //Roenall Soldier
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8 // General (was TROLIC01)
    WRITE_ASCII 0x258 ~bpseenmy~ #8 // Override (was SHOUT)
    WRITE_ASCII 0x268 ~bpwtrsgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~kpsold06.cre~ ~override~ //de'Arnise Guard
              ~kpsold04.cre~ ~override~
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8 // General (was TROLIC01)
    WRITE_ASCII 0x260 ~bpseenmy~ #8 // Override (was SHOUT)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~kpsold09.cre~ ~override~ //de'Arnise Guard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8 // Override (was SHOUT)
    WRITE_ASCII 0x260 ~bpprie6a~ #8 // Override (was SHOUT)
    WRITE_ASCII 0x268 ~bpwtrsgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~kptrol01.cre~ ~override~ //Troll
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 87 // CurrHP (was 70)
    WRITE_SHORT 0x26 87 // MaxHP (was 70)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 6)
    WRITE_BYTE 0x239 100 // StrBon (was 0)
    WRITE_ASCII 0x258 ~bpprie8a~ #8 // Race (was )
    WRITE_ASCII 0x260 ~creshout~ #8 // General (was TROLIC01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~kptrol02.cre~ ~override~ //Troll
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 87 // CurrHP (was 70)
    WRITE_SHORT 0x26 87 // MaxHP (was 70)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 6)
    WRITE_BYTE 0x239 100 // StrBon (was 0)
    WRITE_ASCII 0x250 ~bpprie8a~ #8 // Class (was )
    WRITE_ASCII 0x260 ~creshout~ #8 // General (was TROLIC01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~kptrol03.cre~ ~override~ //Troll
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 88 // CurrHP (was 70)
    WRITE_SHORT 0x26 88 // MaxHP (was 70)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 6)
    WRITE_BYTE 0x235 1 // HighestLevelSecond (was 30)
    WRITE_BYTE 0x239 100 // StrBon (was 0)
    WRITE_ASCII 0x258 ~bpprie8a~ #8 // Race
    WRITE_ASCII 0x260 ~creshout~ #8 // General (was TROLIC01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~kptrol04.cre~ ~override~ //Troll
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 89 // CurrHP (was 70)
    WRITE_SHORT 0x26 89 // MaxHP (was 70)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 6)
    WRITE_BYTE 0x235 1 // HighestLevelSecond (was 30)
    WRITE_BYTE 0x239 100 // StrBon (was 0)
    WRITE_ASCII 0x250 ~~ #8 // Class (was KPTROL04)
    WRITE_ASCII 0x258 ~bpprie8a~ #8 // Race (was )
    WRITE_ASCII 0x260 ~creshout~ #8 // General (was TROLIC01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~kptrol05.cre~ ~override~ //Troll
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 86 // CurrHP (was 60)
    WRITE_SHORT 0x26 86 // MaxHP (was 60)
    WRITE_BYTE 0x234 8 // HighestLevelPrimary (was 6)
    WRITE_BYTE 0x235 1 // HighestLevelSecond (was 30)
    WRITE_BYTE 0x239 100 // StrBon (was 0)
    WRITE_ASCII 0x260 ~creshout~ #8 // General (was TROLIC01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~kptrol06.cre~ ~override~ //Troll
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 38 // CurrHP (was 15)
    WRITE_SHORT 0x26 38 // MaxHP (was 15)
    WRITE_BYTE 0x52 15 // THAC0 (was 19)
    WRITE_BYTE 0x234 4 // HighestLevelPrimary (was 6)
    WRITE_BYTE 0x235 1 // HighestLevelSecond (was 30)
    WRITE_BYTE 0x239 10 // StrBon (was 0)
    WRITE_ASCII 0x248 ~trolic01~ #8 // Override (was GENSHT01)
    WRITE_ASCII 0x260 ~creshout~ #8 // General (was TROLIC01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~kpyuan01.cre~ ~override~ //Greater Yuan-Ti
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 86 // CurrHP (was 72)
    WRITE_SHORT 0x26 86 // MaxHP (was 72)
    WRITE_SHORT 0x46 ~-2~ // ACNatul (was 0)
    WRITE_SHORT 0x48 ~-2~ // ACEffec (was 0)
    WRITE_BYTE 0x234 11 // HighestLevelPrimary (was 7)
    WRITE_BYTE 0x235 1 // HighestLevelSecond (was 30)
    WRITE_ASCII 0x260 ~creshout~ #8 // General (was TROLIC01)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~torgal.cre~ ~override~ //TorGal
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 220 // CurrHP (was 140)
    WRITE_SHORT 0x26 220 // MaxHP (was 140)
    WRITE_BYTE 0x59 30 // RstFire (was 0)
    WRITE_BYTE 0x5a 75 // RstCold (was 30)
    WRITE_BYTE 0x5b 75 // RstElec (was 30)
    WRITE_BYTE 0x5c 30 // RstAcid (was 0)
    WRITE_BYTE 0x5e 30 // RstMFre (was 0)
    WRITE_BYTE 0x5f 75 // RstMCld (was 30)
    WRITE_BYTE 0x60 25 // RstSlash (was 0)
    WRITE_BYTE 0x61 25 // RstCrush (was 0)
    WRITE_BYTE 0x62 25 // RstPierc (was 0)
    WRITE_BYTE 0x63 25 // RstMissl (was 0)
    // WRITE_BYTE 0x72 2 // Unu4(Blunt prof) (was 0)
    WRITE_BYTE 0x234 16 // HighestLevelPrimary (was 6)
    WRITE_BYTE 0x23d 24 // Con (was 19)
    WRITE_ASCII 0x250 ~humansht~ #8 // General (was TROLIC01)
    WRITE_ASCII 0x260 ~bpleader~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwtsigt~ #8 // Default (was WTASIGHT)
    ADD_CRE_ITEM ~BOULDER~ #8 #0 #0 ~NONE~ ~WEAPON2~ EQUIP TWOHANDED
    SET_BG2_PROFICIENCY ~PROFICIENCYSPEAR~ 2
    SET_BG2_PROFICIENCY 110 2 //PROFICIENCYMARTIALARTS
    READ_LONG 0x2c4 effects_offset
    READ_LONG 0x2c8 effects_num
	PATCH_IF NOT GAME_IS ~bg2ee~ BEGIN
    FOR (cnt=0; cnt<effects_num; cnt=cnt+1) BEGIN
      READ_LONG (effects_offset+cnt*0x108+8) type
      PATCH_IF type = 98 BEGIN //Regeneration
        WRITE_LONG (effects_offset+cnt*0x108+20) 4
      END
      PATCH_IF type = 126 BEGIN //Movement rate
        WRITE_LONG (effects_offset+cnt*0x108+20) 16
      END
      PATCH_IF type = 285 BEGIN //Melee damage modifier
        WRITE_LONG (effects_offset+cnt*0x108+20) 7
      END
    END
	END
    LAUNCH_PATCH_FUNCTION ADD_CRE_EFFECT
      INT_VAR opcode = 101 //Protection from Opcode
      timing = 9 //Permanent after death
      parameter2 = 74 //Opcode (Blindness)
      resist_dispel = 2 //Not dispellable/bypass resistance
    END
  END
BUT_ONLY


COPY_EXISTING ~kpdead01.cre~ ~override~ //Servant
              ~kpgate01.cre~ ~override~ //Guard
              ~kpgate02.cre~ ~override~ //Guard
              ~kpgol02.cre~ ~override~ //Clay Golem
              ~kpgrd01.cre~ ~override~ //Lastin
              ~kpumb01.cre~ ~override~ //Umber Hulk
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~naliames.cre~ ~override~ //Messenger
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpcber2b~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY


END

////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION planar_prison BEGIN

INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF planar_prison_scripts END



COPY_EXISTING ~pbhunt01.cre~ ~override~ //Aawill
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~humansht~ #8 // Class
    WRITE_ASCII 0x258 ~bp!bard~ #8 // Race (was GPSKEL1)
    WRITE_ASCII 0x260 ~~ #8 // General (was GPUSE)
    WRITE_ASCII 0x268 ~wsarsgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~pbhunt02.cre~ ~override~ //Bounty Hunter
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~~ #8 // Class (was GPARCHER)
    WRITE_ASCII 0x258 ~humansht~ #8 // Race (was GENSHT01)
    WRITE_ASCII 0x268 ~bpgparch~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~pbhunt03.cre~ ~override~ //Bounty Hunter
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8
    WRITE_ASCII 0x250 ~bpmag14c~ #8 
    WRITE_ASCII 0x258 ~~ #8 
    WRITE_ASCII 0x260 ~~ #8
    WRITE_ASCII 0x268 ~wgarsgt~ #8 
    REPLACE_CRE_ITEM ~DAGG05~ #20 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~pbhunt04.cre~ ~override~ //Bounty Hunter
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8
    WRITE_ASCII 0x250 ~bppri12a~ #8 
    WRITE_ASCII 0x258 ~~ #8 // Race (was GENSHT01)
    WRITE_ASCII 0x260 ~~ #8
    WRITE_ASCII 0x268 ~wbasight~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~pbhunt05.cre~ ~override~ //Bounty Hunter
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 44 // CurrHP (was 40)
    WRITE_SHORT 0x26 44 // MaxHP (was 40)
    WRITE_BYTE 0x64 25 // DtectIll (was 0)
    WRITE_ASCII 0x248 ~humansht~ #8
    WRITE_ASCII 0x250 ~~ #8 // Class (was THIEF14T)
    WRITE_ASCII 0x258 ~~ #8 // Race (was GENSHT01)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~pcapt02.cre~ ~override~ //Prison Captain
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x28 25105 // AnimationID (was 24833)
    WRITE_ASCII 0x248 ~humansht~ #8
    WRITE_ASCII 0x250 ~figmag10~ #8 // Class (was THIEF14T)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~pcapt03.cre~ ~override~ //Prison Captain
              ~pcapt05.cre~ ~override~
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x28 25105 // AnimationID (was 24833)
    WRITE_ASCII 0x248 ~humansht~ #8
    WRITE_ASCII 0x260 ~bpleader~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~pcapt04.cre~ ~override~ //Prison Captain
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8
    WRITE_ASCII 0x250 ~bpmag12b~ #8 // Class (was THIEF14T)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was NONE)
    REPLACE_CRE_ITEM ~DART01~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~pcapt06.cre~ ~override~ //Prison Captain
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8
    WRITE_ASCII 0x250 ~bpprt12b~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REMOVE_MEMORIZED_SPELL ~sppr511~
    REMOVE_MEMORIZED_SPELL ~sppr608~
    REMOVE_MEMORIZED_SPELL ~sppr603~
    ADD_MEMORIZED_SPELL ~sppr599~ #4 ~priest~ (2)
    ADD_MEMORIZED_SPELL ~sppr699~ #5 ~priest~
    ADD_MEMORIZED_SPELL ~sppr698~ #5 ~priest~
  END
BUT_ONLY

COPY_EXISTING ~pdwarf01.cre~ ~override~ //Dwarf Thrall
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 40 // DtectIll (was 0)
    WRITE_BYTE 0x68 60 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~pmaster.cre~ ~override~ //Master of Thralls
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 74 // CurrHP (was 54)
    WRITE_SHORT 0x26 74 // MaxHP (was 54)
    WRITE_ASCII 0x250 ~humansht~ #8
    WRITE_ASCII 0x258 ~bpleader~ #8
    WRITE_ASCII 0x260 ~bptanari~ #8 // Race (was TANARI2)
    WRITE_ASCII 0x260 ~bpdemon~ #8 // General (was WTASIGHT)
  END
BUT_ONLY


COPY_EXISTING ~pthral02.cre~ ~override~ //Thrall
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~bpmag12a~ #8 // Race (was )
    WRITE_ASCII 0x268 ~bpwtrsgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~DART01~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY


COPY_EXISTING ~pthral04.cre~ ~override~ //Thrall
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~bpmag12b~ #8 // Race (was )
    WRITE_ASCII 0x268 ~bpwtrsgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~DAGG02~ #0 #0 #0 ~NONE~ ~WEAPON1~
    REPLACE_CRE_ITEM ~DAGG16~ #20 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
  END
BUT_ONLY

COPY_EXISTING ~pthral08.cre~ ~override~ //Thrall
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~bpmag12b~ #8 // Race (was )
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~DAGG05~ #20 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~pthral09.cre~ ~override~ //Thrall
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x258 ~bpprst12~ #8 // Race (was )
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~DAGG05~ #20 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~pwarden.cre~ ~override~ //Warden
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x258 ~bpmag18d~ #8 // Race (was )
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~raelis.cre~ ~override~ //Raelis Shai
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x48 4 // ACEffec (was 10)
    WRITE_ASCII 0x250 ~bp!plot~ #8 // Class (was SHOUT)
    WRITE_ASCII 0x258 ~bpmage8a~ #8 // Race (was NONE)
    WRITE_ASCII 0x260 ~bp!bard~ #8 // General (was MAGE8A)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~DAGG02~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~DAGG05~ #20 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~pthral01.cre~ ~override~ //Thrall Leader
              ~pthral05.cre~ ~override~ //Female Thrall
              ~pthral07.cre~ ~override~ //Warden Thrall
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~pthral10.cre~ ~override~ //Thrall
              ~pthral11.cre~ ~override~ //Thrall
              ~pwyvv01.cre~ ~override~ //Wyvern
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x248 ~~ #8 //no shouts for thralls
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY


END

///////////////////////////RED BADGE///////////////////////////
////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION red_badge BEGIN

COPY ~BP/REDB/SOLA0002.ARE~      ~override/SOLA0002.ARE~

COPY ~BP/REDB/solasna1.cre~      ~override/solasna1.cre~       
  SAY NAME1 @402 
  SAY NAME2 @402 

COPY ~BP/REDB/solasna2.cre~      ~override/solasna2.cre~       
  SAY NAME1 @403 
  SAY NAME2 @403 

COPY ~BP/REDB/solasna3.cre~      ~override/solasna3.cre~       
  SAY NAME1 @404 
  SAY NAME2 @404 

COPY ~BP/REDB/solasna4.cre~      ~override/solasna4.cre~       
  SAY NAME1 @405 
  SAY NAME2 @405 

COPY ~BP/REDB/solasna5.cre~      ~override/solasna5.cre~       
  SAY NAME1 @406 
  SAY NAME2 @406 

COPY ~BP/REDB/solasna1.itm~      ~override/solasna1.itm~       

COPY ~BP/REDB/solasna3.itm~      ~override/solasna3.itm~       

COPY ~BP/REDB/solasna4.itm~      ~override/solasna4.itm~       

COPY ~BP/REDB/solasna5.itm~      ~override/solasna5.itm~       
  SAY NAME2 @407 
  SAY DESC @408 

COMPILE ~BP/REDB/COMPILE~

ACTION_IF FILE_EXISTS_IN_GAME ~AR3000.bcs~ BEGIN
  COPY_EXISTING ~AR3000.bcs~ ~override~
  EXTEND_TOP ~AR3000.bcs~           ~BP/REDB/tAR3000.baf~
END


END

///////////////////THE RITUAL, by Westley Weimer///////////////////
////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION ritual BEGIN


//Custom, used for ritual
COPY ~BP/RITUAL/ar0088.are~        ~override/ar0088.are~         

COPY ~BP/RITUAL/mysboot.itm~       ~override/mysboot.itm~        
  SAY NAME2 @434 
  SAY DESC @435 

COPY ~BP/RITUAL/ritamul.itm~       ~override/ritamul.itm~        
  SAY NAME2 @436 
  SAY DESC @437 

COPY ~BP/RITUAL/ritdrag.itm~       ~override/ritdrag.itm~        
  SAY NAME2 @438 
  SAY DESC @439 

COPY ~BP/RITUAL/ritgol.itm~        ~override/ritgol.itm~         

COPY ~BP/RITUAL/ritamul.spl~       ~override/ritamul.spl~        

COPY ~BP/RITUAL/ritskul1.spl~      ~override/ritskul1.spl~       

ACTION_IF NOT FILE_EXISTS_IN_GAME ~ritdrag.spl~ BEGIN
  COPY ~BP/RITUAL/ritdrag.spl~      ~override/ritdrag.spl~       
END

COPY ~BP/RITUAL/ritual.spl~        ~override/ritual.spl~         
  SAY NAME1 @440 
  SAY NAME2 @440 

COPY_EXISTING   ~wolfspir.itm~  ~override/wolfspir.itm~
                ~bearspir.itm~  ~override/bearspir.itm~
                ~lionspir.itm~  ~override/lionspir.itm~
  LPF ~DELETE_ITEM_EQEFFECT~ INT_VAR opcode_to_delete = 65 END   // no blur -- bugfix 
BUT_ONLY_IF_IT_CHANGES 

COPY ~BP/RITUAL/ritac1.cre~        ~override/ritac1.cre~         
  SAY NAME1 @415 
  SAY NAME2 @415 

COPY ~BP/RITUAL/ritb1.cre~         ~override/ritb1.cre~          
  SAY NAME1 @416 
  SAY NAME2 @416 

COPY ~BP/RITUAL/ritbear.cre~       ~override/ritbear.cre~        

COPY ~BP/RITUAL/ritcount.cre~      ~override/ritcount.cre~       
  SAY NAME1 @417 
  SAY NAME2 @417 

COPY ~BP/RITUAL/ritd1.cre~         ~override/ritd1.cre~          
  SAY NAME1 @418 
  SAY NAME2 @418 

COPY ~BP/RITUAL/ritdrag.cre~       ~override/ritdrag.cre~        
  SAY NAME1 @419 
  SAY NAME2 @419 

COPY ~BP/RITUAL/ritend.cre~        ~override/ritend.cre~         
  SAY NAME1 @420 
  SAY NAME2 @420 

COPY ~BP/RITUAL/ritgol0.cre~       ~override/ritgol0.cre~        
  SAY NAME1 @421 
  SAY NAME2 @421 

COPY ~BP/RITUAL/ritgol1.cre~       ~override/ritgol1.cre~        
  SAY NAME1 @422 
  SAY NAME2 @422 

COPY ~BP/RITUAL/ritgol2.cre~       ~override/ritgol2.cre~        
  SAY NAME1 @423 
  SAY NAME2 @423 

COPY ~BP/RITUAL/ritgol3.cre~       ~override/ritgol3.cre~        

COPY ~BP/RITUAL/ritguard.cre~      ~override/ritguard.cre~       
  SAY NAME1 @424 
  SAY NAME2 @424 

COPY ~BP/RITUAL/riti1.cre~         ~override/riti1.cre~          
  SAY NAME1 @425 
  SAY NAME2 @425 

COPY ~BP/RITUAL/ritkm1.cre~        ~override/ritkm1.cre~         
  SAY NAME1 @426 
  SAY NAME2 @426 

COPY ~BP/RITUAL/ritkt1.cre~        ~override/ritkt1.cre~         
  SAY NAME1 @427 
  SAY NAME2 @427 

COPY ~BP/RITUAL/ritlion.cre~       ~override/ritlion.cre~        

COPY ~BP/RITUAL/ritm1.cre~         ~override/ritm1.cre~          
  SAY NAME1 @428 
  SAY NAME2 @428 

COPY ~BP/RITUAL/ritpont.cre~       ~override/ritpont.cre~        
  SAY NAME1 @429 
  SAY NAME2 @429 

COPY ~BP/RITUAL/rits1.cre~         ~override/rits1.cre~          
  SAY NAME1 @430 
  SAY NAME2 @430 

COPY ~BP/RITUAL/ritsf1.cre~        ~override/ritsf1.cre~         
  SAY NAME1 @431 
  SAY NAME2 @431 

COPY ~BP/RITUAL/ritskul1.cre~      ~override/ritskul1.cre~       
  SAY NAME1 @432 
  SAY NAME2 @432 

COPY ~BP/RITUAL/ritw1.cre~         ~override/ritw1.cre~          
  SAY NAME1 @433 
  SAY NAME2 @433 

COPY ~BP/RITUAL/ritwolf.cre~       ~override/ritwolf.cre~        

COMPILE ~BP/RITUAL/D~

COMPILE ~BP/RITUAL/BAF~

ACTION_IF FILE_EXISTS_IN_GAME ~AR0088.BCS~ THEN BEGIN
  COPY_EXISTING ~AR0088.BCS~ ~override~
  EXTEND_BOTTOM ~AR0088.BCS~  ~BP/RITUAL/AR0088.BAF~
END
ELSE BEGIN
  COMPILE ~BP/RITUAL/AR0088.BAF~
END

ACTION_IF FILE_EXISTS_IN_GAME ~AR3000.bcs~ BEGIN
 COPY_EXISTING ~AR3000.bcs~ ~override~
 EXTEND_TOP ~AR3000.BCS~           ~BP/RITUAL/tAR3000.BAF~
END

END

////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION shadelord BEGIN

INCLUDE ~bp/lib/bp_main.tph~

LAF shadow_scripts END

//Can't pollute shadow rules w/ this item
ACTION_IF NOT FILE_EXISTS_IN_GAME ~shadeld.itm~ BEGIN
  COPY ~bp/itm/shadeld.itm~ ~override~
END

COPY_EXISTING ~rngwlf01.cre~ ~override~ //Anath
              ~rngwlf02.cre~ ~override~ //Anath
              ~rngwlf03.cre~ ~override~ //Anath
              ~rngwlf04.cre~ ~override~ //Anath
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~bpwdasgt~ #8 // Class (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~rngsha.cre~ ~override~ //Shadow
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x234 7 // HighestLevelPrimary (was 4)
    WRITE_ASCII 0x248 ~creshout~ #8 
    WRITE_ASCII 0x268 ~bpshadow~ #8 // Default (was WTASIGHT)
    REMOVE_MEMORIZED_SPELL ~spwi112~
    REMOVE_MEMORIZED_SPELL ~spwi212~
    REMOVE_MEMORIZED_SPELL ~spwi304~
    REMOVE_MEMORIZED_SPELL ~spwi306~
    REMOVE_MEMORIZED_SPELL ~spwi308~
    REMOVE_MEMORIZED_SPELL ~spwi402~
    REMOVE_MEMORIZED_SPELL ~spwi415~
    REMOVE_MEMORIZED_SPELL ~spwi501~
    REMOVE_MEMORIZED_SPELL ~spwi502~
    REMOVE_MEMORIZED_SPELL ~spwi504~
    REMOVE_MEMORIZED_SPELL ~spwi508~
    REMOVE_MEMORIZED_SPELL ~spwi601~
    REMOVE_MEMORIZED_SPELL ~spwi602~
    REMOVE_MEMORIZED_SPELL ~spwi604~
    ADD_MEMORIZED_SPELL ~spwi106~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi125~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi105~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi212~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi205~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi201~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi317~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi305~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi314~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi409~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi412~ #3 ~wizard~
  END
BUT_ONLY

COPY_EXISTING ~rngsha01.cre~ ~override~ //Shadow
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x234 7 // HighestLevelPrimary (was 4)
    WRITE_ASCII 0x248 ~creshout~ #8 
    WRITE_ASCII 0x268 ~bpshadow~ #8 // Default (was WTASIGHT)
    REMOVE_MEMORIZED_SPELL ~spwi112~
    REMOVE_MEMORIZED_SPELL ~spwi212~
    REMOVE_MEMORIZED_SPELL ~spwi304~
    REMOVE_MEMORIZED_SPELL ~spwi308~
    REMOVE_MEMORIZED_SPELL ~spwi415~
    REMOVE_MEMORIZED_SPELL ~spwi502~
    REMOVE_MEMORIZED_SPELL ~spwi504~
    REMOVE_MEMORIZED_SPELL ~spwi602~
    REMOVE_MEMORIZED_SPELL ~spwi604~
    ADD_MEMORIZED_SPELL ~spwi106~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi105~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi125~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi212~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi205~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi201~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi305~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi317~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi314~ #2 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi409~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi415~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi513~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi512~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi618~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi607~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~sumshad~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~rngsha02.cre~ ~override~ //Shadow Patrick
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 135 // CurrHP (was 60)
    WRITE_SHORT 0x26 135 // MaxHP (was 60)
    WRITE_SHORT 0x46 ~-2~ // ACNatul (was 3)
    WRITE_SHORT 0x48 ~-2~ // ACEffec (was 3)
    WRITE_BYTE 0x54 9 // SaveVDth (was 13)
    WRITE_BYTE 0x55 14 // SaveVWnd (was 15)
    WRITE_BYTE 0x56 13 // SaveVPoly (was 14)
    WRITE_BYTE 0x57 10 // SaveVAtks (was 16)
    WRITE_BYTE 0x58 12 // SaveVspell (was 16)
    WRITE_BYTE 0x5b 100 // RstElec (was 0)
    WRITE_BYTE 0x234 16 // HighestLevelPrimary (was 5)
    WRITE_BYTE 0x238 18 // Str (was 13)
    WRITE_BYTE 0x239 76 // StrBon (was 0)
    WRITE_BYTE 0x23c 18 // Dex (was 10)
    WRITE_BYTE 0x241 1 // Racial (was 255)
    WRITE_ASCII 0x250 ~creshout~ #8 // Class (was GPSHOUT)
    WRITE_ASCII 0x260 ~~ #8 // General (was PRIES6A)
    WRITE_ASCII 0x268 ~bpshadow~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x270 128 // EnemyAlly (was 255)
    WRITE_BYTE 0x272 149 // IDSRace (was 132)
    REMOVE_MEMORIZED_SPELL ~spwi112~
    REMOVE_MEMORIZED_SPELL ~spwi212~
    REMOVE_MEMORIZED_SPELL ~spwi304~
    REMOVE_MEMORIZED_SPELL ~spwi308~
    REMOVE_MEMORIZED_SPELL ~spwi402~
    REMOVE_MEMORIZED_SPELL ~spwi415~
    REMOVE_MEMORIZED_SPELL ~spwi502~
    REMOVE_MEMORIZED_SPELL ~spwi504~
    REMOVE_MEMORIZED_SPELL ~spwi602~
    REMOVE_MEMORIZED_SPELL ~spwi604~
    ADD_MEMORIZED_SPELL ~spwi112~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi106~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi105~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi125~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi212~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi205~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi201~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi305~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi304~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi314~ #2 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi405~ #3 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi409~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi412~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi513~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi512~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi607~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi618~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~sumshad~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~rngsha03.cre~ ~override~ //Shadow
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x234 7 // HighestLevelPrimary (was 4)
    WRITE_ASCII 0x250 ~creshout~ #8 // Class (was GPSHOUT)
    WRITE_ASCII 0x268 ~bpshadow~ #8 // Default (was WTASIGHT)
    REMOVE_MEMORIZED_SPELL ~spwi112~
    REMOVE_MEMORIZED_SPELL ~spwi212~
    REMOVE_MEMORIZED_SPELL ~spwi304~
    REMOVE_MEMORIZED_SPELL ~spwi308~
    REMOVE_MEMORIZED_SPELL ~spwi402~
    REMOVE_MEMORIZED_SPELL ~spwi415~
    REMOVE_MEMORIZED_SPELL ~spwi502~
    REMOVE_MEMORIZED_SPELL ~spwi504~
    REMOVE_MEMORIZED_SPELL ~spwi602~
    REMOVE_MEMORIZED_SPELL ~spwi604~
    ADD_MEMORIZED_SPELL ~spwi106~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi105~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi125~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi212~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi205~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi201~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi305~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi317~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi314~ #2 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi405~ #3 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi409~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi412~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi513~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi512~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi607~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi618~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~sumshad~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~rngsha04.cre~ ~override~ //Shadow Jailor
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 80 // CurrHP (was 60)
    WRITE_SHORT 0x26 80 // MaxHP (was 60)
    WRITE_BYTE 0x234 9 // HighestLevelPrimary (was 5)
    WRITE_ASCII 0x250 ~creshout~ #8 // Class (was GPSHOUT)
    WRITE_ASCII 0x260 ~bpmag14m~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpshadow~ #8 // Default (was WTASIGHT)
    REMOVE_MEMORIZED_SPELL ~spwi112~
    REMOVE_MEMORIZED_SPELL ~spwi212~
    REMOVE_MEMORIZED_SPELL ~spwi304~
    REMOVE_MEMORIZED_SPELL ~spwi308~
    REMOVE_MEMORIZED_SPELL ~spwi402~
    REMOVE_MEMORIZED_SPELL ~spwi415~
    REMOVE_MEMORIZED_SPELL ~spwi502~
    REMOVE_MEMORIZED_SPELL ~spwi504~
    REMOVE_MEMORIZED_SPELL ~spwi602~
    REMOVE_MEMORIZED_SPELL ~spwi604~
    ADD_MEMORIZED_SPELL ~spwi106~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi105~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi125~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi212~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi201~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi205~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi305~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi317~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi314~ #2 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi405~ #3 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi409~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi412~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi513~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi512~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi607~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi618~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~sumshad~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~rngsha2d.cre~ ~override~ //Shadow Patrick
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x234 11 // HighestLevelPrimary (was 5)
    WRITE_ASCII 0x250 ~creshout~ #8 // Class (was GPSHOUT)
    WRITE_ASCII 0x260 ~bpmag14m~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpshadow~ #8 // Default (was WTASIGHT)
    REMOVE_MEMORIZED_SPELL ~spwi112~
    REMOVE_MEMORIZED_SPELL ~spwi212~
    REMOVE_MEMORIZED_SPELL ~spwi304~
    REMOVE_MEMORIZED_SPELL ~spwi308~
    REMOVE_MEMORIZED_SPELL ~spwi402~
    REMOVE_MEMORIZED_SPELL ~spwi415~
    REMOVE_MEMORIZED_SPELL ~spwi502~
    REMOVE_MEMORIZED_SPELL ~spwi504~
    REMOVE_MEMORIZED_SPELL ~spwi602~
    REMOVE_MEMORIZED_SPELL ~spwi604~
    ADD_MEMORIZED_SPELL ~spwi106~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi125~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi105~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi212~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi205~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi201~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi305~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi317~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi314~ #2 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi405~ #3 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi409~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi412~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi513~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi512~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi607~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi618~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~sumshad~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~rumar01.cre~ ~override~ //Umar
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~bpmag14m~ #8 // Class (was NONE)
    WRITE_ASCII 0x260 ~bpwtrsgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~DAGG05~ #20 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~rumar02.cre~ ~override~ //Nabassu
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~cresht01~ #8 // Class (was NONE)
    WRITE_ASCII 0x250 ~bptanari~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpdemon~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~rumar03.cre~ ~override~ //Imp
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x248 ~cresht01~ #8 // Class (was NONE)
    WRITE_ASCII 0x258 ~bpmage8b~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~sdshadfi.cre~ ~override~ //Shadow Fiend
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~creshout~ #8 // Class (was NONE)
    WRITE_ASCII 0x258 ~bpmag14m~ #8 // Race (was NONE)
    WRITE_ASCII 0x268 ~bpshadow~ #8
    WRITE_BYTE 0x271 4 // IDSGeneral (was 1)
    REMOVE_KNOWN_SPELL ~spwi112~
    REMOVE_KNOWN_SPELL ~spwi304~
    REMOVE_KNOWN_SPELL ~spwi502~
    REMOVE_KNOWN_SPELL ~spwi402~
    REMOVE_KNOWN_SPELL ~spwi415~
    REMOVE_KNOWN_SPELL ~spwi308~
    REMOVE_KNOWN_SPELL ~spwi504~
    REMOVE_MEMORIZED_SPELL ~spwi112~
    REMOVE_MEMORIZED_SPELL ~spwi212~
    REMOVE_MEMORIZED_SPELL ~spwi304~
    REMOVE_MEMORIZED_SPELL ~spwi308~
    REMOVE_MEMORIZED_SPELL ~spwi402~
    REMOVE_MEMORIZED_SPELL ~spwi415~
    REMOVE_MEMORIZED_SPELL ~spwi502~
    REMOVE_MEMORIZED_SPELL ~spwi504~
    REMOVE_MEMORIZED_SPELL ~spwi602~
    REMOVE_MEMORIZED_SPELL ~spwi604~
    ADD_MEMORIZED_SPELL ~spwi106~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi105~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi125~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi212~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi201~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi205~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi305~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi317~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi314~ #2 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi405~ #3 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi409~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi412~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi513~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi512~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi607~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi618~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~sumshad~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~sdshadow.cre~ ~override~ //Shadow
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 60 // CurrHP (was 30)
    WRITE_SHORT 0x26 60 // MaxHP (was 30)
    WRITE_SHORT 0x46 5 // ACNatul (was 7)
    WRITE_SHORT 0x48 5 // ACEffec (was 7)
    WRITE_BYTE 0x234 6 // HighestLevelPrimary (was 12)
    WRITE_ASCII 0x248 ~creshout~ #8 // Class (was NONE)
    WRITE_ASCII 0x258 ~bpmag14m~ #8 // Race (was NONE)
    WRITE_ASCII 0x268 ~bpshadow~ #8 // Default (was WTASIGHT)
    WRITE_BYTE 0x271 4 // IDSGeneral (was 1)
    REMOVE_MEMORIZED_SPELL ~spwi112~
    REMOVE_MEMORIZED_SPELL ~spwi212~
    REMOVE_MEMORIZED_SPELL ~spwi304~
    REMOVE_MEMORIZED_SPELL ~spwi308~
    REMOVE_MEMORIZED_SPELL ~spwi402~
    REMOVE_MEMORIZED_SPELL ~spwi415~
    REMOVE_MEMORIZED_SPELL ~spwi502~
    REMOVE_MEMORIZED_SPELL ~spwi504~
    REMOVE_MEMORIZED_SPELL ~spwi602~
    REMOVE_MEMORIZED_SPELL ~spwi604~
    ADD_MEMORIZED_SPELL ~spwi106~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi105~ #0 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi125~ #0 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi212~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi201~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi205~ #1 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi305~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi317~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi314~ #2 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi419~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi405~ #3 ~wizard~ (2)
    ADD_MEMORIZED_SPELL ~spwi409~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi412~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi512~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi513~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi607~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi618~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~sumshad~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~shadel.cre~ ~override~ //Shade Lord
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 175 // CurrHP (was 85)
    WRITE_SHORT 0x26 175 // MaxHP (was 85)
    WRITE_SHORT 0x46 ~-6~ // ACNatul (was -2)
    WRITE_SHORT 0x48 ~-6~ // ACEffec (was -2)
    WRITE_BYTE 0x5a 100 // RstCold (was 0)
    WRITE_BYTE 0x5b 100 // RstElec (was 0)
    WRITE_BYTE 0x5d 65 // RstMagc (was 50)
    WRITE_BYTE 0x5f 100 // RstMCld (was 0)
    WRITE_BYTE 0x60 25 // RstSlash (was 0)
    WRITE_BYTE 0x61 25 // RstCrush (was 0)
    WRITE_BYTE 0x62 25 // RstPierc (was 0)
    WRITE_BYTE 0x63 25 // RstMissl (was 0)
    WRITE_BYTE 0x64 75 // DtectIll (was 0)
    WRITE_ASCII 0x250 ~cresht01~ #8 // Class (was gpshout)
    WRITE_ASCII 0x260 ~bpmag14m~ #8 // General (was wtasight)
    WRITE_ASCII 0x268 ~bpshadow~ #8 // Default
    WRITE_BYTE 0x27b 35 // Alignment (neutral_evil, was 33 neutral_good)
    REMOVE_MEMORIZED_SPELL ~spin117~ //Berserk
    REMOVE_KNOWN_SPELL ~spin117~
    ADD_MEMORIZED_SPELL ~spwi105~ #0 ~wizard~ //Color spray
    ADD_MEMORIZED_SPELL ~spwi106~ #0 ~wizard~ (2) //Blindness
    ADD_MEMORIZED_SPELL ~spwi118~ #0 ~wizard~ (3) //Chromatic Orb
    ADD_MEMORIZED_SPELL ~spwi125~ #0 ~wizard~ (2) //Spook
    ADD_MEMORIZED_SPELL ~spwi201~ #1 ~wizard~ //Blur
    ADD_MEMORIZED_SPELL ~spwi205~ #1 ~wizard~ (2) //Horror
    ADD_MEMORIZED_SPELL ~spwi212~ #1 ~wizard~ (2) //Stinking Cloud
    ADD_MEMORIZED_SPELL ~spwi305~ #2 ~wizard~ //Haste
    ADD_MEMORIZED_SPELL ~spwi306~ #2 ~wizard~ //Hold Person
    ADD_MEMORIZED_SPELL ~spwi314~ #2 ~wizard~ (2) //Vampiric Touch
    ADD_MEMORIZED_SPELL ~spwi317~ #2 ~wizard~ //Ghost Armor
    ADD_MEMORIZED_SPELL ~spwi405~ #3 ~wizard~ //Improved Invisibility
    ADD_MEMORIZED_SPELL ~spwi409~ #3 ~wizard~ (2) //Contagion
    ADD_MEMORIZED_SPELL ~spwi412~ #3 ~wizard~ //Greater Malison
    ADD_MEMORIZED_SPELL ~spwi419~ #3 ~wizard~ //Secret Word
    ADD_MEMORIZED_SPELL ~spwi501~ #4 ~wizard~ //Animate Dead
    ADD_MEMORIZED_SPELL ~spwi505~ #4 ~wizard~ //Shadow Door
    ADD_MEMORIZED_SPELL ~spwi508~ #4 ~wizard~ //Chaos
    ADD_MEMORIZED_SPELL ~spwi511~ #4 ~wizard~ //Protection from Normal Weapons
    ADD_MEMORIZED_SPELL ~spwi513~ #4 ~wizard~ //Breach
    ADD_MEMORIZED_SPELL ~spwi601~ #5 ~wizard~ //Invisible Stalker
    ADD_MEMORIZED_SPELL ~spwi607~ #5 ~wizard~ //Mislead
    ADD_MEMORIZED_SPELL ~spwi618~ #5 ~wizard~ //Spell Deflection
    ADD_MEMORIZED_SPELL ~spwi624~ #5 ~wizard~ //Summon Nishruu
    ADD_MEMORIZED_SPELL ~spwi711~ #6 ~wizard~ //Sphere of Chaos
    ADD_MEMORIZED_SPELL ~spwi715~ #6 ~wizard~ //Power Word: Stun
    ADD_MEMORIZED_SPELL ~spwi899~ #7 ~wizard~ //Symbol: Fear
    ADD_MEMORIZED_SPELL ~sumshad~ #0 ~innate~ (4) //Summon Shadow Fiends
    REMOVE_CRE_ITEM ~immune1~ ~p3-12m4~
    REPLACE_CRE_ITEM ~immune2~ #0 #0 #0 ~NONE~ ~RRING~
    REPLACE_CRE_ITEM ~shadeld~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
  END
BUT_ONLY

COPY_EXISTING ~shalt01.cre~ ~override~ //Shadow Altar
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 275 // CurrHP (was 100)
    WRITE_SHORT 0x26 275 // MaxHP (was 100)
    WRITE_SHORT 0x46 ~-5~ // ACNatul (was 2)
    WRITE_SHORT 0x48 ~-7~ // ACEffec (was 2)
    WRITE_SHORT 0x4a ~-2~ // ACCrush (was 0)
    WRITE_SHORT 0x4e 3 // ACPierc (was 0)
    WRITE_SHORT 0x50 2 // ACSlash (was 0)
    WRITE_BYTE 0x59 100 // RstFire (was 0)
    WRITE_BYTE 0x5a 100 // RstCold (was 0)
    WRITE_BYTE 0x5b 100 // RstElec (was 0)
    WRITE_BYTE 0x5c 40 // RstAcid (was 0)
    WRITE_BYTE 0x5d 75 // RstMagc (was 0)
    WRITE_BYTE 0x5e 85 // RstMFre (was 0)
    WRITE_BYTE 0x5f 90 // RstMCld (was 0)
    WRITE_BYTE 0x60 25 // RstSlash (was 0)
    WRITE_BYTE 0x62 50 // RstPierc (was 0)
    WRITE_BYTE 0x63 75 // RstMissl (was 0)
    WRITE_BYTE 0x64 100 // DtectIll (was 0)
    WRITE_BYTE 0x6d 3 // Luck (was 0)
    WRITE_BYTE 0x234 14 // HighestLevelPrimary (was 8)
    WRITE_BYTE 0x235 14 // HighestLevelSecond (was 9)
    WRITE_BYTE 0x236 14 // HighestLevelTertiary (was 5)
    WRITE_BYTE 0x23f 20 // Mor (was 16)
  END
BUT_ONLY

// This file is in both components, the BUT_ONLY check should prevent duplicate install
COPY_EXISTING ~shawol01.cre~ ~override~ //Shade Wolf
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x234 5 // HighestLevelPrimary (was 4)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
    REMOVE_CRE_ITEM ~P1-8~
    REPLACE_CRE_ITEM ~SHADOWWP~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
  END
BUT_ONLY

COPY_EXISTING ~shawol02.cre~ ~override~ //Greater Shade Wolf
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x46 3 // ACNatul (was 6)
    WRITE_SHORT 0x48 3 // ACEffec (was 6)
    WRITE_BYTE 0x53 7 // NOAtt (was 1)
    WRITE_BYTE 0x59 231 // RstFire (was 0)
    WRITE_BYTE 0x5a 100 // RstCold (was 0)
    WRITE_BYTE 0x5b 100 // RstElec (was 0)
    WRITE_BYTE 0x5e 231 // RstMFre (was 0)
    WRITE_BYTE 0x5f 100 // RstMCld (was 0)
    WRITE_BYTE 0x234 7 // HighestLevelPrimary (was 5)
    WRITE_BYTE 0x239 51 // StrBon (was 0)
    WRITE_BYTE 0x23c 22 // Dex (was 9)
    WRITE_BYTE 0x23d 19 // Con (was 9)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
    REMOVE_CRE_ITEM ~P2-16~
    REPLACE_CRE_ITEM ~WOLFVA1~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
  END
BUT_ONLY


END


//////Improved Encounters--Gebhard Blucher and Kensai Ryu//////
////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION random_encounters BEGIN


INCLUDE ~bp/lib/bp_main.tph~

LAF thief_rules END

COPY ~bp/gbenc/gbband1a.cre~ ~override/gbband1a.cre~

COPY ~bp/gbenc/gbband1b.cre~ ~override/gbband1b.cre~

COPY ~bp/gbenc/gbband1c.cre~ ~override/gbband1c.cre~

COPY ~bp/gbenc/gbband1d.cre~ ~override/gbband1d.cre~

COPY ~bp/gbenc/gbene01a.cre~ ~override/gbene01a.cre~

COPY ~bp/gbenc/gbene01b.cre~ ~override/gbene01b.cre~

COPY ~bp/gbenc/gbene01c.cre~ ~override/gbene01c.cre~

COPY ~bp/gbenc/gbene01d.cre~ ~override/gbene01d.cre~

COPY ~bp/gbenc/gbene01e.cre~ ~override/gbene01e.cre~

COPY ~bp/gbenc/gbene01f.cre~ ~override/gbene01f.cre~

COPY ~bp/gbenc/gbene02a.cre~ ~override/gbene02a.cre~

COPY ~bp/gbenc/gbene02b.cre~ ~override/gbene02b.cre~

COPY ~bp/gbenc/gbene02c.cre~ ~override/gbene02c.cre~

COPY ~bp/gbenc/gbene02d.cre~ ~override/gbene02d.cre~

COPY ~bp/gbenc/gbene02e.cre~ ~override/gbene02e.cre~

COPY ~bp/gbenc/gbene02f.cre~ ~override/gbene02f.cre~

COPY ~bp/gbenc/gbhrep1a.cre~ ~override/gbhrep1a.cre~

COPY ~bp/gbenc/gbhrep1b.cre~ ~override/gbhrep1b.cre~

COPY ~bp/gbenc/gbhrep1c.cre~ ~override/gbhrep1c.cre~

COPY ~bp/gbenc/gbhrep1d.cre~ ~override/gbhrep1d.cre~

COPY ~bp/gbenc/gbhrep1e.cre~ ~override/gbhrep1e.cre~

COPY ~bp/gbenc/gbshtf1c.cre~ ~override/gbshtf1c.cre~


COPY_EXISTING ~reband01.cre~ ~override~ //Bandit
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x68 60 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpbounty~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin487~ #0 ~innate~ (3)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~reband02.cre~ ~override~ //Bandit
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 45 // CurrHP (was 40)
    WRITE_SHORT 0x26 45 // MaxHP (was 40)
    WRITE_BYTE 0x238 17 // Str (was 9)
    WRITE_BYTE 0x23c 16 // Dex (was 9)
    WRITE_BYTE 0x23d 15 // Con (was 9)
    WRITE_ASCII 0x268 ~bpbounty~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin487~ #0 ~innate~ (2)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~reband04.cre~ ~override~ //Bandit
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    REPLACE_CRE_ITEM ~DAGG05~ #20 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~recler01.cre~ ~override~ //Slaver
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 28 // CurrHP (was 14)
    WRITE_SHORT 0x26 28 // MaxHP (was 14)
    WRITE_ASCII 0x268 ~wbasight~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~redrad01.cre~ ~override~ //Dradeel
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x48 4 // ACEffec (was 10)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~DART04~ #30 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~STAF02~ #0 #0 #0 ~NONE~ ~WEAPON2~
    SET_BG2_PROFICIENCY ~PROFICIENCYDART~ 1
  END
BUT_ONLY

COPY_EXISTING ~refigh01.cre~ ~override~ //Slaver
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 28 // CurrHP (was 20)
    WRITE_SHORT 0x26 28 // MaxHP (was 20)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    ADD_CRE_ITEM ~BOW01~ #0 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~remage01.cre~ ~override~ //Slaver Wizard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 21 // CurrHP (was 8)
    WRITE_SHORT 0x26 21 // MaxHP (was 8)
    WRITE_ASCII 0x268 ~wgarsgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~STAF01~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED
    REPLACE_CRE_ITEM ~DART01~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~rerak01.cre~ ~override~ //Traveler
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 52 // CurrHP (was 32)
    WRITE_SHORT 0x26 52 // MaxHP (was 32)
    WRITE_ASCII 0x268 ~wgarsgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~rerak02.cre~ ~override~ //Traveler
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 58 // CurrHP (was 32)
    WRITE_SHORT 0x26 58 // MaxHP (was 32)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~rerak03.cre~ ~override~ //Traveler
              ~rerak06.cre~ ~override~ //Traveler
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 54 // CurrHP (was 32)
    WRITE_SHORT 0x26 54 // MaxHP (was 32)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~rerak04.cre~ ~override~ //Traveler
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 56 // CurrHP (was 32)
    WRITE_SHORT 0x26 56 // MaxHP (was 32)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~rerak05.cre~ ~override~ //Traveler
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 59 // CurrHP (was 32)
    WRITE_SHORT 0x26 59 // MaxHP (was 32)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~resuna.cre~ ~override~ //Suna Seni
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 58 // CurrHP (was 50)
    WRITE_SHORT 0x26 58 // MaxHP (was 50)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~rethie01.cre~ ~override~ //Slaver
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 55 // CurrHP (was 10)
    WRITE_SHORT 0x26 55 // MaxHP (was 10)
    WRITE_BYTE 0x64 25 // DtectIll (was 0)
    WRITE_BYTE 0x68 40 // Stealth (was 20)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTARSGT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~rethie02.cre~ ~override~ //Slaver
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x64 40 // DtectIll (was 0)
    WRITE_BYTE 0x68 60 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (4)
  END
BUT_ONLY

COPY_EXISTING ~rethie03.cre~ ~override~ //Slaver
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x64 40 // DtectIll (was 0)
    WRITE_BYTE 0x68 60 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (4)
  END
BUT_ONLY

COPY_EXISTING ~rethug01.cre~ ~override~ //Thug
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~rethug02.cre~ ~override~ //Mage
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_LONG 0x1c 14 // Goldcarried (was 0)
    WRITE_SHORT 0x24 36 // CurrHP (was 24)
    WRITE_SHORT 0x26 36 // MaxHP (was 24)
    WRITE_ASCII 0x268 ~wsarsgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~STAF01~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED
    REPLACE_CRE_ITEM ~DAGG05~ #20 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~rethug03.cre~ ~override~ //Thug
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~wgarsgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~rethug04.cre~ ~override~ //Thug
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x64 25 // DtectIll (was 0)
    WRITE_BYTE 0x68 40 // Stealth (was 20)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTARSGT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~reband03.cre~ ~override~ //Bandit
              ~reband05.cre~ ~override~ //Bandit
              ~recler02.cre~ ~override~ //Cleric
              ~redilav.cre~ ~override~ //Dilav
              ~reeldar.cre~ ~override~ //Eldarin
              ~repthf1.cre~ ~override~ //Shadow Thief
              ~repthf3.cre~ ~override~ //Shadow Thief
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY


COMPILE ~bp/gbenc/compile~

COPY_EXISTING ~ar0041.bcs~ ~override~
  REPLACE_TEXTUALLY ~bp/SNIP/oAR0041.baf~ ~bp/SNIP/nAR0041.baf~
BUT_ONLY
EXTEND_BOTTOM ~ar0041.bcs~ ~bp/snip/bar0041.baf~

  //only add bp druids if installed 
ACTION_IF MOD_IS_INSTALLED ~setup-bp.tp2~ ~1140~ OR MOD_IS_INSTALLED ~setup-bp.tp2~ ~1150~ BEGIN
  EXTEND_BOTTOM ~ar0041.bcs~ ~bp/SNIP/bAR0041a.baf~
END

EXTEND_BOTTOM ~ar0041.bcs~ ~bp/snip/bar0041b.baf~



ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpwdasgt.bcs~ BEGIN
  ACTION_IF MOD_IS_INSTALLED ~setup-bp.tp2~ ~175~ BEGIN
    COMPILE ~bp/baf/shouts/no_strings_2/bpwdasgt.baf~
  END ELSE BEGIN
    COMPILE ~bp/baf/re-baf/core/bpwdasgt.baf~
  END
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~wbasight.bcs~ BEGIN
  ACTION_IF MOD_IS_INSTALLED ~setup-bp.tp2~ ~175~ BEGIN
    COMPILE ~bp/baf/shouts/no_strings_2/wbasight.baf~
  END ELSE BEGIN
    COMPILE ~bp/baf/new_baf/core/wbasight.baf~
  END
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpbounty.bcs~ BEGIN
  COMPILE ~bp/baf/new_baf/core/bpbounty.baf~
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpthief.bcs~ BEGIN
  COMPILE ~bp/baf/new_baf/core/bpthief.baf~
END


EXTEND_BOTTOM ~ar0041.bcs~ ~bp/snip/bar0041b.baf~

COPY_EXISTING ~ar0042.bcs~ ~override~
  REPLACE_TEXTUALLY ~bp/SNIP/oAR0042.baf~ ~bp/SNIP/nAR0042.baf~
BUT_ONLY
EXTEND_BOTTOM ~ar0042.bcs~ ~bp/snip/bar0042.baf~

COPY_EXISTING ~ar0043.bcs~ ~override~
  REPLACE_TEXTUALLY ~bp/SNIP/oAR0043.baf~ ~bp/SNIP/nAR0043.baf~
BUT_ONLY
EXTEND_BOTTOM ~ar0043.bcs~ ~bp/snip/bar0043.baf~

COPY_EXISTING ~ar0044.bcs~ ~override~
  REPLACE_TEXTUALLY ~bp/SNIP/oAR0044.baf~ ~bp/SNIP/nAR0044.baf~
BUT_ONLY
EXTEND_BOTTOM ~ar0044.bcs~ ~bp/snip/bar0044.baf~

COPY_EXISTING ~ar0045.bcs~ ~override~
  REPLACE_TEXTUALLY ~bp/SNIP/oAR0045.baf~ ~bp/SNIP/nAR0045.baf~
BUT_ONLY
EXTEND_BOTTOM ~ar0045.bcs~ ~bp/snip/bar0045.baf~

COPY_EXISTING ~amntrp01.bcs~ ~override~
  REPLACE_TEXTUALLY ~bp/SNIP/oAMNTRP1.baf~ ~bp/SNIP/nAMNTRP1.baf~
BUT_ONLY

EXTEND_BOTTOM ~bodhitrp.bcs~ ~bp/baf/null/bodhitrp.baf~

EXTEND_BOTTOM ~vampsttp.bcs~ ~bp/snip/bvampstp.baf~ 
ACTION_IF MOD_IS_INSTALLED ~setup-bp.tp2~ ~800~ BEGIN
  EXTEND_BOTTOM ~vampsttp.bcs~ ~bp/snip/bvampstz.baf~ // Only add BP Shadow thieves if installed
END


END

////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION shadow_thieves BEGIN

INCLUDE ~bp/lib/bp_main.tph~

LAF shadow_thief_scripts END


COPY_EXISTING ~aran.cre~ ~override~ //Aran Linvail
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x34 ~aran~ #8
    WRITE_ASCII 0x258 ~bp!plot~ #8
    WRITE_ASCII 0x260 ~bpmag10a~ #8
    WRITE_ASCII 0x268 ~bpbounty~ #8
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (4)
    ADD_MEMORIZED_SPELL ~spin487~ #0 ~innate~ (3)
    SET_BG2_PROFICIENCY ~PROFICIENCYCROSSBOW~ 3
    SET_BG2_PROFICIENCY ~PROFICIENCYSHORTSWORD~ 3
  END
BUT_ONLY

COPY_EXISTING ~aran02.cre~ ~override~ //Aran Linvail
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x34 ~aran~ #8
    WRITE_ASCII 0x258 ~bp!plot~ #8
    WRITE_ASCII 0x260 ~bpmag10a~ #8
    WRITE_ASCII 0x268 ~bpbounty~ #8
    REMOVE_KNOWN_SPELL ~spwi116~ ~spwi217~ ~spwi306~
    REMOVE_MEMORIZED_SPELL ~spwi116~ ~spwi217~ ~spwi306~
    ADD_MEMORIZED_SPELL ~spwi103~ #0 ~wizard~ (3)
    ADD_MEMORIZED_SPELL ~spwi112~ #0 ~wizard~ (4)
    ADD_MEMORIZED_SPELL ~spwi113~ #0 ~wizard~ (4)
    ADD_MEMORIZED_SPELL ~spwi201~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi213~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi215~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi220~ #1 ~wizard~ (4)
    ADD_MEMORIZED_SPELL ~spwi302~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi304~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi305~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi308~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi311~ #2 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi401~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi405~ #3 ~wizard~ (4)
    ADD_MEMORIZED_SPELL ~spwi407~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi412~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi421~ #3 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi506~ #4 ~wizard~ (4)
    ADD_MEMORIZED_SPELL ~spwi508~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi511~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi522~ #4 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi611~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi613~ #5 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi707~ #6 ~wizard~
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (4)
    ADD_MEMORIZED_SPELL ~spin487~ #0 ~innate~ (3)
    SET_BG2_PROFICIENCY ~PROFICIENCYCROSSBOW~ 3
    SET_BG2_PROFICIENCY ~PROFICIENCYSHORTSWORD~ 3
  END
BUT_ONLY

COPY_EXISTING ~arnboy01.cre~ ~override~ //Apprentice Torturer Douglas
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~bpthfsht~ #8
    WRITE_ASCII 0x268 ~bpthief~ #8
  END
BUT_ONLY

COPY_EXISTING ~arnfgt01.cre~ ~override~ //Shadow Thief
              ~arnfgt02.cre~ ~override~ //Shadow Thief
              ~arnfgt04.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 40
    WRITE_ASCII 0x248 ~bpthfsht~ #8
    WRITE_ASCII 0x268 ~bpthief~ #8
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~arnfgt06.cre~ ~override~ //Haz
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpally~ #8
    WRITE_BYTE 0x274 0x1
    REPLACE_CRE_ITEM ~DART02~ #30 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
  END
BUT_ONLY

COPY_EXISTING ~arngrl01.cre~ ~override~ //Missy
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~bpthfsht~ #8
    WRITE_ASCII 0x268 ~bpthief~ #8
    WRITE_ASCII 0x280 ~arngrl01~ #8
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~arnman03.cre~ ~override~ //Cuchul
              ~arnman04.cre~ ~override~ //Mitsu
              ~arnman05.cre~ ~override~ //Achon
              ~arnman08.cre~ ~override~ //Shadow Thief
              ~arnman09.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 40
    WRITE_ASCII 0x248 ~bpthfsht~ #8
    WRITE_ASCII 0x268 ~bpthief~ #8
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~arntra01.cre~ ~override~ //Trainee
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 50
    WRITE_ASCII 0x248 ~bpthfsht~ #8
    WRITE_ASCII 0x260 ~~ #8
    WRITE_ASCII 0x268 ~bpthief~ #8
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~arntra02.cre~ ~override~ //Trainee
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~stdeath~ #8
    WRITE_ASCII 0x250 ~arntra02~ #8
    WRITE_ASCII 0x258 ~bpprst12~ #8
    WRITE_ASCII 0x260 ~bpmag10a~ #8
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~ EQUIP
    REPLACE_CRE_ITEM ~BULL01~ #40 #0 #0 ~NONE~ ~QUIVER1~
  END
BUT_ONLY

COPY_EXISTING ~arntra04.cre~ ~override~ //Trainee
              ~arntra06.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 36
    WRITE_BYTE 0x68 40
    WRITE_ASCII 0x258 ~bpthfsht~ #8
    WRITE_ASCII 0x268 ~bpthief~ #8
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~arnwar02.cre~ ~override~ //Shadow Thief
              ~arnwar03.cre~ ~override~ //Shadow Thief
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x64 50
    WRITE_ASCII 0x248 ~bpthfsht~ #8
    WRITE_ASCII 0x260 ~~ #8
    WRITE_ASCII 0x268 ~bpthief~ #8
    WRITE_BYTE 0x274 1
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~arnwar04.cre~ ~override~ //Shadow Thief
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x258 ~~ #8
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
    WRITE_BYTE 0x274 1
  END
BUT_ONLY

COPY_EXISTING ~arnwar08.cre~ ~override~ //Tizzak
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 50
    WRITE_ASCII 0x248 ~shoutdlg~ #8
    WRITE_ASCII 0x250 ~bpthfsht~ #8
    WRITE_ASCII 0x258 ~~ #8
    WRITE_ASCII 0x268 ~bpthief~ #8
    WRITE_BYTE 0x274 1
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~arnwar09.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~~ #8
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~arngol01.cre~ ~override~ //Golem
              ~arnwar07.cre~ ~override~ //Dedral
              ~arnwar10.cre~ ~override~ //Priest of Mask
              ~vvdead1.cre~ ~override~ //Shadow Thief
              ~vvdead2.cre~ ~override~ //Shadow Thief
              ~vvdead3.cre~ ~override~ //Shadow Thief
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~dsbody01.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was NONE)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~embarl.cre~ ~override~ //Embarl
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 25 // DtectIll (was 0)
    WRITE_BYTE 0x68 40 // Stealth (was 0)
    WRITE_ASCII 0x248 ~~ #8 // Override (was GPUSE)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~gaelan.cre~ ~override~ //Gaelan Bayle
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 50 // DtectIll (was 0)
    WRITE_ASCII 0x258 ~~ #8 // Race (was GPUSE)
    WRITE_ASCII 0x260 ~bp!plot~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was )
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (5)
  END
BUT_ONLY

COPY_EXISTING ~gaelan2.cre~ ~override~ //Gaelan Bayle
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 50 // DtectIll (was 0)
    WRITE_ASCII 0x248 ~bpmag14m~ #8 // Override (was NONE)
    WRITE_ASCII 0x260 ~bp!plot~ #8 // General (was NONE)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (5)
  END
BUT_ONLY

COPY_EXISTING ~ishaddud.cre~ ~override~ //Assassin
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 25 // DtectIll (was 0)
    WRITE_BYTE 0x68 45 // Stealth (was 20)
    WRITE_ASCII 0x250 ~bpmage8~ #8 // Class (was NONE)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was NONE)
    ADD_MEMORIZED_SPELL ~spwi212~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spwi214~ #1 ~wizard~
    ADD_MEMORIZED_SPELL ~spin118~ #0 ~innate~ (3)
    ADD_MEMORIZED_SPELL ~spcl423~ #0 ~innate~ (2)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~mook.cre~ ~override~ //Mook
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 40 // DtectIll (was 0)
    WRITE_BYTE 0x68 45 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~mook02.cre~ ~override~ //Mook
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 40 // DtectIll (was 0)
    WRITE_BYTE 0x68 60 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~mookft01.cre~ ~override~ //Shadow Thief
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x64 45 // DtectIll (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~mookft02.cre~ ~override~ //Shadow Thief
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~renal.cre~ ~override~ //Renal Bloodscalp
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    SAY NAME1 #21285 // LongName (~Renal Bloodscalp~)
    SAY NAME2 #21285 // ShortName (~Renal Bloodscalp~)
    WRITE_ASCII 0x34 ~renals~ #8 // SmallPortrait (was NONE)
    WRITE_BYTE 0x64 50 // DtectIll (was 0)
    WRITE_ASCII 0x250 ~~ #8 // Class (was USEITEM)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (4)
  END
BUT_ONLY

COPY_EXISTING ~shadth01.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~bpwdasgt~ #8 // Class (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~shadth02.cre~ ~override~ //Rogue
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~bpwdasgt~ #8 // Class (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~shth01.cre~ ~override~ //Hanz
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~shth011.cre~ ~override~ //Hanz
              ~shth02.cre~ ~override~ //Goshan
              ~shth03.cre~ ~override~ //Kretor
              ~shth04.cre~ ~override~ //Morsa
              ~shth05.cre~ ~override~ //Joster
              ~shth06.cre~ ~override~ //Varia
              ~shthlt02.cre~ ~override~ //Lathan
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~shthass1.cre~ ~override~ //Ama
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~~ #8 // Class (was SHTHASS1)
    WRITE_ASCII 0x260 ~~ #8 // General (was USEITEM)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTARSGT)
    ADD_MEMORIZED_SPELL ~spcl423~ #0 ~innate~ (2)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~shthass2.cre~ ~override~ //Shadow Thief
              ~shthdr01.cre~ ~override~ //Brannel
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was NONE)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~shthlt01.cre~ ~override~ //Jariel
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~dassin.cre~ ~override~ //Shadow Thief
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 52 // CurrHP (was 50)
    WRITE_SHORT 0x26 52 // MaxHP (was 50)
    WRITE_BYTE 0x64 40 // DtectIll (was 0)
    WRITE_BYTE 0x68 60 // Stealth (was 20)
    WRITE_ASCII 0x248 ~gpshout~ #8 // Override (was NONE)
    WRITE_ASCII 0x250 ~~ #8 // Class (was USEITEM)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spcl423~ #0 ~innate~ (2)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~flyfgt01.cre~ ~override~ //Shadow Thief
              ~flyfgt02.cre~ ~override~ //Shadow Thief
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x64 35 // DtectIll (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (3)
  END
BUT_ONLY

COPY_EXISTING ~flyfgt04.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~DAGG02~ #0 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~lin.cre~ ~override~ //Lin
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 47 // CurrHP (was 7)
    WRITE_SHORT 0x26 47 // MaxHP (was 7)
    WRITE_BYTE 0x64 25 // DtectIll (was 0)
    WRITE_BYTE 0x68 40 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was NONE)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~stass1.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 50 // DtectIll (was 0)
    WRITE_BYTE 0x68 80 // Stealth (was 100)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (4)
  END
BUT_ONLY

COPY_EXISTING ~stdeath.cre~ ~override~ //Arkanis Gath
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x239 80 // StrBon (was 0)
    WRITE_ASCII 0x268 ~bpckth2b~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spcl901~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl904~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl907~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl909~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl913~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl914~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl916~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spcl917~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (5)
    ADD_MEMORIZED_SPELL ~spin489~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spin491~ #0 ~innate~
    ADD_MEMORIZED_SPELL ~spin493~ #0 ~innate~
  END
BUT_ONLY

COPY_EXISTING ~lellyn.cre~ ~override~ //Shadow Thief
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 9 // CurrHP (was 5)
    WRITE_SHORT 0x26 9 // MaxHP (was 5)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was NONE)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~
  END
BUT_ONLY

END


/////////////////////SMALL TEETH PASS//////////////////////////

// Brown Dragon code by Hlidskialf; Brown Dragon by Kensai Ryu
// Lots of BP additions, but they only install if BP core is also installed
//////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION small_teeth_pass BEGIN



COPY ~BP/BrownDragon/FileDump~  ~override~ // File Copy 

ACTION_IF NOT FILE_EXISTS_IN_GAME ~override/dragredd.cre~ BEGIN
  COPY ~bp/suldan/dragredd.cre~ ~override/dragredd.cre~
END


ACTION_IF MOD_IS_INSTALLED ~setup-bp.tp2~ ~0~ BEGIN
  ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpmag10b~ BEGIN
    COMPILE ~bp/baf/re-baf/core/bpmag10b.baf~
  END

  ACTION_IF NOT FILE_EXISTS_IN_GAME ~bpwdasgt.bcs~ BEGIN
    ACTION_IF MOD_IS_INSTALLED ~setup-bp.tp2~ ~175~ BEGIN
      COMPILE ~bp/baf/shouts/no_strings_2/bpwdasgt.baf~
    END ELSE BEGIN
      COMPILE ~bp/baf/re-baf/core/bpwdasgt.baf~
    END
  END

  COPY ~BP/CRE/bpdragtp.cre~      ~override/bpdragtp.cre~       
    SAY NAME1 @174 
    SAY NAME2 @174
  COPY_EXISTING ~dragpurp.cre~ ~override~ //Purple Dragon
    PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
      // SAY NAME1 #72049 // LongName (was 72048)
      WRITE_ASCII 0x258 ~bpmag10b~ #8 // Race (was NONE)
      WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    END
  COPY_EXISTING ~dragyell.cre~ ~override~ //Yellow Dragon
    PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
      // SAY NAME1 #67124 // LongName (was 67123)
      WRITE_ASCII 0x250 ~bpmag10b~ #8 // Class (was NONE)
      WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    END
  EXTEND_BOTTOM ~AR1700.bcs~      ~BP/SNIP/bAR1700.baf~
END ELSE BEGIN
  EXTEND_BOTTOM ~AR1700.bcs~    ~BP/SNIP/bAR1700a.baf~
END

COMPILE ~BP/BrownDragon/baf/krdrgbrn.baf~

COPY ~bp/browndragon/filedump~ ~override~


END

//////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION tanners BEGIN

INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF tanner_scripts END

COPY ~bp/cre/tantugn1.cre~ ~override~

COPY_EXISTING ~tanadv01.cre~ ~override~ //Adventurer
              ~tanadv02.cre~ ~override~ //Adventurer
              ~tanadv03.cre~ ~override~ //Adventurer
              ~tanadv04.cre~ ~override~ //Adventurer
              ~trskin01.cre~ ~override~ //Raissa
              ~trskin03.cre~ ~override~ //Rejiek Hidesman
              ~trskin06.cre~ ~override~ //Darsidian Moor
              ~trskind1.cre~ ~override~ //Rejiek Hidesman
              ~trskind2.cre~ ~override~ //Darsidian Moor
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~tanadv05.cre~ ~override~ //Adventurer
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x250 ~bpprie8a~ #8 // Class (was MAGE6)
    WRITE_ASCII 0x258 ~bpmage6~ #8 // Race (was NONE)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~SLNG01~ #0 #0 #0 ~NONE~ ~WEAPON2~
    REPLACE_CRE_ITEM ~BULL01~ #40 #0 #0 ~NONE~ ~QUIVER1~
  END
BUT_ONLY

COPY_EXISTING ~tanadv06.cre~ ~override~ //Dunbar the Fifth
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x52 16 // THAC0 (was 20)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~tanner.cre~ ~override~ //Rejiek Hidesman
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 60 // CurrHP (was 30)
    WRITE_SHORT 0x26 60 // MaxHP (was 30)
    WRITE_BYTE 0x52 15 // THAC0 (was 20)
    WRITE_BYTE 0x235 6 // Was Level 1
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
    SET_BG2_PROFICIENCY ~PROFICIENCYBASTARDSWORD~ 1
  END
BUT_ONLY

COPY_EXISTING ~tanthf01.cre~ ~override~ //Rune Assassin
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_SHORT 0x24 96 // CurrHP (was 72)
    WRITE_SHORT 0x26 96 // MaxHP (was 72)
    WRITE_SHORT 0x46 4 // ACNatul (was 10)
    WRITE_SHORT 0x48 4 // ACEffec (was 10)
    WRITE_BYTE 0x52 9 // THAC0 (was 10) 
    WRITE_ASCII 0x268 ~bpthief~ #8
    REMOVE_CRE_ITEM ~SW1H08~ ~LEAT01~
    REPLACE_CRE_ITEM ~SW1H10~ #0 #0 #0 ~UNSTEALABLE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~LEAT07~ #0 #0 #0 ~UNSTEALABLE~ ~ARMOR~
    SET_BG2_PROFICIENCY ~PROFICIENCYSHORTSWORD~ 2
  END
BUT_ONLY

COPY_EXISTING ~tantug01.cre~ ~override~ //Thug
              ~tantug02.cre~ ~override~ //Thug
              ~tantug03.cre~ ~override~ //Thug
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 80 // CurrHP (was 60)
    WRITE_SHORT 0x26 80 // MaxHP (was 60)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
  END
BUT_ONLY

COPY_EXISTING ~tanwiz02.cre~ ~override~ //Mage
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 75 // CurrHP (was 44)
    WRITE_SHORT 0x26 75 // MaxHP (was 44)
    WRITE_SHORT 0x48 4 // ACEffec (was 10)
    WRITE_BYTE 0x52 5 // THAC0 (was 15)
    WRITE_BYTE 0x53 2 // NOAtt (was 1)
    WRITE_ASCII 0x250 ~bpmag16a~ #8
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
    REPLACE_CRE_ITEM ~STAF02~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED
    REPLACE_CRE_ITEM ~DART03~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~tanwiz03.cre~ ~override~ //Mage
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 75 // CurrHP (was 44)
    WRITE_SHORT 0x26 75 // MaxHP (was 44)
    WRITE_SHORT 0x48 4 // ACEffec (was 10)
    WRITE_BYTE 0x52 7 // THAC0 (was 15)
    WRITE_BYTE 0x53 3 // NOAtt (was 1)
    WRITE_ASCII 0x250 ~bpmag16a~ #8
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
    REPLACE_CRE_ITEM ~STAF15~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP TWOHANDED
    REPLACE_CRE_ITEM ~DART02~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~tanwiz04.cre~ ~override~ //Mage
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 65 // CurrHP (was 44)
    WRITE_SHORT 0x26 65 // MaxHP (was 44)
    WRITE_SHORT 0x48 4 // ACEffec (was 10)
    WRITE_BYTE 0x52 7 // THAC0 (was 15)
    WRITE_ASCII 0x250 ~bpmag16b~ #8
    WRITE_ASCII 0x268 ~bpwdasgt~ #8
    REPLACE_CRE_ITEM ~DART04~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~tanwiz1.cre~ ~override~ //Vellin Dahn
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 90 // CurrHP (was 62)
    WRITE_SHORT 0x26 90 // MaxHP (was 62)
    WRITE_BYTE 0x52 6 // THAC0 (was 15)
    WRITE_BYTE 0x23a 17 // Int (was 10)
  END
BUT_ONLY

END

//////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION tavern_brawl BEGIN

INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF tavern_brawl_scripts END

COPY_EXISTING ~sevpat01.cre~ ~override~ //Mencar Pebblecrusher
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x258 ~~ #8 // Race (was USEITEM)
    WRITE_ASCII 0x268 ~wsasight~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~sevpat02.cre~ ~override~ //Sorcerous Amon
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~~ #8 // General (was USEITEM)
    WRITE_ASCII 0x268 ~wbasight~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~STAF02~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~DART02~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~sevpat03.cre~ ~override~ //Pooky
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    SAY NAME1 #47310 // LongName (~Pooky~)
    SAY NAME2 #47310 // ShortName (~Pooky~)
    REMOVE_MEMORIZED_SPELL ~spwi505~
    REMOVE_MEMORIZED_SPELL ~spwi503~
  END
BUT_ONLY

COPY_EXISTING ~sevpat04.cre~ ~override~ //Smaeluv Orcslicer
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~sevpat05.cre~ ~override~ //Brennan Risling
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x258 ~~ #8 // Race (was USEITEM)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (4)
  END
BUT_ONLY



END

//////////////////////////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION trademeet BEGIN

INCLUDE ~bp/lib/bp_encounter_scripts.tph~

LAF trademeet_scripts END

COPY_EXISTING ~trcut06.cre~ ~override~ //Lord Skarmaen Alibakkar
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~DAGG03~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    REPLACE_CRE_ITEM ~DAGG16~ #20 #0 #0 ~NONE~ ~WEAPON2~
    SET_BG2_PROFICIENCY ~PROFICIENCYDAGGER~ 1
  END
BUT_ONLY

COPY_EXISTING ~trgrd03.cre~ ~override~ //Militia Captain
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x260 ~bpleader~ #8 // General (was NONE)
  END
BUT_ONLY

COPY_EXISTING ~trfued05.cre~ ~override~ //Lord Skarmaen Alibakkar
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~SW1H04~ #0 #0 #0 ~NONE~ ~WEAPON1~ EQUIP
    SET_BG2_PROFICIENCY ~PROFICIENCYLONGSWORD~ 1
  END
BUT_ONLY

COPY_EXISTING ~trfued09.cre~ ~override~ //Lurraxol Guard
              ~trfued10.cre~ ~override~ //Alibakkar Guard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_SHORT 0x24 30 // CurrHP (was 15)
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
  END
BUT_ONLY

COPY_EXISTING ~trfued11.cre~ ~override~ //Militia Wizard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x258 ~bpmage8a~ #8 // Default (was WTASIGHT)
    WRITE_ASCII 0x268 ~bpwtrsgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~DART01~ #30 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~trgrd02.cre~ ~override~ //Militia Wizard
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    REPLACE_CRE_ITEM ~DART01~ #20 #0 #0 ~NONE~ ~WEAPON2~
  END
BUT_ONLY

COPY_EXISTING ~trhmer01.cre~ ~override~ //Guildmistress Busya
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x260 ~bp!plot~ #8 // General (was NONE)
  END
BUT_ONLY

COPY_EXISTING ~trcar03.cre~ ~override~ //Caravan Driver
              ~trgyp04.cre~ ~override~ //Jidek
              ~trlgrd01.cre~ ~override~ //Lord Logan's Guard
              ~trple01.cre~ ~override~ //Wilfred the Red
              ~trthf03.cre~ ~override~ //Shadow Thief
              ~trthf04.cre~ ~override~ //Merchant
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // Default (was WTASIGHT)
    // WRITE_BYTE 0x270 255 // EnemyAlly (was 128)
  END
BUT_ONLY

COPY_EXISTING ~trgeni01.cre~ ~override~
              ~trgeni02.cre~ ~override~
              ~trgeni03.cre~ ~override~
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_ASCII 0x248 ~humansht~ #8 // Override (was GENSHT01)
    WRITE_ASCII 0x260 ~bpdjinni~ #8 // General (was )
    WRITE_ASCII 0x268 ~bpwdasgt~ #8 // General (was )
  END
BUT_ONLY

COPY_EXISTING ~trthf01.cre~ ~override~ //Itona
  LAUNCH_PATCH_FUNCTION FJ_CRE_VALIDITY RET vl = valid END
  PATCH_IF vl BEGIN
    WRITE_BYTE 0x64 30 // DtectIll (was 0)
    WRITE_BYTE 0x68 65 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY

COPY_EXISTING ~trthf02.cre~ ~override~ //Kich
  PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
    WRITE_BYTE 0x64 30 // DtectIll (was 0)
    WRITE_BYTE 0x68 55 // Stealth (was 0)
    WRITE_ASCII 0x268 ~bpthief~ #8 // Default (was WTASIGHT)
    ADD_MEMORIZED_SPELL ~spin483~ #0 ~innate~ (2)
  END
BUT_ONLY


END

////////////////////WAND OF ORCUS//////////////////////////////
//////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION wand_of_orcus BEGIN

INCLUDE ~bp/lib/bp_main.tph~

LAF demon_rules END
LAF telekinesis END


ACTION_IF NOT FILE_EXISTS_IN_GAME ~spin473.spl~ BEGIN
  COPY ~bp/spl/spin473.spl~ ~override~
END

APPEND ~spell.ids~ ~3473 SPECTATOR_SUGGESTION~ UNLESS ~SPECTATOR_SUGGESTION~


COPY ~bp/orcus/copy~ ~override~

APPEND ~spell.ids~ ~3170 ORCUS_SUMMONS~ UNLESS ~ORCUS_SUMMONS~


COPY_EXISTING ~dglab01.eff~      ~override~ 
WRITE_LONG 0x18 8 
WRITE_LONG 0x20 2 
WRITE_ASCII 0x30 ~DGLAB01~ #8 

COPY_EXISTING ~demnab01.cre~ ~override/orctnari.cre~ 
WRITE_ASCII 0x280 ~bporctnari~ #18 //orctnari.cre, called by orctnari.eff, did not exist! It has become a nabassu; hope it's nasty enough... 

//Basically, just adds the Wand to a container. Can be easily scripted instead...
//Nope, needs to be hex-patched, cause the container doesn't exist in-game.
COPY_EXISTING ~ar3020.are~ ~override~
  SAY 0x4dc @378
  LPF fj_are_structure
    INT_VAR
    fj_type        = 2
    fj_loc_x       = 689
    fj_loc_y       = 1064
    fj_lock_diff   = 130
    fj_flags       = 1
    fj_trap_detect = 130
    fj_trap_remove_diff = 130
    fj_trap_status = 0
    fj_trap_loc_x  = 689
    fj_trap_loc_y  = 1064
    fj_box_left    = 663
    fj_box_top     = 1006
    fj_box_right   = 716
    fj_box_bottom  = 1059
    fj_vertex_0    = 702 + (1006 << 16)
    fj_vertex_1    = 716 + (1051 << 16)
    fj_vertex_2    = 679 + (1059 << 16)
    fj_vertex_3    = 663 + (1021 << 16)
    fj_vertex_4    = 671 + (1006 << 16)
    fj_vertex_5    = 702 + (1006 << 16)
    STR_VAR
    fj_structure_type = container
    fj_trap_script = GTORC
    fj_name           = ~OrcusPot~
  END
  LPF fj_are_structure
    INT_VAR
    fj_con_itm_idx    = SHORT_AT 0x74 - 1 // a new container will be last in the file
    fj_charge_1       = 3
    fj_charge_2       = 1
    STR_VAR
    fj_name           = wandorc
    fj_structure_type = itm
  END

PRINT ~Adding new spells to the game ...~ 
SILENT 

COPY ~bp/Orcus/BPSPINOR.SPL~         ~override/BPSPINOR.SPL~ 
  SAY NAME1 @381 
  SAY UNIDENTIFIED_DESC @382 

ADD_SPELL ~bp/Orcus/SPWI540.SPL~ 2 5 WIZARD_DARKNESS_15_RADIUS 
  SAY NAME1 @383 
  SAY UNIDENTIFIED_DESC @384 
  SAY 0xce @385 
//get the spell's new name 
OUTER_SET WIZARD_DARKNESS_15_RADIUS -= 2000 
OUTER_SPRINT darkness ~SPWI%WIZARD_DARKNESS_15_RADIUS%~ 
VERBOSE 

COPY ~bp/orcus/spin170.spl~ ~override/spin170.spl~
  SAY NAME1 @381 //Orcus' Summoning
  SAY UNIDENTIFIED_DESC @382

ACTION_IF NOT FILE_EXISTS_IN_GAME ~spin476.spl~ BEGIN
  COPY ~bp/spl/spin476.spl~ ~override~
    SAY NAME1 @30 //Telekinesis
    SAY UNIDENTIFIED_DESC @30
  COPY ~bp/spl/spin480.spl~ ~override~
    SAY NAME1 @30 //Telekinesis
    SAY NAME2 @30 //Telekinesis
  COPY ~bp/spl/spin482.spl~ ~override~
    SAY NAME1 @30 //Telekinesis
    SAY NAME2 @30 //Telekinesis
END
  

COPY ~bp/orcus/wandorc.itm~ ~override/wandorc.itm~
  SAY NAME1 @386 
  SAY NAME2 @380 
  SAY UNIDENTIFIED_DESC @387 
  SAY DESC @388 
  WRITE_EVALUATED_ASCII 0x48e ~%darkness%~ #8 

COPY ~bp/orcus/blun665.itm~ ~override/blun665.itm~
  SAY NAME1 @379 //Large Rod
  SAY NAME2 @380 //Wand of Orcus

 
ACTION_IF NOT FILE_EXISTS_IN_GAME ~BPORCUS.bcs~ BEGIN
  COMPILE ~bp/Orcus/BPORCUS.baf~
END

COMPILE ~bp/orcus/compile/d~

COMPILE ~bp/orcus/compile/baf~

COPY ~bp/orcus/orcus.cre~ ~override/orcus.cre~
  SAY NAME1 @389 //Orcus
  SAY NAME2 @389 //Orcus
  SAY 0xc8 ~~
  SAY 0xcc ~~
  SAY 0xec ~~ [DEMOG04]
  SAY 0xf0 ~~ [DEMOG05]
  SAY 0x10c @394
  WRITE_EVALUATED_ASCII 0x828 ~%darkness%~ #8 
  WRITE_EVALUATED_ASCII 0x834 ~%darkness%~ #8 
  WRITE_EVALUATED_ASCII 0x40c ~%darkness%~ #8


END


//////////////Improved Xvart Village////////////////////////////
//////////////////////////////////////////////////////////////
DEFINE_ACTION_FUNCTION xvart_village BEGIN


ACTION_FOR_EACH xvart IN ~XVART02~ ~XVART03~ ~XVART_D~ BEGIN
  ACTION_IF NOT FILE_EXISTS_IN_GAME ~%xvart%.cre~ BEGIN
    COPY ~bp/XVART/%xvart%.CRE~            ~override~        
      SAY 0xc8 #5133
      SAY 0xcc #5134
      SAY 0xdc #5491
      SAY 0xe0 #5492
      SAY 0xec #5494
      SAY 0xf0 #5495
      SAY 0x10c #5002
      SAY 0x110 #5004
      PATCH_IF NOT FILE_EXISTS_IN_GAME ~bpwdasgt.bcs~ BEGIN //BP main is not required for this
        WRITE_ASCII SCRIPT_CLASS ~WTASIGHT~
      END
    BUT_ONLY
  END
END

ACTION_IF NOT FILE_EXISTS_IN_GAME ~XVARTPRE.cre~ BEGIN
  COPY ~bp/XVART/XVARTPRE.CRE~            ~override~
    SAY NAME1 @1004 // Xvart Shaman
    SAY NAME2 @1004 // Xvart Shaman
    SAY 0xc8 #5133
    SAY 0xcc #5134
    SAY 0xdc #5491
    SAY 0xe0 #5492
    SAY 0xec #5494
    SAY 0xf0 #5495
    SAY 0x10c #5002
    SAY 0x110 #5004
    PATCH_IF NOT FILE_EXISTS_IN_GAME ~bpwdasgt.bcs~ BEGIN //BP main is not required for this
      WRITE_ASCII SCRIPT_DEFAULT ~WTASIGHT~
    END
  BUT_ONLY
END

EXTEND_BOTTOM ~AR3498.BCS~ ~bp/XVART/AR3498.baf~      //append, not overwrites


END

