// Special Abilities database file
// The line above **must** be the first line of the special abilities file!!!
// Sample:
// \(BEGIN)
// name = Bless
// [Activation Script] = $PUBLIC $FUNC SA_Bless  // Script names in []
// -{   //  Continuations start with hyphen
// -  $RETURN $SET_CHAR_BLESS($IndexOf($Target()),true)
// -} SA_Bless;
// (parameterA) = 5    // parameter names in ()
// \(END)

\(BEGIN)
name = $$Help
Date = "September 8, 2012";
Version = ".9951";
Updates9717 = "Dispel Magic - dispel summoned monster, destroy potions; Dispel Evil/Good; Protection From Evil/Good";
Updates9763 = "added item_Whip, item_SpiritualHammer";
Updates9785 = "added AdjustInitiative to Competing and IsFast, finalized Dispel Magic";
Updates982 = "combined paladin SAs, spell_ProtectionFromEvil/Good, IsProtectedEvil/Good, cloak of displacement";
Updates9832 = "added new Charm monster script, implementing StandardDisplaySpellEffect";
Updates984 = "updated DamageMagical, race_ShortSaveBonus, added race_Elf, race_HalfElf";
Updates9851 = "added Tom's fixes of Charm Monster, Charm Person, Charm Person or Mammal, Diemension Door, Mass Charm, fixed monster_BeholderAttacks, added monster_HellHoundAttacks";
Updates9852 = "SA for Cause Disease spell added, updates for Hold SAs, Blink SAs, Gauntlets of Ogre Strength, Boots of Speed";
Updates9854 = "SA for Raise Dead and various Hold spells updated, updated / added Poison SAs";
Updates9868 = "IsHeld, IsParalyzed, Is Sleeping - changed out ComputeDamage for GetItemTargetHitBonus, updated spell_Cloudkill";
Updates9871 = "changed all OnReadyXxx to OnReady and all OnUnReadyXxx to OnUnReady, added itemSlot_Xxx for Fingers and Pack; added item_RingOfXxx for Blinking, Cold Resistance, Electrical Immunity, Fire Resistance, item_ElixirOfYouth, item_PeriaptOfHealth";
Updates9901 = "redid Global_Transfer to remove drow equipment";
Updated9904 = "redid Competing to implement Guarding / Free attacks properly";
Updates9909 = "added spell_SummonElementalAir, spell_SummonElementalWater, spell_SummonInvisibleStalker";
Updates992 = "added AbilityAdjustments and class_Spells - when db is imported into DC, these must be set to 'InteerTable', added CreateCharacterSpells CreateCharacterSpellsMinMax and LearnSpellsNum Hooks to the class_MageScribe SA to facilitate acquisition and learning of mage spells";
Updates9921 = "changed CreateCharacterSpells and CreateCharacterSpellsMinMax to KnowableSpells and KnowableSpellsMinMax, respectively and updated to work with Training Hall event";
Updates9928 = "updated LearnSpellsNum script";
Updates9932 = "updated Global_CreateCharacter, IntegerTables, Competing, spell_Barkskin, monster_ElementalImmunity, spell_ProtectionFromFire (various SAs), spell_MummyRot (various SAs). added spell_ProtectionFromLightning (various SAs)";
Updates9933 = "added spell_ReadMagic";
Updates9935 = "updated race_ShortSaveBonus/IsShortSaveBonus, IsCloakDisplaced, IsPaladinProtectedFromEvil, IsProtectedEvil, IsProtectedGood; added class_Thief and display SAs for each thief skill";
Updates9936 = "added spell_ProtectionFromAcid (various SAs), monster_PlayerControl";
Updates9939 = "fixed missing OnStep Hook for Competing, updated mosnter_ElementalGrowth, updated IsDispellingEvil, IsDispellingGood, spell_DispelEvil, spell_DispelGood, Summoned, monster_DrainStrength, IsDrainedStrength; added spell_DetectMagic and IsDetectedEvil; added spell_ProtectionFromPoison (various SAs)";
Updates9951 = "updated class_ThiefSkills, class_Paladin, spell_CharmMonster, spell_CharmPerson, spell_CharmPersonOrMammal, spell_CharmPlant, spell_MassCharm, Competing
added ranceGhast, IsCarrionStenchable, IsCarrionStenched
fixed IsShielded, spell_Shield, isImmunePoison, IsParalyzed, spell_Paralyzed
removed spell_ShieldRanger
\(END)

\(BEGIN)
name = AbilityAdjustments
<DexInit> = 3; DEX 3
-2
-1
-0
-0
-0
-0
-0
-0
-0
-0
-0
-0
--1
--2
--3; DEX 18
--3
--3
--4
--4
--4
--5
--5; DEX 25
<IntSpellsMax> = 6; INT 9
-7
-7
-7
-9
-9
-11
-11
-14
-18; INT 18
-255
-255
-255
-255
-255
-255
-255; INT 25
<IntSpellsMin> = 4; INT 9
-5
-5
-5
-6
-6
-7
-7
-8
-9; INT 18
-10; Deities & Demigods lists this as 11
-12
-13
-14
-15
-16
-17; INT 25
<IntSpellsSuccess> = 35; INT 9
-45
-45
-45
-55
-55
-65
-65
-75
-85; INT 18
-95
-96
-97
-98
-99
-100
-100; INT 25
\(END)

\(BEGIN)
name = class_MageScribe
[CanScribeOrWhatever] = $SET_HOOK_PARAM(5,"SCRIBE");
-$SET_HOOK_PARAM(6,0);
[KnowableSpells] = $VAR char;
-$VAR mu;
-$VAR spLvl;
-$VAR spCls;
-char = $IndexOf($CharacterContext());
-mu = $GET_CHAR_Lvl(char, "magicUser");
-spLvl = $GET_HOOK_PARAM(6);
-spCls = $SA_SPELL_GET("spellClass");
-$IF (mu ># 18){mu = 18;};
-$IF (spCls != "magicUser"){$RETURN "0";};
-$IF (spLvl ># $IntegerTable("class_Spells","magicUserLvl",mu -# 1,"Index")){$RETURN "0";}
-$ELSE{$RETURN $IntegerTable("AbilityAdjustments","IntSpellsSuccess",$GET_HOOK_PARAM(5) -# 9,"Index");};
[KnowableSpellsMinMax] = $VAR par4;
-$VAR par5;
-$VAR par6;
-$VAR intMin;
-$VAR intMax;
-$VAR char;
-$VAR muLvl;
-par4 = $GET_HOOK_PARAM(4);
-par5 = $GET_HOOK_PARAM(5);
-par6 = $GET_HOOK_PARAM(6);
-intMin = $IntegerTable("AbilityAdjustments","IntSpellsMin",par5 -# 9,"Index");
-intMax = $IntegerTable("AbilityAdjustments","IntSpellsMax",par5 -# 9,"Index");
-char = $IndexOf($CharacterContext());
-muLvl = $GET_CHAR_Lvl(char, "magicUser");
-$IF (par4 == "I")
-	{
-		$IF (par6 !=# 1)
-			{
-				$SET_HOOK_PARAM(7, intMin);
-				$SET_HOOK_PARAM(8, intMax);
-				$SET_HOOK_PARAM(9, "2");
-				$RETURN "2";
-			}
-		$ELSE
-			{
-				$SET_HOOK_PARAM(7, intMin -# 2);
-				$SET_HOOK_PARAM(8, intMax -# 2);
-				$SET_HOOK_PARAM(9, "0");
-				$RETURN "1";
-			};
-	};
-$IF (par4 == "L")
-	{
-		$IF (muLvl ># 18){muLvl = 19;};
-		$IF (par6 !=# $IntegerTable("class_Spells","magicUserTrain",muLvl -# 1,"Index"))
-			{
-				$SET_HOOK_PARAM(7, 0);
-				$SET_HOOK_PARAM(8, 0);
-				$SET_HOOK_PARAM(9, "0");
-				$RETURN "0";
-			}
-		$ELSE
-			{
-				$SET_HOOK_PARAM(7, intMin);
-				$SET_HOOK_PARAM(8, intMax);
-				$SET_HOOK_PARAM(9, "2");
-				$RETURN "0";
-			};
-	};
[LearnSpellsNum] = $VAR char;
-$VAR muLvl;
-$VAR canKnow;
-$VAR lvl;
-$VAR spl;
-$VAR par4;
-$VAR par6;
-char = $IndexOf($CharacterContext());
-muLvl = $GET_CHAR_Lvl(char,"magicUser");
-canKnow = "#$2$0$0$0$0$0$0$0$0#$3$0$0$0$0$0$0$0$0#$3$2$0$0$0$0$0$0$0#$4$3$0$0$0$0$0$0$0#$4$3$2$0$0$0$0$0$0#$5$3$3$0$0$0$0$0$0#$5$4$3$2$0$0$0$0$0#$5$4$4$3$0$0$0$0$0#$5$5$4$3$2$0$0$0$0#$6$5$4$3$3$0$0$0$0#$6$6$5$4$4$0$0$0$0#$6$6$5$5$5$2$0$0$0#$7$6$6$5$5$3$0$0$0#$7$7$6$5$5$3$2$0$0#$7$7$6$6$6$4$2$0$0#$7$8$6$6$6$4$3$2$0#$7$8$6$6$6$4$4$3$0#7$8$6$6$6$4$4$3$2#$7$8$7$6$6$4$4$4$2#$7$8$7$6$6$5$4$4$3#$7$8$7$6$6$5$5$5$3#$7$8$7$6$6$6$5$5$4#$7$8$7$6$6$6$6$6$4#$7$8$7$6$6$6$6$6$5#$7$9$7$6$6$6$6$6$6#$8$9$8$7$6$6$6$6$6#$8$9$8$7$7$7$7$6$6#$8$9$8$7$7$7$7$7$7#$9$10$9$8$7$7$7$7$7#$9$10$9$8$8$8$8$7$7#$9$10$9$8$8$8$8$8$8#$10$11$10$9$8$8$8$8$8#$10$11$10$9$9$9$9$8$8#$11$12$11$10$9$9$9$9$9#$11$12$12$11$9$9$9$9$9#$11$12$12$11$10$10$10$9$9#$11$12$12$11$10$10$10$10$10#$12$13$12$11$10$10$10$10$10#$12$13$12$11$11$11$11$10$10#$12$13$12$11$11$11$11$11$11";
-lvl = $DelimitedStringSubstring(canKnow,muLvl -# 1);
-par4 = $GET_HOOK_PARAM(4);
-par6 = $GET_HOOK_PARAM(6);
-spl = $DelimitedStringSubstring(lvl,par6 -# 1);
-IF (par6 ==# 0) {$RETURN:};
-$IF (par4 == "I")
-	{
-		$SET_HOOK_PARAM(8,spl);
-		$SET_HOOK_PARAM(9,1);
-		$RETURN "1";
-	};
-$IF (par4 == "L")
-	{
-		$SET_HOOK_PARAM(8,spl);
-		$SET_HOOK_PARAM(9,1);
-		$RETURN "1";
-	};
[ScribeOrWhatever] = $SET_HOOK_PARAM(5, "Scribe");
\(END)

\(BEGIN)
name = class_NoSpells
[CanCastSpells] = $RETURN "N";
[CanMemorizeSpells] = $RETURN "N";
\(END)

\(BEGIN)
name = class_Paladin
[CanCureOrWhatever] = $VAR target;
-$VAR prevTime; //hours
-$VAR curTime;
-$VAR elapsedTime;
-$VAR waitTime;
-$VAR paladinLevel;
-$VAR paladinDiv; //divisor for equation
-target = $IndexOf($CharacterContext());
-prevTime = $SA_PARAM_GET();
-curTime = $GET_PARTY_DAYS() *# 24 +# $GET_PARTY_HOURS();
-$IF(prevTime)  // First time fudge.
-{elapsedTime = curTime -# prevTime;}
-$ELSE{elapsedTime = 999;};
-paladinLevel = $GET_CHAR_PALADINLVL(target);
-$IF(paladinLevel >#5){paladinDiv =#2;};
-paladinDiv = (paladinLevel +#4) /# 5;
-$IF (paladinDiv <# 1){paladinDiv = 1;};
-$IF (paladinDiv ># 8){paladinDiv = 8;};
-waitTime = 168 /# paladinDiv;
-$IF ((elapsedTime >= 0) && (elapsedTime <# waitTime)) {$RETURN;};
-$SET_HOOK_PARAM( 5, "CURE DISEASE" );
-$SET_HOOK_PARAM( 6, "0");
[CanLayOrWhatever] = $VAR prevTime;
-$VAR curTime;
-$VAR elapsedTime;
-prevTime = $SA_PARAM_GET();
-curTime = $GET_PARTY_TIME();
-$IF(prevTime)  // First time fudge.
-{elapsedTime = curTime -# prevTime;}
-$ELSE{elapsedTime = 999;};
-$IF ((elapsedTime >= 0) && (elapsedTime <# 24)) {$RETURN;};
-$SET_HOOK_PARAM( 5, "LAY ON HANDS" );
-$SET_HOOK_PARAM( 6, "0");
[CreateMonsterCombatant] = $SET_CHAR_CLASS($IndexOf($CharacterContext()),3);
-$SET_CHARACTER_SA($CharacterContext(),"IsPaladinImmuneDisease","paladin");
-$SET_CHARACTER_SA($CharacterContext(),"IsPaladinProtectedFromEvil","paladin");
[CureOrWhatever] = $VAR target;
-$VAR oldCHA;
-$VAR curTime;
-target = $IndexOf($CharacterContext());
-oldCHA = $SA_CHARACTER_GET("diseasedCHA");
-curTime = $GET_PARTY_DAYS() *# 24 +# $GET_PARTY_HOURS();
-$SA_PARAM_SET(curTime);
-$IF ($GET_CHARACTER_SA($CharacterContext(),"IsDiseased") != "-?-?-")
-	{
-		$DELETE_CHARACTER_SA($CharacterContext(),"IsDiseased");
-		$DELETE_CHARACTER_SA($CharacterContext(),"IsMummyDiseased");
-		$SET_CHAR_CHA(target,"oldCHA");
-		$DELETE_CHARACTER_SA($CharacterContext(),"diseasedCHA");
-	};
[LayOrWhatever] = $VAR curTime;
-$VAR target;
-curTime = $GET_PARTY_DAYS() *# 24 +# $GET_PARTY_HOURS();
-target = $IndexOf($CharacterContext());
-$SA_PARAM_SET(curTime);
-$IF ($GET_CHAR_HITPOINTS(target) <# $GET_CHAR_MAXHITPOINTS(target))
-	{
-		$SET_CHAR_HITPOINTS(target,$GET_CHAR_HITPOINTS(target) +# ($GET_CHAR_PALADINLVL(target) *# 2));
-	};
[PostCreateCharacter] = $SET_CHARACTER_SA($CharacterContext(),"IsPaladinImmuneDisease","paladin");
-$SET_CHARACTER_SA($CharacterContext(),"IsPaladinProtectedFromEvil","paladin");
\(END)

\(BEGIN)
name = class_Spells
<magicUserLvl> = 1; magic user level 1
-1; for use at character creation
-2
-2
-3
-3
-4
-4
-5
-5; magic user level 10
-5
-6
-6
-7
-7
-8
-8
-9; magic user level 18
magicUserTrain = 1; magic user level 1
-0; for use when magic user uses Training Hall
-2
-0
-3
-0
-4
-0
-5
-0; magic user level 10
-0
-6
-0
-7
-0
-8
-0
-9; magic user level 18
-0
\(END)

\(BEGIN)
name = class_Thief
[CharDisplayStatus] = $VAR me;
-me = $IndexOf($CharacterContext());
-$IF ($GET_HOOK_PARAM(5) == "DISPLAY")
-	{
-		$SET_HOOK_PARAM(7,"Pocket "+ $GET_CHAR_PICKPOCKETS(me)+ "\n" +"Lock "+ $GET_CHAR_OPENLOCKS(me)+ "\n" +"Trap "+ $GET_CHAR_FINDTRAPS(me)+ "\n" +"Move "+ $GET_CHAR_MOVESILENT(me)+ "\n" +"Hide "+ $GET_CHAR_HIDESHADOWS(me)+ "\n" +"Hear "+ $GET_CHAR_HEARNOISE(me)+ "\n" +"Climb "+ $GET_CHAR_CLIMBWALLS(me)+ "\n" +"Read "+ $GET_CHAR_READLANG(me));
-		$SET_HOOK_PARAM(6,"Thief");
-	}
-$ELSE
-	{
-		$SET_HOOK_PARAM(7,"");
-		$SET_HOOK_PARAM(6,"");
-	};
-$RETURN 1;
[PostCreateCharacter] = $SET_CHARACTER_SA($CharacterContext(),"class_ThiefSkills",1);
\(END)

\(BEGIN)
name = CombatPlacement
[PlaceMonsterClose] = $IF($GET_PARTY_FACING() >=#2)
-	{
-		$MonsterPlacement("FbPV500E");
-	}
-$ELSE{$MonsterPlacement("bPV500E");};
[PlaceMonsterFar] = $IF($GET_PARTY_FACING() >=#2)
-	{
-		$MonsterPlacement("17FbPV500E");
-	}
-$ELSE{$MonsterPlacement("16FbPV500E");};
[PlaceMonsterNear] = $IF($GET_PARTY_FACING() >=#2)
-	{
-		$MonsterPlacement("10FbPV500E");
-	}
-$ELSE{$MonsterPlacement("9FbPV500E");};
\(END)

\(BEGIN)
name = CombatRoundStart
[StartCombatRound] = $SA_PARAM_SET("0");
\(END)

\(BEGIN)
name = CombatRoundStart1
[StartCombatRound] = $SA_PARAM_SET("-?-?-");
\(END)

\(BEGIN)
name = Competing
[AdjustInitiative] = $VAR me;
-$VAR dex;
-$VAR p5;
-$VAR list;
-$VAR adj;
-$VAR redo;
-me = $IndexOf($CombatantContext());
-dex = $GET_CHAR_DEX(me);
-p5 = $GET_HOOK_PARAM(5);
-list = "$3$3$3$3$2$1$0$0$0$0$0$0$0$0$0$0$-1$-2$-3$-3$-3$-4$-4$-4$-5$-5";
-adj = $DelimitedStringSubstring(list,dex);
-$IF ($NOT($GetCombatRound()))//Past round 1
-	{$RETURN adj;};
-$IF (p5 != 18)// adjustment for unsurprised
-	{$RETURN adj;};
-$IF (adj <# "-1"||adj ==# "-1" && $GET_CHAR_RANGEREXP(me) ># 0)// negate surprise for -2 or better
-	{redo = 1;};
-$IF ($GET_CHAR_RANGEREXP(me) ># 0 || dex == 16)// 50% negate surprise for -1 or ranger
-	{redo = $RANDOM(2);};
-$IF (redo ==# 1)// set new random initiative if not surprised
-	{$RETURN $RANDOM(10) +# 9 +# adj -# 18;}
-$ELSE {$RETURN 5;}; // set to surprised
[AutoAction] = $RETURN $GET_COMBATANT_SA($CombatantContext(),"playerControl");
[CombatMainMenu] = $VAR adjCombatant;
-$VAR count;
-$VAR t;
-$VAR target;
-$VAR lvl;
-lvl = $GET_CHAR_Lvl($MyIndex(),"fighter") +# $GET_CHAR_Lvl($MyIndex(),"paladin") +# $GET_CHAR_Lvl($MyIndex(),"ranger") ;
-$IF (lvl ># 1)
-	{
-		adjCombatant = $ListAdjacentCombatants($MyIndex());
-		t = 0;
-		count = $DelimitedStringCount(adjCombatant);
-		$WHILE (count >=# 0)
-			{
-				target = $DelimitedStringSubstring(adjCombatant,count);
-				$IF ($GET_MONSTERTYPE_SA($GET_CHAR_NAME(target),"monster_Swept") != "-?-?-" && $GET_CHAR_STATUS(target) ==# 0){t = t +# 1;};
-				count = count -# 1;
-			};
-		$IF (t ># 1)
-			{
-				$SET_HOOK_PARAM(6, "SWEEP");
-				$SET_HOOK_PARAM(7, 0);
-				$SET_COMBATANT_SA($CombatantContext(),"IsSweeping",lvl);
-			};
-	};
[FreeAttack-AttackOver] = $VAR par5;
-par5 = $GET_HOOK_PARAM(5);
-$RETURN;
[FreeAttack-CanFreeAttack] = $VAR rangeWpn;
-rangeWpn = $GET_ITEM_SA($GET_CHAR_Ready($AttackerContext(), "WEAPON", 0),"item_CombatAim");
-$IF (rangeWpn != "-?-?-"){$RETURN "N";};
-$RETURN "Y";
[GetNumberOfAttacks] = $VAR com; // combatant
-$VAR fighterLvl;
-$VAR paladinLvl;
-$VAR rangerLvl;
-$VAR name;
-com = $IndexOf($CombatantContext());
-fighterLvl = $GET_CHAR_Lvl(com,"fighter");
-paladinLvl = $GET_CHAR_Lvl(com,"paladin");
-rangerLvl = $GET_CHAR_Lvl(com,"ranger");
-name = $GET_CHAR_NAME(com);
-$IF ($GET_MONSTERTYPE_SA(name,"monsterLevel") != "-?-?-"){$RETURN;};
-$IF ((fighterLvl >=# 13) || (paladinLvl >=# 13) || (rangerLvl >=# 15)){$RETURN 2;};
-$IF ((fighterLvl >=# 7) || (paladinLvl >=# 7) || (rangerLvl >=# 8)){$RETURN (($GetCombatRound() +# 1) %# 2) +# 1;};
[Guarding-AttackOver] = $RETURN;
[Guarding-BeginCombat] = $RETURN "N";
[Guarding-CanGuard] = $VAR rangeWpn;
-rangeWpn = $GET_ITEM_SA($GET_CHAR_Ready($CombatantContext(), "WEAPON",0),"item_CombatAim");
-$IF (rangeWpn != "-?-?-"){$RETURN "N";};
-$IF($GET_HOOK_PARAM(5) ==# 2){$RETURN "Y";};
[Guarding-CanGuardAttack] = $VAR par5;
-par5 = $GET_HOOK_PARAM(5);
-$IF ($GetCombatantState($AttackerContext()) != "ICS_Guarding"){$RETURN "N";};
-$IF (par5 ># 0){$RETURN "Y";};
[Guarding-Guard] = $RETURN;
[Guarding-StartOfRound] = $VAR par5;
-$VAR par6;
-par5 = $GET_HOOK_PARAM(5);
-par6 = $GET_HOOK_PARAM(6);
-$IF (par5 ==# 3){$SET_HOOK_PARAM(6,"G");};
[IsCombatReady] = $RETURN;
[OnStartCombat] = $VAR name;
-$VAR name1;
-$VAR me;
-$VAR lvl;
-$VAR controlNPC;
-$VAR index;
-$VAR modCha;
-$VAR random;
-$VAR i;
-me = $IndexOf($CharacterContext());
-name = $GET_CHAR_NAME(me);
-$RUN_CHAR_SCRIPTS(me,"spawn");
-i = $NextCreatureIndex("", 1);
-$WHILE (i != "")
-	{ // Check for Aura Effects
-		name1 = $GET_CHAR_NAME(i);
-		$IF (name != name1 && $GET_MONSTERTYPE_SA(name1,"range") != "-?-?-")
-			{
-				$SET_COMBATANT_SA($CharacterContext(),"range" + name1,1);
-			};
-		i = $NextCreatureIndex(i,1);
-	};
-index = $NextCreatureIndex("", 4);
-$WHILE (index != "") // Record Friendly Status
-	{
-		$IF (index == me) {$SET_COMBATANT_SA($CharacterContext()  ,"side",1);};
-		index = $NextCreatureIndex(index,4);
-	};
-$IF ($GET_COMBATANT_SA($CharacterContext()  ,"side") == "-?-?-")
-	{
-		$SET_COMBATANT_SA($CharacterContext()  ,"side",2);
-	};
-$IF ($GetCombatRound() ># 0) {$SET_COMBATANT_SA($CharacterContext()  , "Summoned", "spell");};
-$IF ($GET_PARTY_ASL("controlNPC") == "") // Paladin Leadership
-	{
-		controlNPC = 0;
-		index = $NextCreatureIndex("", 4);
-		$WHILE (index != "")
-			{
-				name = $GET_CHAR_NAME(index);
-				$IF ($InParty($Name(name)) == 1)
-					{
-						$SET_COMBATANT_SA($Name(name),"endControl", 1);
-						lvl = $GET_CHAR_Lvl(index,"paladin");
-						$IF (lvl ># 0)
-							{
-								modCha = ($GET_CHAR_CHA(index) -# 13) *# 5;
-								$IF (lvl >=# 3){controlNPC = modCha +# 79;};
-								$IF (lvl ==# 2){controlNPC = modCha +# 39;};
-								$IF (lvl ==# 1){controlNPC = modCha +# 19;};
-								$SET_PARTY_ASL("controlNPC",controlNPC);
-							};
-					};
-				index = $NextCreatureIndex(index,4);
-			};
-	};
-$IF ($GET_COMBATANT_SA($CharacterContext()  ,"side") == 1)
-	{
-		$IF ($RANDOM(100) <# $GET_PARTY_ASL("controlNPC"))
-			{
-				$SET_COMBATANT_SA($CharacterContext()  ,"playerControl","CP");
-			};
-	};
[OnStep] = $VAR creatureIndex;
-creatureIndex = $NextCreatureIndex("", 1);
-$WHILE (creatureIndex != "")
-	{
-		$IF (creatureIndex != $MyIndex())
-			{
-				$SET_HOOK_PARAM(6, $MyIndex());
-				$SET_HOOK_PARAM(5, creatureIndex);
-				$DebugWrite("OnStep " + $MyIndex() + " " + creatureIndex + "\n");
-				$RUN_CHAR_SCRIPTS(creatureIndex,"CheckProximity");
-				$SET_HOOK_PARAM(5, $MyIndex());
-				$SET_HOOK_PARAM(6, creatureIndex);
-				$RUN_CHAR_SCRIPTS($MyIndex(),"CheckProximity");
-			};
-		creatureIndex = $NextCreatureIndex(creatureIndex,1);
-	};
[StartCombatRound] = $RETURN;
\(END)

\(BEGIN)
name = DamageMagical
[DoesSpellAttackSucceed] = $VAR target;
-$VAR targetMR;
-$VAR caster;
-$VAR caster1;
-$VAR caster2;
-$VAR level;
-$VAR base;
-target = $IndexOf($TargetContext());
-targetMR = $GET_CHAR_MAGICRESIST(target);
-$IF (targetMR ==# 0) {$RETURN;};
-caster = $SA_SPELL_GET("Caster");
-caster1 = $DelimitedStringSubstring(caster,0);
-caster2 = $DelimitedStringSubstring(caster,1);
-$IF (caster1 == "monster")
-	{
-		level =  $GET_MONSTERTYPE_SA($GET_CHAR_NAME($IndexOf($AttackerContext())),"monsterLevel");
-		base = 11;
-	}
-$ELSE
-	{
-		$IF (caster1 == "item")
-			{
-				level = caster2;
-				base = 11;
-			}
-		$ELSE
-			{
-				level = $GET_CHAR_Lvl($IndexOf($AttackerContext()),caster1);
-				base = caster2;
-			};
-	};
-$IF ($RANDOM(100) <# targetMR -# 5 *# (level -# base))
-	{
-		$SET_HOOK_PARAM( 5, $GET_CHAR_NAME(target) +" is unaffected" );
-		$RETURN "N";
-	};
Parameters = "acid, charm, cold, electricity, fear, fire, mind, paralysis, petrification, poison, spell";
\(END)

\(BEGIN)
name = DamageNonMagical
Parameters = "blunt, crushing, piercing, poison, psionic, slashing, venom";
\(END)

\(BEGIN)
name = DisplayClimbWalls
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, $GET_CHAR_CLIMBWALLS( $IndexOf($CharacterContext()) + "% Climb Walls" ));
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = DisplayFindTraps
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$GET_CHAR_FINDTRAPS( $IndexOf($CharacterContext()) + "% Find Traps" ));
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = DisplayHearNoise
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$GET_CHAR_HEARNOISE( $IndexOf($CharacterContext()) + "% Hear Noise" ));
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = DisplayHideInShadows
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$GET_CHAR_HIDESHADOWS( $IndexOf($CharacterContext()) + "% Hide in Shadows" ));
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = DisplayMoveSilently
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$GET_CHAR_MOVESILENT( $IndexOf($CharacterContext()) + "% Move Silently" ));
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = DisplayOpenLocks
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$GET_CHAR_OPENLOCKS( $IndexOf($CharacterContext()) + "% Open Locks" ));
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = DisplayPickPockets
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$GET_CHAR_PICKPOCKETS( $IndexOf($CharacterContext()) + "% Pick Pockets" ));
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = DisplayReadLanguages
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$GET_CHAR_READLANG( $IndexOf($CharacterContext()) + "% Read Languages" ));
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = Global_Combat
[PartyArrangement] = $IF ($GET_HOOK_PARAM(5) == "I")
-  {
-    $RETURN "ABABBBbBABBBABBBBCCCbBABBBBCCCbBABBBACCCBCbBABBBCBACCCBCbBABBBCBACDCBCCCbAbAABcbbAABbAABcAbBcbbAABcAbBcbbAABdbbBcAcbbAABBCdbbBcAcbbAABBCdbACcAbBAAAAbABAAAbAAAbAbbcbBAAAbAbbcbBAAAbAAbcbbbCABAAAbAAbcbbbCABAAAbABbcbAbbbBBBBAACCBBAABBAACBBACCBBAACBBACCBBAADCBACBCCBBAAbbDCBACBCCBBAAbbDCAbCBBA";
-  }
-$ELSE
-  {
-    $RETURN "ABABBBbBABBBbBABBBCBcBbBABBBCBcBbbABBBCBDBdBcBbBABBBCBDBeBdBcBbBABBBCBDBbAbAABcbbAABcbbAABBCdccbbAABBCdccbbAABBCCDeddccbbAABBCCDeddccbbAABBCCDDEAAAAbABAAAbACABAAAbACABAAAbAbADACABAAAbAcADACABAAAbAcAdAEADACABAAAbAcAdABBBBAACCBBAACCBBAAbbDDCCBBAAbbDDCCBBAAbbccEEDDCCBBAAbbccEEDDCCBBAAbbccdd";
-  };
[PartyOriginEast] = $SET_HOOK_PARAM(5,"-1");
[PartyOriginNorth] = $SET_HOOK_PARAM(5,"-1");
[PartyOriginSouth] = $SET_HOOK_PARAM(5,"-1");
[PartyOriginWest] = $SET_HOOK_PARAM(5,"-1");
\(END)

\(BEGIN)
name = Global_CreateCharacter
[PostCreateCharacter] = $VAR char;
-char = $IndexOf($CharacterContext());
-$SET_CHARACTER_SA($CharacterContext(), "pcSTR", $GET_CHAR_STR(char));
-$SET_CHARACTER_SA($CharacterContext(), "pcSTRMOD", $GET_CHAR_STRMOD(char));
-$SET_CHARACTER_SA($CharacterContext(), "pcINT", $GET_CHAR_INT(char));
-$SET_CHARACTER_SA($CharacterContext(), "pcWIS", $GET_CHAR_WIS(char));
-$SET_CHARACTER_SA($CharacterContext(), "pcDEX", $GET_CHAR_DEX(char));
-$SET_CHARACTER_SA($CharacterContext(), "pcCON", $GET_CHAR_CON(char));
-$SET_CHARACTER_SA($CharacterContext(), "pcCHA", $GET_CHAR_CHA(char));
\(END)

\(BEGIN)
name = Global_CreateMonsterCombatant
[CreateMonsterCombatant] = $VAR tbl;
-$VAR levelTbl;
-$VAR i;
-$VAR monster;
-$VAR level;
-tbl = "/$17$3$4$5$4$6/$15$4$5$6$4$7/$13$5$6$7$5$8/$11$7$8$9$8$10/$9$8$9$10$9$11/$7$10$11$12$12$13/$5$11$12$13$13$14/$3$13$14$15$16$16/$1$14$15$16$17$17/$0$16$17$18$20$19";
-monster = $IndexOf($CharacterContext());
-level = $SA_MONSTERTYPE_GET("monsterLevel");
-// setting monster race
-$IF ($SA_MONSTERTYPE_GET("monster_Race") != "-?-?-")
-	{
-		$SET_CHAR_RACE(monster, $SA_PARAM_GET());
-	};
-// settinc monster class
-$IF ($SA_MONSTERTYPE_GET("monster_Class") != "-?-?-")
-	{
-		$SET_CHAR_CLASS(monster, $SA_PARAM_GET());
-	};
-//  Here we might examine the monstertype for a special ability named SpecialSaves.
-//  special = Get SA parameter "SpecialSaves" for monstertype;
-//  $IF (special != "-?-?-?") {tbl = special;};
-i = 0;
-$WHILE (1)
-	{
-		levelTbl = $DelimitedStringSubstring(tbl, i);
-		$IF (levelTbl == "") {$RETURN;}; // Protects us from bad Special SAves
-		$IF (level >=# $DelimitedStringSubstring(levelTbl, 0))
-			{
-				$SET_CHAR_SAVEVSPPDM(monster, $DelimitedStringSubstring(levelTbl, 1));
-				$SET_CHAR_SAVEVSPP(monster, $DelimitedStringSubstring(levelTbl, 2));
-				$SET_CHAR_SAVEVSRSW(monster, $DelimitedStringSubstring(levelTbl, 3));
-				$SET_CHAR_SAVEVSBR(monster, $DelimitedStringSubstring(levelTbl, 4));
-				$SET_CHAR_SAVEVSSP(monster, $DelimitedStringSubstring(levelTbl, 5));
-				$RETURN;
-			};
-		i = i +# 1;
-	};
\(END)

\(BEGIN)
name = Global_Transfer
[EachPartyMember] = $ForEachPossession($CharacterContext(), "item_DrowEquipment");
-$RETURN "1";
[TransferModule] = $ForEachPartyMember("Global_Transfer", "EachPartyMember");
-$IF ($GET_HOOK_PARAM(5) ==# "1")
-	{
-		$SET_HOOK_PARAM(6,"Your drow equipment dissolves.");
-	};
-$RETURN;
\(END)

\(BEGIN)
name = IsAfraid
[AutoAction] = $IF ($SA_COMBATANT_GET("monster_ImmuneFear") != "-?-?-") {$RETURN;}
-$ELSE{$RETURN "F" + $SA_PARAM_GET();};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Afraid");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = IsBarkskinned
[CharDisplayStatus] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-  {$RETURN $SA_REMOVE();};
-$SET_HOOK_PARAM( 7, "Barkskin");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $IF ($GET_CHARACTER_SA($TargetContext(),"IsBarkskin") == "-?-?-")
-	{$RETURN;};
-$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 1);
-$IF ($GET_HOOK_PARAM(5) <# $GET_HOOK_PARAM(6))
-	{$RETURN "N";};
[SaveVsBW_Save] = $RETURN $GET_HOOK_PARAM(0) -# 1;
[SaveVsPPDM_Save] = $RETURN $GET_HOOK_PARAM(0) -# 1;
[SaveVsPP_Save] = $RETURN $GET_HOOK_PARAM(0) -# 1;
[SaveVsRSW_Save] = $RETURN $GET_HOOK_PARAM(0) -# 1;
[SaveVsSp_Save] = $RETURN $GET_HOOK_PARAM(0) -# 1;
\(END)

\(BEGIN)
name = IsBestowedCurse
[CharDisplayStatus] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET()){$SA_REMOVE();};
-$SET_HOOK_PARAM( 7, "Curse Bestowed");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[DoesAttackSucceed] = $IF ($GET_CHARACTER_SA($AttackerContext(),"IsBestowedCurse") == "-?-?-"){$RETURN;};
-$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 4);
-$IF ($GET_HOOK_PARAM(5) <# $GET_HOOK_PARAM(6)){$RETURN "N";};
[SaveVsBW_Save] = $RETURN $GET_HOOK_PARAM(0) +# 4;
[SaveVsPPDM_Save] = $RETURN $GET_HOOK_PARAM(0) +# 4;
[SaveVsPP_Save] = $RETURN $GET_HOOK_PARAM(0) +# 4;
[SaveVsRSW_Save] = $RETURN $GET_HOOK_PARAM(0) +# 4;
[SaveVsSp_Save] = $RETURN $GET_HOOK_PARAM(0) +# 4;
\(END)

\(BEGIN)
name = IsBlessed
[CharDisplayStatus] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET()){$RETURN $SA_REMOVE();};
-$SET_HOOK_PARAM( 7,"Blessed");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $IF ($GET_COMBATANT_SA($AttackerContext(),"IsBlessed") == "-?-?-"){$RETURN;};
-$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) +# 1);
-$IF ($GET_HOOK_PARAM(5) >=# $GET_HOOK_PARAM(6)){$RETURN "Y";};
\(END)

\(BEGIN)
name = IsBlind
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Blind");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[DoesAttackSucceed] = $IF ($GET_COMBATANT_SA($TargetContext(),"IsBlind1") == "-?-?-"){$RETURN;};
-$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) +# 4);
-$IF ($GET_HOOK_PARAM(5) >=# $GET_HOOK_PARAM(6)){$RETURN "Y";};
[IsCombatReady] = $RETURN "N";
\(END)

\(BEGIN)
name = IsBlinking
[CanCastSpells] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-	{
-		$DELETE_COMBATANT_SA($CharacterContext(),"IsBlinking1");
-		$DELETE_COMBATANT_SA($CharacterContext(),"IsBlinking2");
-		$DELETE_CHARACTER_SA($CharacterContext(),"blinking");   
-		$SA_REMOVE();
-	};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Blinking ");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[spawn] = $SET_COMBATANT_SA($Myself(),"IsBlinking1",1);
\(END)

\(BEGIN)
name = IsBlinkingRing
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Blinking ");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = IsBlinking1
[OnStartCombatantAction] = $SET_COMBATANT_SA($CharacterContext(),"IsBlinking2",1);
[StartCombatRound] = $DELETE_COMBATANT_SA($CharacterContext(),"IsBlinking2");
\(END)

\(BEGIN)
name = IsBlinking2
[IsValidTarget] = $IF ($GET_MONSTERTYPE_SA($GET_CHAR_NAME($IndexOf($AttackerContext())),"monsterSeeEthereal") != "-?-?-"){$RETURN "Y";};
-$IF ($GET_CHARACTER_SA($AttackerContext(),"IsBlinking") != "-?-?-"){$RETURN "Y";};
-$IF ($GET_CHARACTER_SA($AttackerContext(),"IsBlinkingRing") != "-?-?-"){$RETURN "Y";};
-$RETURN "N";
\(END)

\(BEGIN)
name = IsCarrionStenchable
[CheckProximity] = $VAR me;
-$VAR it;
-me = $GET_HOOK_PARAM(5);
-it = $GET_HOOK_PARAM(6);
-$IF (me != $IndexOf($CombatantContext())){$RETURN;};
-$IF ($GET_CHAR_NAME(it) == "Ghast" && $VisualDistance(me,it) <# 2)
-	{
-		$SET_COMBATANT_SA($Myself(),"IsCarrionStenched",1);
-	};
[IsCombatReady] = $VAR list;
-$VAR count;
-$VAR i;
-list = $ListAdjacentCombatants($IndexOf($CharacterContext()));
-count = $DelimitedStringCount(list);
-$WHILE (count ># 0)
-	{
-		count = count -# 1;
-		i = $DelimitedStringSubstring(list,count);
-		$IF ($GET_CHAR_NAME(i) == "Ghast")
-			{
-				$RETURN $SET_COMBATANT_SA($CombatantContext(),"IsCarrionStenched",1);
-			};
-	};
\(END)

\(BEGIN)
name = IsCarrionStenched
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Retching");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[CheckProximity] = $VAR list;
-$VAR count;
-$VAR i;
-$VAR num;
-$IF ($GET_HOOK_PARAM(5) != $IndexOf($CombatantContext())){$RETURN;};
-list = $ListAdjacentCombatants($IndexOf($CombatantContext()));
-count = $DelimitedStringCount(list);
-$WHILE (count ># 0)
-	{
-		count = count -# 1;
-		i = $DelimitedStringSubstring(list,count);
-		$IF ($GET_CHAR_NAME(i) == "Ghast"){num = num +# 1;};
-	};
-$IF (num == ""){$SA_REMOVE();};
[DoesAttackSucceed] = $IF ($GET_COMBATANT_SA($AttackerContext(),"IsCarrionStenched") == "-?-?-"){$RETURN;};
-$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 2);
-$IF ($GET_HOOK_PARAM(5) <# $GET_HOOK_PARAM(6)){$RETURN "N";};
[IsCombatReady] = $VAR list;
-$VAR count;
-$VAR i;
-list = $ListAdjacentCombatants($IndexOf($CharacterContext()));
-count = $DelimitedStringCount(list);
-$WHILE (count ># 0)
-	{
-		count = count -# 1;
-		i = $DelimitedStringSubstring(list,count);
-		$IF ($GET_CHAR_NAME(i) == "Ghast")
-			{
-				$RETURN $SET_COMBATANT_SA($CombatantContext(),"IsCarrionStenched",1);
-			};
-	};
\(END)

\(BEGIN)
name = IsCharmed
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Charmed ");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $VAR clev; // Cast level
-$VAR dlev; // Dispel level
-$VAR cls;  // Class
-$VAR pct;  // Percent
-clev = $SA_PARAM_GET();
-cls  = $SA_SPELL_GET("spell_Dispel");
-dlev = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF ($GET_CHARACTER_SA($TargetContext(),"z-IsGlobedMinor") != "-?-?-" && cls != "druid")
-	{$RETURN;};
-$IF ($GET_CHARACTER_SA($TargetContext(),"z-IsGlobed") != "-?-?-")
-	{$RETURN;};
-$IF (cls == "paladin"){dlev = dlev -#8;};
-$IF (clev ># dlev) {pct = 50 -# ((clev -# dlev) *# 2);}
-$ELSE {pct = 50 +# ((dlev -# clev) *# 5);};
-$IF ($RANDOM(100) +# 1 <=# pct)
-	{
-		$SetFriendly($IndexOf($TargetContext()),$GET_COMBATANT_SA($TargetContext(),"side"));
-		$SA_REMOVE();
-	};
\(END)

\(BEGIN)
name = IsCharmResistant
\(END)

\(BEGIN)
name = IsCharmResistantMin
\(END)

\(BEGIN)
name = IsCloakDisplaced
[DoesAttackSucceed] = $IF ($GET_CHARACTER_SA($TargetContext(),"IsCloakDisplaced") != "-?-?-" && $GET_COMBATANT_SA($TargetContext(),"displaceMiss") == "-?-?-")
-	{
-		$SET_COMBATANT_SA($TargetContext(),"displaceMiss",1);
-		$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 90);
-		$RETURN "N";
-	};
[SaveVsBW_Save] = $RETURN $GET_HOOK_PARAM(0) -# 2;
[SaveVsRSW_Save] = $RETURN $GET_HOOK_PARAM(0) -# 2;
[SaveVsPP_Save] = $RETURN $GET_HOOK_PARAM(0) -# 2;
[SaveVsPPDM_Save] = $RETURN $GET_HOOK_PARAM(0) -# 2;
[SaveVsSp_Save] = $RETURN $GET_HOOK_PARAM(0) -# 2;
\(END)

\(BEGIN)
name = IsConfused
[CanCastSpells] = $RETURN "N";
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Confused");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[GetAdjMaxMovement] = $RETURN "0";
[IsCombatReady] = $RETURN "N";
\(END)

\(BEGIN)
name = IsConfusedExtended
[Dispel] = $SA_REMOVE();
[StartCombatRound] = $VAR save;
-$VAR rnd;
-$VAR opr; // once per round
-opr = $GET_COMBATANT_SA($CombatantContext(),"oncePerRnd");
-$IF (opr ==# 0)
-  {
-    $DELETE_COMBATANT_SA($CharacterContext(),"IsConfused");
-    save = ($GET_CHAR_SAVEVSSP($IndexOf($CombatantContext())));
-    rnd = $RANDOM(20) -# 1;
-    $IF (save <# rnd){$DELETE_COMBATANT_SA($CharacterContext(),"ConfusionSA");$RETURN;};
-    rnd = $RANDOM(10) +# 1;
-    $IF (rnd ==# 1){$SetFriendly($IndexOf($CombatantContext()),1);$RETURN;};
-    $IF (rnd <=# 6){$SET_COMBATANT_SA($CombatantContext(),"IsConfused","Confused");$RETURN;};
-    $IF (rnd ==# 7){$SetFriendly($IndexOf($CombatantContext()),1);$RETURN;};
-    $IF (rnd ==# 8){$SetFriendly($IndexOf($CombatantContext()),2);$RETURN;};
-    $SetFriendly($IndexOf($CombatantContext()),2);
-    $RETURN;
-  };
\(END)

\(BEGIN)
name = IsCursed
[CharDisplayStatus] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET()){$RETURN $SA_REMOVE();};
-$SET_HOOK_PARAM( 7, "Cursed");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[DoesAttackSucceed] = $IF ($GET_COMBATANT_SA($AttackerContext(),"IsCursed") == "-?-?-"){$RETURN;};
-$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 1);
-$IF ($GET_HOOK_PARAM(5) <# $GET_HOOK_PARAM(6)){$RETURN "N";};
\(END)

\(BEGIN)
name = IsDetectedEvil
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, $SA_PARAM_GET() );
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = IsDetectingMagic
[CanCastSpells] = $VAR expiration;
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() ># expiration){$SA_REMOVE();};
[CanSpellDetectMagic] = $VAR expiration;
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() ># expiration){$SA_REMOVE();};
-$RETURN "Y";
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Detecting Magic");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
\(END)

\(BEGIN)
name = IsDiseased
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[ComputeDamage] = $VAR target;
-$VAR spell;
-$VAR spellCount;
-target = $IndexOf($CharacterContext());
-spell = "$Cure Light Wounds$Cure Serious Wounds$Cure Critical Wounds$Cure Light Wounds|Druid$Cure Serious Wounds|Druid$Cure Critical Wounds|Druid";
-spellCount = $DelimitedStringCount(spell);
-$SET_CHARACTER_SA($CharacterContext(),"diseasedCHA",$GET_CHAR_CHA(target));
-$SET_CHAR_CHA(target,$GET_CHAR_CHA(target) -# 2);
-$IF ($SpellContext() == $DelimitedStringSubstring(spell,spellCount))
-  {$RETURN 0;};
-$IF ($SpellContext() == "Cure Disease")
-  {
-    $DELETE_CHARACTER_SA($CharacterContext(), "IsDiseased");
-    $SET_CHAR_CHA(target,$SA_CHARACTER_GET("diseasedCHA"));
-    $DELETE_CHARACTER_SA($CharacterContext(), "diseasedCHA");
-  };
\(END)

\(BEGIN)
name = IsDiseasedSpell
[CanCastSpells] = $VAR chr;
-$VAR t10;
-$VAR t60;
-$VAR str;
-chr = $IndexOf($CharacterContext());
-$IF ($GET_CHARACTER_SA($CharacterContext(),"IDSTimer10") == "-?-?-")
-	{
-		$SET_CHARACTER_SA($CharacterContext(),"IDSTimer10",$GET_PARTY_TIME() +# 10);
-		$SET_CHARACTER_SA($CharacterContext(),"IDSTimer60",$GET_PARTY_TIME() +# 60);
-	};
-t10 = $GET_CHARACTER_SA($CharacterContext(),"IDSTimer10");
-t60 = $GET_CHARACTER_SA($CharacterContext(),"IDSTimer60");
-$IF ($GET_CHAR_HITPOINTS(chr) ># $GET_CHARACTER_SA($CharacterContext(),"minhp"))
-	{
-		$IF ($GET_PARTY_TIME() ># t10)
-			{
-				$SET_CHARACTER_SA($CharacterContext(),"IDSTimer10",$GET_PARTY_TIME() +# 10);
-				$SET_CHAR_HITPOINTS(chr,$GET_CHAR_HITPOINTS(chr) -# 1);
-			};
-	};
-str = $GET_CHAR_STR(chr);
-$IF (str ># 3)
-	{
-		$IF ($GET_PARTY_TIME() ># t60)
-			{
-				$SET_CHARACTER_SA($CharacterContext(),"IDSTimer60",$GET_PARTY_TIME() +# 60);
-				$SET_CHAR_STR(chr,str -# 1);
-				$IF (str <# 4) {$SET_CHAR_MAXMOVE(chr,2);};
-			};
-	};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Diseased ");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[IsCombatReady] = $IF ($GET_CHAR_STR($IndexOf($CharacterContext())) <# 4)
-	{$RETURN "N";};
\(END)

\(BEGIN)
name = IsDispellingEvil
[CharDisplayStatus] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-  {$RETURN $SA_REMOVE();};
-$SET_HOOK_PARAM( 7, "Dispelling Evil");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $IF ($GET_CHARACTER_SA($TargetContext(),"IsDispellingEvil") != "-?-?-")
-	{
-		$IF ($AlignmentGood($AttackerContext()) == "" && $GET_COMBATANT_SA($AttackerContext(),"Summoned") != "-?-?-")
-			{
-				$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 7);
-				$IF ($GET_HOOK_PARAM(5) <# $GET_HOOK_PARAM(6)){$RETURN "N";};
-			};
-	}
-$ELSE
-	{
-		$IF ($AlignmentGood($TargetContext()) == "" && $GET_COMBATANT_SA($TargetContext(),"Summoned") != "-?-?-" && $GET_HOOK_PARAM(6) <# $GET_HOOK_PARAM(5) && $GET_CHARACTER_SA($AttackerContext(),"CanDispel") != "-?-?-")
-			{
-				$CastSpellOnTargetAs($TargetContext(),"Banish",$AttackerContext());
-				$DELETE_CHARACTER_SA($AttackerContext(),"CanDispel");
-			};
-	};
\(END)

\(BEGIN)
name = IsDispellingGood
[CharDisplayStatus] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-  {$RETURN $SA_REMOVE();};
-$SET_HOOK_PARAM( 7, "Dispelling Good");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $IF ($GET_CHARACTER_SA($TargetContext(),"IsDispellingGood") != "-?-?-")
-	{
-		$IF ($AlignmentGood($AttackerContext()) == "" && $GET_COMBATANT_SA($AttackerContext(),"Summoned") != "-?-?-")
-			{
-				$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 7);
-				$IF ($GET_HOOK_PARAM(5) <# $GET_HOOK_PARAM(6)){$RETURN "N";};
-			};
-	}
-$ELSE
-	{
-		$IF ($AlignmentGood($TargetContext()) == "" && $GET_COMBATANT_SA($TargetContext(),"Summoned") != "-?-?-" && $GET_HOOK_PARAM(6) <# $GET_HOOK_PARAM(5) && $GET_CHARACTER_SA($AttackerContext(),"CanDispel") != "-?-?-")
-			{
-				$CastSpellOnTargetAs($TargetContext(),"Banish",$AttackerContext());
-				$DELETE_CHARACTER_SA($AttackerContext(),"CanDispel");
-			};
-	};
\(END)

\(BEGIN)
name = IsDragonFear
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
DrawMoveMenu = $SET_HOOK_PARAM(1,0);
[GetAdjMaxMovement] = $RETURN 0;
[IsCombatReady] = $RETURN "N";
[OnStartCombatantAction] = $RETURN "F";
\(END)

\(BEGIN)
name = IsDragonFlee
[AutoAction] = $RETURN "F" + $SA_PARAM_GET();
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = IsDrained
[TrainingCharacter] = $SA_REMOVE();
\(END)

\(BEGIN)
name = IsDrainedStrength
[CanCastSpells] = $VAR me;
-$IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-	{
-		me = $IndexOf($CharacterContext());
-		$SET_CHAR_STR(me,$GET_CHARACTER_SA($CharacterContext(),"pcSTR"));
-		$SET_CHAR_STRMOD(me,$GET_CHARACTER_SA($CharacterContext(),"pcSTRMOD"));
-		$SA_REMOVE();
-	};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Weakened");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
\(END)

\(BEGIN)
name = IsEnlarged
[CanCastSpells] = $VAR me;
-me = $IndexOf($CharacterContext());
-$IF ($GET_PARTY_TIME() ># $GET_CHARACTER_SA($CharacterContext(),"enlarged"))
-	{
-		$DELETE_CHARACTER_SA($CharacterContext(),"enlarged");
-		$SET_CHAR_STR(me,$GET_CHARACTER_SA($CharacterContext(),"myStr"));
-		$SET_CHAR_STRMOD(me,$GET_CHARACTER_SA($CharacterContext(),"myStrMod"));
-		$SET_CHAR_SIZE(me,$GET_CHARACTER_SA($CharacterContext(),"mySize"));
-		$RUN_CHAR_SE_SCRIPTS($CharacterContext(),"Dispel SE");
-		$SA_REMOVE();
-	};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Enlarged");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
\(END)

\(BEGIN)
name = IsEntangled0
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Entangled by Vines");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[ComputeDamage] = $RETURN $GET_CHAR_HITPOINTS($IndexOf($TargetContext())) +# 1;
[Dispel] = $SA_REMOVE();
[GetAdjMaxMovement] = $RETURN "0";
[IsCombatReady] = $VAR duration;
-duration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() >=# duration)
-	{
-		$SA_REMOVE();
-		$RETURN "Y";
-	}
-$ELSE {$RETURN "N";};
\(END)

\(BEGIN)
name = IsEntangled1
[CharDisplayStatus] = $RUN_AREA_SE_SCRIPTS("Entangled1", $IndexOf($CharacterContext()));
-$SET_HOOK_PARAM( 7, $GET_HOOK_PARAM(8));
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[GetAdjMaxMovement] = $SET_HOOK_PARAM(6, $GET_HOOK_PARAM(5));
-$RUN_AREA_SE_SCRIPTS("MovementAdjustments", $IndexOf($CharacterContext()));
-$RETURN $GET_HOOK_PARAM(5);
\(END)

\(BEGIN)
name = IsFast
[AdjustInitiative] = $RETURN -2;
[CharDisplayStatus] = $VAR expiration;
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() >=# expiration){$SA_REMOVE();};
-$SET_HOOK_PARAM( 7,"Hasted");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[GetAdjMaxMovement] = $RETURN $GET_HOOK_PARAM(5) *# 2;
[GetNumberOfAttacks] = $RETURN 2;
\(END)

\(BEGIN)
name = IsFastBoots
[GetAdjMaxMovement] = $RETURN $GET_HOOK_PARAM(5) *# 2;
\(END)

\(BEGIN)
name = IsFeebleminded
[CanCastSpells] = $RETURN "N";
[CanKnowSpell] = $RETURN "N";
[CanMemorizeSpells] = $RETURN "N";
[IsCombatReady] = $RETURN "N";
\(END)

\(BEGIN)
name = IsFleeing
[AutoAction] = $RETURN "F" + $IndexOf($LEAST_DAMAGED_FRIENDLY());
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = IsFumbling
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $VAR saveSpell;
-$VAR roll;
-$VAR expiration;
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() >=# expiration){$SA_REMOVE();};
-saveSpell = $GET_CHAR_SAVEVSSP($IndexOf($TargetContext()));
-roll = $RANDOM(20) +# 1;
-$IF (saveSpell <# roll)
-  {
-    $SET_COMBATANT_SA($TargetContext(),"IsSlow","1");
-    $SA_PARAM_SET("saved");
-  };
[GetAdjMaxMovement] = $IF ($SA_PARAM_GET() != "saved"){$RETURN "0";};
\(END)

\(BEGIN)
name = IsHeld
[CharDisplayStatus] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET()){$RETURN $SA_REMOVE();};
-$SET_HOOK_PARAM( 7,"Held ");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[DoesAttackSucceed] = $IF ($GET_COMBATANT_SA($TargetContext(),"IsHeld") != "-?-?-"){$RETURN;};
-$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) +# 30);
-$IF ($GET_HOOK_PARAM(5) >=# $GET_HOOK_PARAM(6)){$RETURN "Y";};
[GetItemTargetHitBonus] = $RETURN $GET_CHAR_HITPOINTS($IndexOf($TargetContext())) +# 15;
[IsCombatReady] = $RETURN "N";
\(END)

\(BEGIN)
name = IsHelpless
[CanCastSpells] = $RETURN "N";
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[GetAdjMaxMovement] = $RETURN "0";
\(END)

\(BEGIN)
name = IsHugged
[CanCastSpells] = $IF ($GET_CHAR_HITPOINTS($IndexOf($CombatantContext())) <# 1) 
-	{
-		$SA_REMOVE();
-		$RETURN;
-	};
-$RETURN "N";
[GetAdjMaxMovement] = $RETURN 0;
\(END)

\(BEGIN)
name = IsImmuneDB
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $VAR immuneAll;
-immuneAll = $GET_ITEM_SA($ItemContext(),"DragonBreathWeapon");
-$IF (immuneAll != "-?-?-"){$RETURN "N";};
\(END)

\(BEGIN)
name = IsImmuneDisease
[CharDisplayStatus] = $SET_HOOK_PARAM(7,"Immune to Disease");
-$SET_HOOK_PARAM(6,"");
-$RETURN 1;
[DoesSpellAttackSucceed] = $IF ($SA_SPELL_GET("DamageMagical") == "disease" || $SA_SPELL_GET("DamageNonMagical") == "disease"){$RETURN "N";};
\(END)

\(BEGIN)
name = IsImmuneNormalMissiles
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $VAR itemNormal;
-$VAR itemMissile;
-$VAR expiration;
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() >=# expiration){$SA_REMOVE();};
-itemNormal = $SA_ITEM_GET("item_MagicalWeapon");
-itemMissile = $SA_ITEM_GET("item_MissileWeapon");
-$IF ((itemNormal == "-?-?-") && (itemMissile != "-?-?-")){$RETURN "N";};
\(END)

\(BEGIN)
name = IsImmunePoison
[DoesSpellAttackSucceed] = $IF ($SA_SPELL_GET("DamageMagical") == "poison" || $SA_SPELL_GET("DamageNonMagical") == "poison"){$RETURN "N";};
\(END)

\(BEGIN)
name = IsImmuneSpells
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $VAR spellAll;
-$VAR expiration;
-spellAll = $GET_SPELL_Level($SpellContext());
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() >=# expiration){$SA_REMOVE();};
-$IF (spellAll <#5){$RETURN "N";};
\(END)

\(BEGIN)
name = IsImmuneSpellsMinor
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $VAR spellMinor;
-$VAR expiration;
-spellMinor = $GET_SPELL_Level($SpellContext());
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() >=# expiration){$SA_REMOVE();};
-$IF (spellMinor <#4){$RETURN "N";};
\(END)

\(BEGIN)
name = IsInsectFlee
[AutoAction] = $RETURN "F" + $SA_PARAM_GET();
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Fleeing insects");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = IsInvisible
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $IF ($IndexOf($Myself()) == $IndexOf($AttackerContext()))
-	{
-		$DELETE_CHARACTER_SA($Myself(),"IsInvisibleSpell");
-		$DELETE_COMBATANT_SA($Myself(),"IsInvisible");
-	};
[IsValidTarget] = $IF ($SA_COMBATANT_GET("IsSeeingInvisible") != "-?-?-"){$RETURN "Y";};
-$IF ($GET_CHARACTER_SA($TargetContext(),"IsFaerieFire") != "-?-?-"){$RETURN;}
-$ELSE {$RETURN "N";};
\(END)

\(BEGIN)
name = IsInvisiblePotioin
[Dispel] = $SA_REMOVE();
[IsCombatReady] = $SET_COMBATANT_SA($Myself(),"IsInvisible",1);
\(END)

\(BEGIN)
name = IsInvisibleRing
[OnStartCombatantAction] = $SET_COMBATANT_SA($Myself(),"IsInvisible",1);
\(END)

\(BEGIN)
name = IsInvisibleSpell
[CharDisplayStatus] = $IF ($GET_HOOK_PARAM(5) == "DISPLAY")
-	{
-		$SET_HOOK_PARAM(7,"Invisible, spell");
-		$SET_HOOK_PARAM(6,2);
-	}
-$ELSE
-	{
-		$SET_HOOK_PARAM(7,"Invisible");
-		$SET_HOOK_PARAM(6,"");
-	};
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[IsCombatReady] = $SET_COMBATANT_SA($Myself(),"IsInvisible",1);
\(END)

\(BEGIN)
name = IsInvisibleStalker
[IsValidTarget] = $IF ($SA_COMBATANT_GET("IsSeeingInvisible") != "-?-?-"){$RETURN "Y";};
-$IF ($GET_CHARACTER_SA($TargetContext(),"IsFaerieFire") != "-?-?-"){$RETURN;}
-$ELSE {$RETURN "N";};
\(END)

\(BEGIN)
name = IsInvisibleToAnimals
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Invisible to Animals");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[IsValidTarget] = $IF ($GET_ISANIMAL($AttackerContext()) <# 0){$RETURN "Y";};
-$IF ($SA_COMBATANT_GET("IsSeeingInvisible") != "-?-?-") {$RETURN "Y";}
-$ELSE {$RETURN "N";};
\(END)

\(BEGIN)
name = IsMirrored
[CanCastSpells] = $IF ($IS_AFFECTED_BY_SPELL($CharacterContext(),"Mirror Image") == "")
-  {$SA_REMOVE();};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET() + " mirror images");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $VAR remain;
-$VAR roll;
-$VAR thac0;
-$VAR AC;
-$IF ($GET_CHARACTER_SA($TargetContext(),"IsMirrored") == "-?-?-"){$RETURN;}; // "Target Is Mirrored" filter
-remain = $SA_PARAM_GET();
-$IF ($RANDOM(remain +# 1) ==# 0){$RETURN;}; // Targeting caster, not image
-thac0 = $GET_CHAR_THAC0($IndexOf($AttackerContext()));
-AC = $GET_CHAR_AC($IndexOf($TargetContext()));
-roll = $GET_HOOK_PARAM(5);
-$IF (roll >=# (thac0 -# AC))
-	{
-		$SA_PARAM_SET(remain -# 1);
-		$IF ($GET_CHARACTER_SA($TargetContext(),"IsMirrored") <# 1)
-		{$SA_REMOVE();}; // Images depleted
-	};
-// Image targeted - Attack fails
-$RETURN "N";
\(END)

\(BEGIN)
name = IsMummyDiseased
[CanCastSpells] = $VAR me;
-me = $IndexOf($CharacterContext());
-$IF ($GET_PARTY_DAYS() >=# $SA_PARAM_GET())
-	{
-		$SA_PARAM_SET($GET_PARTY_DAYS() +# 30);
-		$SET_CHAR_CHA(me,$GET_CHAR_CHA(me) -# 2);
-		$SET_CHARACTER_SA($CharacterContext(),"pcCHA",$GET_CHAR_CHA(me));
-		$SET_CHARACTER_SA($CharacterContext(),"rot",$GET_CHARACTER_SA($CharacterContext(),"rot") +# 17);
-		$IF ($RANDOM(100) <= $GET_CHARACTER_SA($CharacterContext(),"rot"))
-			{
-				$SET_CHAR_HITPOINTS(me,0);
-				$SET_CHAR_STATUS(me,5);
-			};
-		$IF ($GET_CHAR_CHA(me) <# 6)
-			{
-				$SET_CHAR_STATUS(me,5);
-			};
-	};
-$IF ($GET_CHAR_STATUS(me) ==# 2 && $GET_CHARACTER_SA($CharacterContext(),"IsMummyRotting") == "-?-?-")
-	{
-		$SET_CHARACTER_SA($CharacterContext(),"IsMummyRotting",$GET_PARTY_TIME() +# 60);
-	};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Has Mummy Rot");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[DoesSpellAttackSucceed] = $VAR dm;
-dm = $SA_SPELL_GET("DamageMagical");
-$IF (dm == "heal" || dm == "cureDis")
-	{$RETURN $SA_REMOVE();};
-$IF (dm == "cureW" || dm == "raise")
-	{$RETURN "N";};
\(END)

\(BEGIN)
name = IsMummyFear
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
DrawMoveMenu = $SET_HOOK_PARAM(1,0);
[GetAdjMaxMovement] = $RETURN 0;
[IsCombatReady] = $RETURN "N";
[OnStartCombatantAction] = $RETURN "F";
\(END)

\(BEGIN)
name = IsMummyFlee
[AutoAction] = $RETURN "F" + $SA_PARAM_GET();
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Fleeing Mummy");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = IsMummyRotting
[CanCastSpells] = $VAR me;
-me = $IndexOf($CharacterContext());
-$IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-	{
-		$DELETE_CHARACTER_SA($CharacterContext(),"IsMummyDiseased");
-		$SA_REMOVE();
-		$SET_CHAR_HITPOINTS(me,0);
-		$SET_CHAR_STATUS(me,5);
-	};
[DoesSpellAttackSucceed] = $IF ($GET_CHARACTER_SA($TargetContext(),"IsMummyDiseased") == "-?-?-" && $SA_SPELL_GET("DamageMagical") == "raise")
-	{
-		$SA_REMOVE();
-		$RETURN "Y";
-	};
\(END)

\(BEGIN)
name = IsPaladinImmuneDisease
[CharDisplayStatus] = $SET_HOOK_PARAM(7,"Immune to Disease");
-$SET_HOOK_PARAM(6,"");
-$RETURN 1;
[DoesSpellAttackSucceed] = $IF ($SA_SPELL_GET("DamageMagical") == "disease" || $SA_SPELL_GET("DamageNonMagical") == "disease"){$RETURN "N";};
\(END)

\(BEGIN)
name = IsPaladinProtectedFromEvil
[CharDisplayStatus] = $SET_HOOK_PARAM(7,"Protected From Evil");
-$SET_HOOK_PARAM(6,"");
-$RETURN 1;
[DoesAttackSucceed] = $IF ($GET_CHARACTER_SA($TargetContext(),"IsPaladinProtectedFromEvil") == "-?-?-"){$RETURN;}; // Directional Filter
-$IF ($GET_COMBATANT_SA($AttackerContext(),"Summoned") != "-?-?-")
-	{
-		$SET_HOOK_PARAM(5,-90);
-		$RETURN "N";
-	};
-$IF ($AlignmentEvil($AttackerContext()))
-	{
-		$SET_HOOK_PARAM(5, $GET_HOOK_PARAM(5) -# 2);
-		$IF ($GET_HOOK_PARAM(5) <# $GET_HOOK_PARAM(6)){$RETURN "N";};
-	};
[SaveVsBW_Save] = $IF ($AlignmentEvil($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
[SaveVsPPDM_Save] = $IF ($AlignmentEvil($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
[SaveVsPP_Save] = $IF ($AlignmentEvil($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
[SaveVsRSW_Save] = $IF ($AlignmentEvil($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
[SaveVsSp_Save] = $IF ($AlignmentEvil($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
\(END)

\(BEGIN)
name = IsParalyzed
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[DoesAttackSucceed] = $IF ($GET_COMBATANT_SA($TargetContext(),"IsParalyzed") != "-?-?-"){$RETURN;};
-$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) +# 30);
-$IF ($GET_HOOK_PARAM(5) >=# $GET_HOOK_PARAM(6)){$RETURN "Y";};
[GetItemTargetHitBonus] = $RETURN $GET_CHAR_HITPOINTS($IndexOf($TargetContext())) +# 15;
[IsCombatReady] = $RETURN "N";
\(END)

\(BEGIN)
name = IsPerson
Parameters = "brownies, dryads, dwarves, elves, gnolls, gnomes, goblins, half-elves, halflings, half-orcs, hobgoblins, humans, kobolds, lizard men, nixies, orcs, pixies, sprites, troglodytes";
\(END)

\(BEGIN)
name = IsPetrified
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[IsCombatReady] = $RETURN "N";
\(END)

\(BEGIN)
name = IsPlant
\(END)

\(BEGIN)
name = IsPoisoned
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Poisoned");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
\(END)

\(BEGIN)
name = IsPraying
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Praying");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
\(END)

\(BEGIN)
name = IsProtectedAcidCaster
[CanCastSpells] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-	{
-		$DELETE_CHARACTER_SA($CharacterContext(),"AcidPoints");
-		$DELETE_COMBATANT_SA($CharacterContext(),"IsProtectedAcidCaster1");
-		$RETURN $SA_REMOVE();
-	};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Protected from Acid");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[DoesSpellAttackSucceed] = $IF ($SA_SPELL_GET("DamageNonMagical") == "acid")
-	{
-		$SET_HOOK_PARAM(5,$GET_CHAR_NAME($IndexOf($TargetContext())) +" is unaffected.");
-		$RETURN "N";
-	};
[spawn] = $SET_COMBATANT_SA($Myself(),"IsProtectedAcidCaster1",1);
\(END)

\(BEGIN)
name = IsProtectedAcidCaster1
[ComputeSpellDamage] = $VAR points;
-$VAR adj;
-$IF ($SA_SPELL_GET("DamageMagical") == "acid")
-	{
-		adj = $GET_HOOK_PARAM(0);
-		$IF (adj == "") {adj = $GET_HOOK_PARAM(5);};
-		points = $GET_CHARACTER_SA($TargetContext(),"AcidPoints");
-		$IF (0 -# points <# adj)
-			{
-				$SET_CHARACTER_SA($TargetContext(),"AcidPoints",points +# adj);
-				$SET_HOOK_PARAM(5,0);
-			}
-		$ELSE
-			{
-				$DELETE_CHARACTER_SA($TargetContext(),"AcidPoints");
-				$DELETE_CHARACTER_SA($TargetContext(),"IsProtectedAcidCaster");
-				$SA_REMOVE();
-				$SET_HOOK_PARAM(5,(adj +# points));
-			};
-	};
-$RETURN $GET_HOOK_PARAM(5);
\(END)

\(BEGIN)
name = IsProtectedAcidTarget
[CanCastSpells] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-	{
-		$DELETE_COMBATANT_SA($CharacterContext(),"IsProtectedAcidTarget1");
-		$SA_REMOVE();
-	};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Protected from Acid");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[DoesSpellAttackSucceed] = $IF ($SA_SPELL_GET("DamageNonMagical") == "acid")
-	{
-		$SET_HOOK_PARAM(5,$GET_CHAR_NAME($IndexOf($TargetContext())) +" is unaffected.");
-		$RETURN "N";
-	};
[SaveVsBW_Save] = $IF ($SA_SPELL_GET("DamageMagical") == "acid")
-	{$RETURN $GET_HOOK_PARAM(0) -# 4;};
[SaveVsRSW_Save] = $IF ($SA_SPELL_GET("DamageMagical") == "acid")
-	{$RETURN $GET_HOOK_PARAM(0) -# 4;};
[SaveVsSp_Save] = $IF ($SA_SPELL_GET("DamageMagical") == "acid")
-	{$RETURN $GET_HOOK_PARAM(0) -# 4;};
[spawn] = $SET_COMBATANT_SA($Myself(),"IsProtectedAcidTarget1",1);
\(END)

\(BEGIN)
name = IsProtectedAcidTarget1
[ComputeSpellDamage] = $VAR adj;
-adj = $GET_HOOK_PARAM(0);
-$IF (adj == "")
-	{adj = $GET_HOOK_PARAM(5);};
-$IF ($SA_SPELL_GET("DamageMagical") == "acid")
-	{$SET_HOOK_PARAM(5,(adj -# 1) /# 2);};
-$RETURN $GET_HOOK_PARAM(5);
\(END)

\(BEGIN)
name = IsProtectedEvil
[CharDisplayStatus] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-  {$RETURN $SA_REMOVE();};
-$IF ($GET_HOOK_PARAM(5) == "DISPLAY")
-  {
-   $SET_HOOK_PARAM( 7,"Protected from Evil");
-   $SET_HOOK_PARAM( 6,"");
-  };
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $IF ($GET_CHARACTER_SA($TargetContext(),"IsProtectedEvil") == "-?-?-"){$RETURN;}; // Directional Filter
-$IF ($GET_COMBATANT_SA($AttackerContext(),"Summoned") != "-?-?-")
-	{
-		$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 90);
-		$RETURN "N";
-	};
-$IF ($AlignmentEvil($AttackerContext()))
-	{
-		$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 2);
-		$IF ($GET_HOOK_PARAM(5) <# $GET_HOOK_PARAM(6)){$RETURN "N";};
-	};
[SaveVsBW_Save] = $IF ($AlignmentEvil($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
[SaveVsRSW_Save] = $IF ($AlignmentEvil($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
[SaveVsPP_Save] = $IF ($AlignmentEvil($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
[SaveVsPPDM_Save] = $IF ($AlignmentEvil($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
[SaveVsSp_Save] = $IF ($AlignmentEvil($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
\(END)

\(BEGIN)
name = IsProtectedFireCaster
[CanCastSpells] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-	{
-		$DELETE_CHARACTER_SA($CharacterContext(),"FirePoints");
-		$DELETE_COMBATANT_SA($CharacterContext(),"IsProtectedFireCaster1");
-		$RETURN $SA_REMOVE();
-	};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Protected from Fire");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[DoesSpellAttackSucceed] = $IF ($SA_SPELL_GET("DamageNonMagical") == "fire")
-	{
-		$SET_HOOK_PARAM(5,$GET_CHAR_NAME($IndexOf($TargetContext())) +" is unaffected.");
-		$RETURN "N";
-	};
[spawn] = $SET_COMBATANT_SA($Myself(),"IsProtectedFireCaster1",1);
\(END)

\(BEGIN)
name = IsProtectedFireCaster1
[ComputeSpellDamage] = $VAR points;
-$VAR adj;
-$IF ($SA_SPELL_GET("DamageMagical") == "fire")
-	{
-		adj = $GET_HOOK_PARAM(0);
-		$IF (adj == "") {adj = $GET_HOOK_PARAM(5);};
-		points = $GET_CHARACTER_SA($TargetContext(),"FirePoints");
-		$IF (0 -# points <# adj)
-			{
-				$SET_CHARACTER_SA($TargetContext(),"FirePoints",points +# adj);
-				$SET_HOOK_PARAM(5,0);
-			}
-		$ELSE
-			{
-				$DELETE_CHARACTER_SA($TargetContext(),"FirePoints");
-				$DELETE_CHARACTER_SA($TargetContext(),"IsProtectedFireCaster");
-				$SA_REMOVE();
-				$SET_HOOK_PARAM(5,(adj +# points));
-			};
-	};
-$RETURN $GET_HOOK_PARAM(5);
\(END)

\(BEGIN)
name = IsProtectedFireTarget
[CanCastSpells] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-	{
-		$DELETE_COMBATANT_SA($CharacterContext(),"IsProtectedFireTarget1");
-		$SA_REMOVE();
-	};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Protected from Fire");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[DoesSpellAttackSucceed] = $IF ($SA_SPELL_GET("DamageNonMagical") == "fire")
-	{
-		$SET_HOOK_PARAM(5,$GET_CHAR_NAME($IndexOf($TargetContext())) +" is unaffected.");
-		$RETURN "N";
-	};
[SaveVsBW_Save] = $IF ($SA_SPELL_GET("DamageMagical") == "fire")
-	{$RETURN $GET_HOOK_PARAM(0) -# 4;};
[SaveVsRSW_Save] = $IF ($SA_SPELL_GET("DamageMagical") == "fire")
-	{$RETURN $GET_HOOK_PARAM(0) -# 4;};
[SaveVsSp_Save] = $IF ($SA_SPELL_GET("DamageMagical") == "fire")
-	{$RETURN $GET_HOOK_PARAM(0) -# 4;};
[spawn] = $SET_COMBATANT_SA($Myself(),"IsProtectedFireTarget1",1);
\(END)

\(BEGIN)
name = IsProtectedFireTarget1
[ComputeSpellDamage] = $VAR adj;
-adj = $GET_HOOK_PARAM(0);
-$IF (adj == "")
-	{adj = $GET_HOOK_PARAM(5);};
-$IF ($SA_SPELL_GET("DamageMagical") == "fire")
-	{$SET_HOOK_PARAM(5,(adj -# 1) /# 2);};
-$RETURN $GET_HOOK_PARAM(5);
\(END)

\(BEGIN)
name = IsProtectedGood
[CharDisplayStatus] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET()){$RETURN $SA_REMOVE();};
-$IF ($GET_HOOK_PARAM(5) == "DISPLAY")
-	{
-		$SET_HOOK_PARAM( 7,"Protected from Good");
-		$SET_HOOK_PARAM( 6,"");
-	};
-$RETURN 1;
[DoesAttackSucceed] = $IF ($GET_CHARACTER_SA($TargetContext(),"IsProtectedGood") == "-?-?-"){$RETURN;}; // Directional Filter
-$IF ($GET_COMBATANT_SA($AttackerContext(),"Summoned") != "-?-?-")
-	{
-		$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 90);
-		$RETURN "N";
-	};
-$IF ($AlignmentGood($AttackerContext()))
-	{
-		$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 2);
-		$IF ($GET_HOOK_PARAM(5) <# $GET_HOOK_PARAM(6)){$RETURN "N";};
-	};
[SaveVsBW_Save] = $IF ($AlignmentGood($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
[SaveVsRSW_Save] = $IF ($AlignmentGood($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
[SaveVsPP_Save] = $IF ($AlignmentGood($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
[SaveVsPPDM_Save] = $IF ($AlignmentGood($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
[SaveVsSp_Save] = $IF ($AlignmentGood($AttackerContext())){$RETURN $GET_HOOK_PARAM(0) -# 2;};
\(END)

\(BEGIN)
name = IsProtectedLightningCaster
[CanCastSpells] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-	{
-		$DELETE_CHARACTER_SA($CharacterContext(),"ZapPoints");
-		$DELETE_COMBATANT_SA($CharacterContext(),"IsProtectedLightningCaster1");
-		$RETURN $SA_REMOVE();
-	};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Protected from Lightning");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[DoesSpellAttackSucceed] = $IF ($SA_SPELL_GET("DamageNonMagical") == "electricity")
-	{
-		$SET_HOOK_PARAM(5,$GET_CHAR_NAME($IndexOf($TargetContext())) +" is unaffected.");
-		$RETURN "N";
-	};
[spawn] = $SET_COMBATANT_SA($Myself(),"IsProtectedLightningCaster1",1);
\(END)

\(BEGIN)
name = IsProtectedLightningCaster1
[ComputeSpellDamage] = $VAR points;
-$VAR adj;
-$IF ($SA_SPELL_GET("DamageMagical") == "electricity")
-	{
-		adj = $GET_HOOK_PARAM(0);
-		$IF (adj == "") {adj = $GET_HOOK_PARAM(5);};
-		points = $GET_CHARACTER_SA($TargetContext(),"ZapPoints");
-		$IF (0 -# points <# adj)
-			{
-				$SET_CHARACTER_SA($TargetContext(),"ZapPoints",points +# adj);
-				$SET_HOOK_PARAM(5,0);
-			}
-		$ELSE
-			{
-				$DELETE_CHARACTER_SA($TargetContext(),"ZapPoints");
-				$DELETE_CHARACTER_SA($TargetContext(),"IsProtectedLightningCaster");
-				$SA_REMOVE();
-				$SET_HOOK_PARAM(5,(adj +# points));
-			};
-	};
-$RETURN $GET_HOOK_PARAM(5);
\(END)

\(BEGIN)
name = IsProtectedLightningTarget
[CanCastSpells] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-	{
-		$DELETE_COMBATANT_SA($CharacterContext(),"IsProtectedLightningTarget1");
-		$SA_REMOVE();
-	};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Protected from Lightning");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[DoesSpellAttackSucceed] = $IF ($SA_SPELL_GET("DamageNonMagical") == "electricity")
-	{
-		$SET_HOOK_PARAM(5,$GET_CHAR_NAME($IndexOf($TargetContext())) +" is unaffected.");
-		$RETURN "N";
-	};
[SaveVsBW_Save] = $IF ($SA_SPELL_GET("DamageMagical") == "electricity")
-	{$RETURN $GET_HOOK_PARAM(0) -# 4;};
[SaveVsRSW_Save] = $IF ($SA_SPELL_GET("DamageMagical") == "electricity")
-	{$RETURN $GET_HOOK_PARAM(0) -# 4;};
[SaveVsSp_Save] = $IF ($SA_SPELL_GET("DamageMagical") == "electricity")
-	{$RETURN $GET_HOOK_PARAM(0) -# 4;};
[spawn] = $SET_COMBATANT_SA($Myself(),"IsProtectedLightningTarget1",1);
\(END)

\(BEGIN)
name = IsProtectedLightningTarget1
[ComputeSpellDamage] = $VAR adj;
-adj = $GET_HOOK_PARAM(0);
-$IF (adj == "")
-	{adj = $GET_HOOK_PARAM(5);};
-$IF ($SA_SPELL_GET("DamageMagical") == "electricity")
-	{$SET_HOOK_PARAM(5,(adj -# 1) /# 2);};
-$RETURN $GET_HOOK_PARAM(5);
\(END)

\(BEGIN)
name = IsProtectedPoisonCaster
[CanCastSpells] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-	{
-		$DELETE_CHARACTER_SA($CharacterContext(),"PoisonPoints");
-		$DELETE_COMBATANT_SA($CharacterContext(),"IsProtectedPoisonCaster1");
-		$RETURN $SA_REMOVE();
-	};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Protected from Poison");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[DoesSpellAttackSucceed] = $IF ($SA_SPELL_GET("DamageNonMagical") == "poison")
-	{
-		$SET_HOOK_PARAM(5,$GET_CHAR_NAME($IndexOf($TargetContext())) +" is unaffected.");
-		$RETURN "N";
-	};
[spawn] = $SET_COMBATANT_SA($Myself(),"IsProtectedPoisonCaster1",1);
\(END)

\(BEGIN)
name = IsProtectedPoisonCaster1
[ComputeSpellDamage] = $VAR points;
-$VAR adj;
-$IF ($SA_SPELL_GET("DamageMagical") == "poison")
-	{
-		adj = $GET_HOOK_PARAM(0);
-		$IF (adj == "") {adj = $GET_HOOK_PARAM(5);};
-		points = $GET_CHARACTER_SA($TargetContext(),"PoisonPoints");
-		$IF (0 -# points <# adj)
-			{
-				$SET_CHARACTER_SA($TargetContext(),"PoisonPoints",points +# adj);
-				$SET_HOOK_PARAM(5,0);
-			}
-		$ELSE
-			{
-				$DELETE_CHARACTER_SA($TargetContext(),"PoisonPoints");
-				$DELETE_CHARACTER_SA($TargetContext(),"IsProtectedPoisonCaster");
-				$SA_REMOVE();
-				$SET_HOOK_PARAM(5,(adj +# points));
-			};
-	};
-$RETURN $GET_HOOK_PARAM(5);
\(END)

\(BEGIN)
name = IsProtectedPoisonTarget
[CanCastSpells] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET())
-	{
-		$DELETE_COMBATANT_SA($CharacterContext(),"IsProtectedPoisonTarget1");
-		$SA_REMOVE();
-	};
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Protected from Poison");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[DoesSpellAttackSucceed] = $IF ($SA_SPELL_GET("DamageNonMagical") == "poison")
-	{
-		$SET_HOOK_PARAM(5,$GET_CHAR_NAME($IndexOf($TargetContext())) +" is unaffected.");
-		$RETURN "N";
-	};
[SaveVsBW_Save] = $IF ($SA_SPELL_GET("DamageMagical") == "poison")
-	{$RETURN $GET_HOOK_PARAM(0) -# 4;};
[SaveVsRSW_Save] = $IF ($SA_SPELL_GET("DamageMagical") == "poison")
-	{$RETURN $GET_HOOK_PARAM(0) -# 4;};
[SaveVsSp_Save] = $IF ($SA_SPELL_GET("DamageMagical") == "poison")
-	{$RETURN $GET_HOOK_PARAM(0) -# 4;};
[spawn] = $SET_COMBATANT_SA($Myself(),"IsProtectedPoisonTarget1",1);
\(END)

\(BEGIN)
name = IsProtectedPoisonTarget1
[ComputeSpellDamage] = $VAR adj;
-adj = $GET_HOOK_PARAM(0);
-$IF (adj == "")
-	{adj = $GET_HOOK_PARAM(5);};
-$IF ($SA_SPELL_GET("DamageMagical") == "poison")
-	{$SET_HOOK_PARAM(5,(adj -# 1) /# 2);};
-$RETURN $GET_HOOK_PARAM(5);
\(END)

\(BEGIN)
name = IsReduced
[CharDisplayStatus] = $VAR myself;
-$VAR duration;
-$VAR size;
-$VAR str;
-$VAR strMod;
-$VAR originalSize;
-$VAR originalStr;
-$VAR originalStrMod;
-myself = $MyIndex();
-duration = $SA_PARAM_GET();
-size = $GET_CHAR_SIZE(myself);
-str = $GET_CHAR_STR(myself);
-strMod = $GET_CHAR_STRMOD(myself);
-originalSize = $GET_COMBATANT_SA($Myself(), "IsReducedSize");
-originalStr = $GET_COMBATANT_SA($Myself(), "IsReducedStr");
-originalStrMod = $GET_COMBATANT_SA($Myself(), "IsReducedStrMod");
-$IF (size ># 0){$SET_CHAR_SIZE(myself, 0);};
-$IF (str ># 6){$SET_CHAR_STR(myself, 6);$SET_CHAR_STRMOD(myself, 0);};
-$IF ($GET_PARTY_TIME() >=# duration)
-	{
-		$SA_REMOVE();
-		$SET_CHAR_SIZE(myself, originalSize);
-		$SET_CHAR_STR(myself, originalStr);
-		$SET_CHAR_STRMOD(myself, originalStrMod);
-	};
-$SET_HOOK_PARAM(7,"Reduced");
-$SET_HOOK_PARAM(6,"");
-$RETURN 1;
[Dispel] = $VAR myself;
-$VAR originalSize;
-$VAR originalStr;
-$VAR originalStrMod;
-myself = $MyIndex();
-originalSize = $GET_COMBATANT_SA($Myself(), "IsReducedSize");
-originalStr = $GET_COMBATANT_SA($Myself(), "IsReducedStr");
-originalStrMod = $GET_COMBATANT_SA($Myself(), "IsReducedStrMod");
-$SA_REMOVE();
-$SET_CHAR_SIZE(myself, originalSize);
-$SET_CHAR_STR(myself, originalStr);
-$SET_CHAR_STRMOD(myself, originalStrMod);
[GetAdjMaxMovement] = $RETURN $GET_HOOK_PARAM(5) /# 2;
\(END)

\(BEGIN)
name = IsReflecting
[RedirectSpell] = $VAR casterName;
-$VAR targetName;
-$VAR listGaze;
-$VAR numGaze;
-$VAR reflectedGaze;
-listGaze = "$monsterCharmGaze$monsterConfusionGaze$monsterPetrifyGaze";
-numGaze = $DelimitedStringCount(listGaze);
-$WHILE (numGaze ># 0)
-	{
-		numGaze = numGaze -# 1;
-		reflectedGaze = $DelimitedStringSubstring(listGaze,numGaze);
-		$IF ($SpellContext() == reflectedGaze)
-			{
-				$SET_HOOK_PARAM(5,$IndexOf($AttackerContext()));
-				casterName = $GET_CHAR_NAME ($IndexOf($AttackerContext()));
-				targetName = $GET_CHAR_NAME ($IndexOf($TargetContext()));
-				$SET_HOOK_PARAM(6, targetName + " reflects " + reflectedGaze  + " back at " + casterName);
-			};
-	};
\(END)

\(BEGIN)
name = IsResistantCold
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Cold Resistant");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[ComputeDamage] = $VAR resist;
-$VAR expiration;
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() >=# expiration){$SA_REMOVE();};
-resist = $SA_ITEM_GET("DamageMagical");
-$IF (resist == "cold"){$RETURN $GET_HOOK_PARAM(5) /# 2;};
[ComputeSpellDamage] = $VAR resist;
-$VAR expiration;
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() >=# expiration){$SA_REMOVE();};
-resist = $SA_SPELL_GET("DamageMagical");
-$IF (resist == "cold"){$RETURN $GET_HOOK_PARAM(5) /# 2;};
\(END)

\(BEGIN)
name = IsResistantFire
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Fire Resistant");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[ComputeDamage] = $VAR resist;
-$VAR expiration;
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() >=# expiration){$SA_REMOVE();};
-resist = $SA_ITEM_GET("DamageMagical");
-$IF (resist == "fire"){$RETURN $GET_HOOK_PARAM(5) /# 2;};
[ComputeSpellDamage] = $VAR resist;
-$VAR expiration;
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() >=# expiration){$SA_REMOVE();};
-resist = $SA_SPELL_GET("DamageMagical");
-$IF (resist == "fire"){$RETURN $GET_HOOK_PARAM(5) /# 2;};
\(END)

\(BEGIN)
name = IsRingImmuneElectricity
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Immune to Electricity");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[ComputeDamage] = $VAR immune;
-immune = $SA_ITEM_GET("DamageMagical");
-$IF (immune == "electricity"){$RETURN 0;};
[ComputeSpellDamage] = $VAR immune;
-immune = $SA_SPELL_GET("DamageMagical");
-$IF (immune == "electricity"){$RETURN 0;};
\(END)

\(BEGIN)
name = IsRingResistantCold
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Cold Resistant");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[ComputeDamage] = $VAR resist;
-resist = $SA_ITEM_GET("DamageMagical");
-$IF (resist == "cold"){$RETURN $GET_HOOK_PARAM(5) /# 2;};
[ComputeSpellDamage] = $VAR resist;
-resist = $SA_SPELL_GET("DamageMagical");
-$IF (resist == "cold"){$RETURN $GET_HOOK_PARAM(5) /# 2;};
\(END)

\(BEGIN)
name = IsRingResistantFire
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, "Fire Resistant");
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[ComputeDamage] = $VAR resist;
-resist = $SA_ITEM_GET("DamageMagical");
-$IF (resist == "fire"){$RETURN $GET_HOOK_PARAM(5) /# 2;};
[ComputeSpellDamage] = $VAR resist;
-resist = $SA_SPELL_GET("DamageMagical");
-$IF (resist == "fire"){$RETURN $GET_HOOK_PARAM(5) /# 2;};
\(END)

\(BEGIN)
name = IsShielded
[CharDisplayStatus] = $IF ($GET_PARTY_TIME() ># $SA_PARAM_GET()){$SA_REMOVE();};
-$IF ($GET_HOOK_PARAM(5) == "DISPLAY")
-	{
-		$SET_HOOK_PARAM( 7,"Shield");
-		$SET_HOOK_PARAM( 6,"1");
-	};
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $VAR atk;
-$VAR tgt;
-$IF ($GET_CHARACTER_SA($TargetContext(),"IsShielded") == "-?-?-")
-  {$RETURN;};
-atk = $IndexOf($AttackerContext());
-tgt = $IndexOf($TargetContext());
-$IF ($SA_ITEM_GET("item_HurledWeapon") != "-?-?-" && $VisualDistance(atk,tgt) ># 1)
-	{$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 8);}
-$ELSE
-	{
-		$IF ($SA_ITEM_GET("item_MissileWeapon") != "-?-?-"){$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 7);}
-		$ELSE {$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) -# 6);};
-	};
-$IF ($GET_HOOK_PARAM(5) <# $GET_HOOK_PARAM(6)){$RETURN "N";};
[DoesSpellAttackSucceed] = $IF ($SA_SOURCE_NAME() == "Magic Missile"){$RETURN "N";};
\(END)

\(BEGIN)
name = IsShortSaveBonus
[SaveVsBW_Save] = $RETURN $GET_HOOK_PARAM(0) +# $SA_PARAM_GET();
[SaveVsPPDM_Save] = $RETURN $GET_HOOK_PARAM(0) +# $SA_PARAM_GET();
[SaveVsPP_Save] = $RETURN $GET_HOOK_PARAM(0) +# $SA_PARAM_GET();
[SaveVsRSW_Save] = $RETURN $GET_HOOK_PARAM(0) +# $SA_PARAM_GET();
[SaveVsSp_Save] = $RETURN $GET_HOOK_PARAM(0) +# $SA_PARAM_GET();
\(END)

\(BEGIN)
name = IsSilenced
[CanCastSpells] = $VAR expiration;
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() >=# expiration){$SA_REMOVE();};
-$RETURN "N";
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Silenced");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
\(END)

\(BEGIN)
name = IsSleeping
[CanCastSpells] = $RETURN "N";
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $RETURN "Y";
[GetAdjMaxMovement] = $RETURN 0;
[GetItemTargetHitBonus] = $RETURN $GET_CHAR_HITPOINTS($IndexOf($TargetContext())) +# 15;
[IsCombatReady] = $RETURN "N";
\(END)

\(BEGIN)
name = IsSleepResistant
\(END)

\(BEGIN)
name = IsSleepResistantMin
\(END)

\(BEGIN)
name = IsSlow
[Dispel] = $SA_REMOVE();
[GetAdjMaxMovement] = $VAR expiration;
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() >=# expiration){$SA_REMOVE();};
-$RETURN $GET_HOOK_PARAM(5) /# 2;
[GetNumberOfAttacks] = $VAR attackNum;
-attackNum = $GET_HOOK_PARAM(5);
-$IF ((attackNum %# 2) ==# 0){$RETURN attackNum /# 2;};
-$IF (($GetCombatRound() %# 2) ==# 0){$RETURN (attackNum +# 1) /# 2;}
-$ELSE{$RETURN (attackNum -# 1) /# 2;};
\(END)

\(BEGIN)
name = IsSlowedPoison
[CanCastSpells] = $VAR expiration;
-$VAR time;
-$VAR char;
-$VAR hp;
-expiration = $GET_SA_PARAM();
-time = $GET_PARTY_TIME();
-char = $IndexOf($CharacterContext());
-hp = $GET_CHAR_HITPOINTS(char);
-$IF (time ># expiration)
-	{
-		$SA_REMOVE();
-		$SET_CHAR_STATUS(char,2);
-		$SET_CHAR_HITPOINTS(char,-11);
-		$RETURN;
-	};
-$SET_CHAR_STATUS(char,1);
-$IF  (hp <# 1){$SET_CHAR_HITPOINTS(char,1);};
\(END)

\(BEGIN)
name = IsSnake
\(END)

\(BEGIN)
name = IsSnakeCharmed
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Charmed");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[GetAdjMaxMovement] = $RETURN "0";
[GetItemTargetHitBonus] = $RETURN $GET_CHAR_HITPOINTS($IndexOf($TargetContext())) +# 15;
[IsCombatReady] = $VAR expiration;
-expiration = $SA_PARAM_GET();
-$IF ($GET_PARTY_TIME() >=# expiration){$SA_REMOVE();};
-$RETURN "N";
\(END)

\(BEGIN)
name = IsStinkingCloudy
[CanCastSpells] = $RUN_AREA_SE_SCRIPTS("StinkAdjust", $IndexOf($CharacterContext()));
-$RETURN $GET_HOOK_PARAM(6);
[CharDisplayStatus] = $RUN_AREA_SE_SCRIPTS("StinkingCloudy", $IndexOf($CharacterContext()));
-$SET_HOOK_PARAM( 7, $GET_HOOK_PARAM(8));
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
\(END)

\(BEGIN)
name = IsStinkingStuck
[CharDisplayStatus] = $RUN_AREA_SE_SCRIPTS("StinkingStuck", $IndexOf($CharacterContext()));
-$SET_HOOK_PARAM( 7, $GET_HOOK_PARAM(8));
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[ComputeDamage] = $IF ($GET_COMBATANT_SA($TargetContext(),"IsStinkingStuck") != "-?-?-")
-  {$RETURN $GET_CHAR_HITPOINTS($IndexOf($TargetContext()));};
[Dispel] = $SA_REMOVE();
[DoesAttackSucceed] = $IF ($GET_COMBATANT_SA($TargetContext(),"IsStinkingStuck") != "-?-?-")
-  {$RETURN "Y";};
[IsCombatReady] = $RUN_AREA_SE_SCRIPTS("StinkAdjust", $IndexOf($CharacterContext()));
-$RETURN $GET_HOOK_PARAM(6);
\(END)

\(BEGIN)
name = IsStunned
[CanCastSpells] = $RETURN "N";
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Stunned");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
[GetAdjMaxMovement] = $RETURN "0";
[IsCombatReady] = $RETURN "N";
\(END)

\(BEGIN)
name = IsSweeping
[CombatSpecialAction] = $VAR damage;
-$VAR distance;
-$VAR attacker;
-$VAR target;
-attacker = $IndexOf($AttackerContext());
-target = $IndexOf($TargetContext());
-$IF ($GET_COMBATANT_SA($AttackerContext(),"IsInvisible") != "-?-?-")
-	{
-		$DELETE_CHARACTER_SA($AttackerContext(),"IsInvisibleSpell");
-		$DELETE_COMBATANT_SA($AttackerContext(),"IsInvisible");
-	};
-$IF (target ==# -#2){$SET_HOOK_PARAM(5,"Sweeps");$RETURN;}; // first call
-$IF (target ==# -#1){$SET_HOOK_PARAM(5,"Sweeps");$RETURN;}; // last call
-distance = $VisualDistance(attacker, target);
-damage = $ComputeAttackDamage(attacker, target);
-$IF(distance ># 1) {$RETURN;};
-$IF ($GET_MONSTERTYPE_SA($GET_CHAR_NAME(target),"monster_Swept") != "-?-?-")
-	{
-		$SET_CHAR_HITPOINTS(target, $GET_CHAR_HITPOINTS(target) -# damage);
-	};
\(END)

\(BEGIN)
name = item_Antidote
[InvokeSpellOnTarget] = $VAR tgt;
-tgt = $IndexOf($TargetContext());
-$IF ($GET_CHARACTER_SA($TargetContext(), "IsPoisoned") == "-?-?-"){$RETURN;};
-$DELETE_CHARACTER_SA($CharacterContext(),"IsPoisoned");
-$IF ($GET_CHAR_HITPOINTS(tgt) <=# 0)
-	{
-		$SET_CHAR_HITPOINTS(tgt, "1");
-		$SET_CHAR_STATUS(tgt, "0");
-	};
\(END)

\(BEGIN)
name = item_BootsOfSpeed
[OnReady] = $SET_CHARACTER_SA($CharacterContext(),"IsFastBoots","1");
[OnUnReady] = $DELETE_CHARACTER_SA($CharacterContext(),"IsFastBoots");
\(END)

\(BEGIN)
name = item_CloakOfDisplacement
[OnReady] = $SET_CHARACTER_SA($CharacterContext(),"IsCloakDisplaced",1);
[OnUnReady] = $DELETE_CHARACTER_SA($CharacterContext(),"IsCloakDisplaced");
\(END)

\(BEGIN)
name = item_CombatAim
[CanAim] = $VAR p5;
-$IF ($GET_HOOK_PARAM(6))
-	{
-		p5 = $GET_HOOK_PARAM(5);
-		$IF(p5 == "Bow" || p5 ==  "Crossbow" || p5 ==  "Sling (no ammo needed)"){$RETURN "N";};
-	};
\(END)

\(BEGIN)
name = item_DrowEquipment
[item_DrowEquipment] = $TAKE_CHAR_ITEM($CharacterContext(), $ItemContext());
-$RETURN "2";
\(END)

\(BEGIN)
name = item_ElixirOfYouth
\(END)

\(BEGIN)
name = item_FineWeapon
[ComputeDamage] = $RETURN $GET_HOOK_PARAM(5) +# $GET_CHAR_DAMAGEBONUS ($IndexOf($AttackerContext()));
[DoesAttackSucceed] = $SET_HOOK_PARAM(5, $GET_HOOK_PARAM(5) +# 
$GET_CHAR_HITBONUS($IndexOf($AttackerContext())));
-$IF ($GET_HOOK_PARAM(5) >=# $GET_HOOK_PARAM(6)){$RETURN "Y";};
\(END)

\(BEGIN)
name = item_GauntletsOgrePower
[OnReady] = $VAR target;
-target = $IndexOf($Myself());
-$SET_CHARACTER_SA($Myself(),"ogreStrength",18-#$GET_CHAR_STR(target));
-$SET_CHAR_STR(target,18);
-$SET_CHARACTER_SA($Myself(),"ogreStrengthMod",100-#$GET_CHAR_STRMOD(target));
-$SET_CHAR_STRMOD(target,100);
[OnUnReady] = $VAR target;
-target = $IndexOf($Myself());
-$SET_CHAR_STR(target,$GET_CHAR_STR(target)-#$SA_CHARACTER_GET("ogreStrength"));
-$DELETE_CHARACTER_SA($Myself(),"ogreStrength");
-$SET_CHAR_STRMOD(target,$GET_CHAR_STRMOD(target)-#$SA_CHARACTER_GET("ogreStrengthMod"));
-$DELETE_CHARACTER_SA($Myself(),"ogreStrengthMod");
\(END)

\(BEGIN)
name = item_GirdleGiantStrength
[OnReady] = $VAR target;
-target = $IndexOf($Myself());
-$SET_CHARACTER_SA($Myself(),"girdleStrength",$SA_PARAM_GET()-#$GET_CHAR_STR(target));
-$SET_CHAR_STR(target,$SA_PARAM_GET());
-$SET_CHARACTER_SA($Myself(),"girdleStrengthMod",$GET_CHAR_STRMOD(target));
-$SET_CHAR_STRMOD(target,0);
[OnUnReady] = $VAR target;
-target = $IndexOf($Myself());
-$SET_CHAR_STR(target,$GET_CHAR_STR(target)-#$SA_CHARACTER_GET("girdleStrength"));
-$DELETE_CHARACTER_SA($Myself(),"girdleStrength");
-$SET_CHAR_STRMOD(target,$SA_CHARACTER_GET("girdleStrengthMod"));
-$DELETE_CHARACTER_SA($Myself(),"girdleStrengthMod");
\(END)

\(BEGIN)
name = item_HolyWater
\(END)

\(BEGIN)
name = item_HurledWeapon
[ComputeDamage] = $VAR p0;
-$VAR p5;
-$VAR dmg;
-$VAR atk;
-p0 = $GET_HOOK_PARAM(0);
-p5 = $GET_HOOK_PARAM(5);
-dmg = p0;
-$IF (dmg == ""){dmg = p5;};
-atk = $IndexOf($AttackerContext());
-$IF ($VisualDistance(atk,$IndexOf($TargetContext())) <# 2)
-	{
-		dmg = dmg +# $GET_CHAR_DAMAGEBONUS(atk);
-	};
-$RETURN dmg;
[DoesAttackSucceed] = $VAR atk;
-atk = $IndexOf($AttackerContext());
-$IF ($VisualDistance(atk,$IndexOf($TargetContext())) <# 2)
-	{
-		$SET_HOOK_PARAM(5,$GET_HOOK_PARAM(5) +# $GET_CHAR_HITBONUS(atk));
-		$IF ($GET_HOOK_PARAM(5) >=# $GET_HOOK_PARAM(6))
-			{
-				$RETURN "Y";
-			};
-	};
\(END)

\(BEGIN)
name = item_LongSwordVsGiants
[ComputeDamage] = $IF ($GET_ISGIANT($TargetContext())){$RETURN $GET_HOOK_PARAM(5) *# 2;};
\(END)

\(BEGIN)
name = item_MagicalWeapon 
Parameters = "0 - no, 1 - +1, 2 - +2, 3 - +3, 4 - +4, 5 - +5, 6 - other";
\(END)

\(BEGIN)
name = item_MissileWeapon
Parameters = "1 - arrow, 2 - bolt, 3 - dart, 4 - javelin/spear, 5 - other";
[ComputeDamage] = $VAR wpn;
-$VAR add;
-$VAR bonus;
-wpn = $GET_CHAR_Ready($AttackerContext(), "WEAPON", 0);
-add = 0;
-bonus = $IndexOf($AttackerContext());
-$IF (wpn == "Fine Long Bow"){add = $GET_CHAR_DAMAGEBONUS(bonus);};
-$IF (wpn == "Fine Long Bow +2"){add = 2 +# $GET_CHAR_DAMAGEBONUS(bonus);};
-$RETURN $GET_HOOK_PARAM(5) +# add;
[DoesAttackSucceed] = $VAR wpn;
-$VAR add;
--VAR bonus;
-wpn = $GET_CHAR_Ready($AttackerContext(), "WEAPON", 0);
-add = 0;
-bonus = $IndexOf($AttackerContext());
-$IF (wpn == "Fine Long Bow"){add = $GET_CHAR_HITBONUS(bonus);};
-$IF (wpn == "Fine Long Bow +2"){add = 2 +# $GET_CHAR_HITBONUS(bonus);};
-$SET_HOOK_PARAM(5, $GET_HOOK_PARAM(5) +# add);
-$IF ($GET_HOOK_PARAM(5) >=# $GET_HOOK_PARAM(6)){$RETURN "Y";};
ComputeDamage = $VAR wpn;
-$VAR add;
-$VAR bonus;
-wpn = $GET_CHAR_Ready($AttackerContext(), "WEAPON", 0);
-add = 0;
-bonus = $IndexOf($AttackerContext());
-$IF ($GET_ITEM_SA(wpn,"item_FineWeapon") != "-?-?-")
-{add = $GET_CHAR_DAMAGEBONUS(bonus);};
-$IF ($GET_ITEM_SA(wpn,"item_MagicalWeapon") != "-?-?-")
-	{
-		add = add +# $GET_ITEM_SA(wpn,"item_MagicalWeapon");
-	};
-$RETURN $GET_HOOK_PARAM(5) +# add;
-DoesAttackSucceed = $VAR wpn;
-$VAR add;
-$VAR bonus;
-wpn = $GET_CHAR_Ready($AttackerContext(), "WEAPON", 0);
-add = 0;
-bonus = $IndexOf($AttackerContext());
-$IF ($GET_ITEM_SA(wpn,"item_FineWeapon") != "-?-?-")
-	{
-		add = $GET_CHAR_HITBONUS(bonus);
-	};
-$IF ($GET_ITEM_SA(wpn,"item_MagicalWeapon") != "-?-?-")
-	{
-		add = add +# $GET_ITEM_SA(wpn,"item_MagicalWeapon");
-	};
-$SET_HOOK_PARAM(5, $GET_HOOK_PARAM(5) +# add);
-$IF ($GET_HOOK_PARAM(5) >=# $GET_HOOK_PARAM(6))
-	{
-		$RETURN "Y";
-	};
\(END)

\(BEGIN)
name = item_Periapt
[OnReady] = $SET_CHARACTER_SA($CharacterContext(), "IsImmuneDisease", "1");
[OnUnReady] = $DELETE_CHARACTER_SA($CharacterContext(),"IsImmuneDisease");
\(END)

\(BEGIN)
name = item_Poison
[DoesAttackSucceed] = $VAR time;
-$VAR par5;
-$VAR par6;
-time = $GET_PARTY_TIME();
-par5 = $GET_HOOK_PARAM(5);
-par6 = $GET_HOOK_PARAM(6);
-$IF ($SA_CHARACTER_GET("IsImmunePoison") != "-?-?-"){$RETURN;};
-$IF ($SA_CHARACTER_GET("IsProtectedPoisonCaster") != "-?-?-"){$RETURN;};
-$IF ($SA_CHARACTER_GET("IsProtectedPoisonTarget") != "-?-?-"){$RETURN;};
-$IF (par5 ># par6)
-	{
-		$SET_CHARACTER_SA($TargetContext(),"IsPoisoned",time);
-		$SET_CHAR_STATUS($IndexOf($TargetContext()),2);
-		$SET_CHAR_HITPOINTS($IndexOf($TargetContext()),"-11");
-	};
\(END)

\(BEGIN)
name = item_PotionInvisibility
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $SET_CHARACTER_SA($TargetContext(),"IsInvisiblePotion",2);
[RemoveLinger] = $RETURN "TARGETS";
\(END)

\(BEGIN)
name = item_Reflect
[OnReady] = $SET_CHARACTER_SA($CharacterContext(), "IsReflecting", "1");
[OnUnReady] = $DELETE_CHARACTER_SA($CharacterContext(),"IsReflecting");
\(END)

\(BEGIN)
name = item_RingOfBlinking
[OnReady] = $SET_CHARACTER_SA($CharacterContext(),"IsBlinkingRing","1");
-$IF ($GET_CHARACTER_SA($CharacterContext(),"side") != "-?-?-")
-	{
-		$SET_CHARACTER_SA($CharacterContext(),"IsBlinking1",1);
-		$SET_CHARACTER_SA($CharacterContext(),"IsBlinking2",1);
-	};
[OnUnReady] = $DELETE_CHARACTER_SA($CharacterContext(),"IsBlinkingRing");
-$DELETE_CHARACTER_SA($CharacterContext(),"IsBlinking1");
-$DELETE_CHARACTER_SA($CharacterContext(),"IsBlinking2");
\(END)

\(BEGIN)
name = item_RingOfColdResistance
[OnReady] = $SET_CHARACTER_SA($CharacterContext(),"IsRingResistantCold", "");
[OnUnReady] = $DELETE_CHARACTER_SA($CharacterContext(), "IsRingResistantCold");
\(END)

\(BEGIN)
name = item_RingOfElectricalImmunity
[OnReady] = $SET_CHARACTER_SA($CharacterContext(),"IsRingImmuneElectricity", "");
[OnUnReady] = $DELETE_CHARACTER_SA($CharacterContext(), "IsRingImmuneElectricity");
\(END)

\(BEGIN)
name = item_RingOfFireResistance
[OnReady] = $SET_CHARACTER_SA($CharacterContext(),"IsRingResistantFire", "");
[OnUnReady] = $DELETE_CHARACTER_SA($CharacterContext(), "IsRingResistantFire");
\(END)

\(BEGIN)
name = item_RingOfInvisibility
[OnReady] = $SET_CHARACTER_SA($CharacterContext(),"IsInvisibleRing","1");
[OnUnReady] = $DELETE_CHARACTER_SA($CharacterContext(),"IsInvisibleRing");
\(END)

\(BEGIN)
name = item_RingOfProtectionFromEvil
[OnReady] = $SET_CHARACTER_SA($CharacterContext(),"IsProtectedEvil","1");
[OnUnReady] = $DELETE_CHARACTER_SA($CharacterContext(),"IsProtectedEvil");
\(END)

\(BEGIN)
name = item_RingOfWizardry
[OnReady] = 
[OnUnReady] = 
\(END)

\(BEGIN)
name = item_Scroll
[OnReady] = $VAR name;
-$VAR class;
-name = $MyIndex();
-class = $SA_PARAM_GET();
-$IF ($GET_CHAR_Lvl(name,class) <# 1 && $GET_CHAR_THIEFLVL(name) <# 10)
-	{
-		$SET_CHAR_Ready($CharacterContext(),0,"");
-	};
\(END)

\(BEGIN)
name = item_SpiritualHammer
[OnReady] = $SET_ITEM_SA("Spiritual Hammer","item_MagicalWeapon",$GET_CHAR_Lvl($MyIndex(),"cleric") /# 3);
\(END)

\(BEGIN)
name = item_VorpalLongSword
[ComputeDamage] = $IF ($SA_COMBATANT_GET("vorp") ==# 20)
-	{
-		$SET_HOOK_PARAM(7,"The combatant's head is cleaved from it's body");
-		$RETURN $GET_HOOK_PARAM(5) +# $GET_CHAR_HITPOINTS($IndexOf($TargetContext()));
-	};
[DoesAttackSucceed] = $RETURN $SET_COMBATANT_SA($TargetContext(),"vorp",$GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = item_WeaponType
Parameters = "blunt, piercing, slashing, piercing/slashing";
\(END)

\(BEGIN)
name = item_Whip
[OnReady] = $VAR char;
-char = $IndexOf($CharacterContext());
-$IF ($GET_CHAR_DRUIDLVL(char) <# 1 && $GET_CHAR_FIGHTERLVL(char) <# 1 && $GET_CHAR_PALADINLVL(char) <# 1 && $GET_CHAR_RANGERLVL(char) <# 1 && $GET_CHAR_RACE(char) != "Drow")
-	{
-		$SET_CHAR_Ready($CharacterContext(),0,"");
-	};
\(END)

\(BEGIN)
name = itemSlot_Fingers
[CanReady] = $IF ($GET_HOOK_PARAM( 5 ) <# 2)
-	{
-		$RETURN "Y";
-	}
-$ELSE
-	{
-		$SET_HOOK_PARAM(6, "Sorry, you can't do that.");
-		$RETURN "N";
-	};
\(END)

\(BEGIN)
name = itemSlot_Pack
[CanReady] = $RETURN "Y";
\(END)

\(BEGIN)
name = monster_BearHug1
[InvokeSpellOnTarget] = $SET_COMBATANT_SA($AttackerContext(),"CombatRoundStart",1);
\(END)

\(BEGIN)
name = monster_BearHug2
[InvokeSpellOnTarget] = $VAR Atk;
-$VAR Tgt;
-$IF ($GET_COMBATANT_SA($AttackerContext(),"CombatRoundStart") ==# 1)
-	{
-		$IF ($GET_CHARACTER_SA($TargetContext(),"IsHugged") == "-?-?-")
-			{
-				Atk = $IndexOf($AttackerContext());
-				Tgt = $IndexOf($TargetContext());
-// Attacker
-				$SET_COMBATANT_SA($AttackerContext(),"HugLink",Tgt);
-				$SET_COMBATANT_SA($AttackerContext(),"monster_BearHugging",Tgt);
-// Target
-				$SET_COMBATANT_SA($TargetContext(),"monster_BearHugged",Atk);
-				$SET_COMBATANT_SA($TargetContext(),"HugLink",Atk);
-				$SET_CHARACTER_SA($TargetContext(),"IsHugged",1);
-			};
-	};
\(END)

\(BEGIN)
name = monster_BearHugged
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Hugged by Bear");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[OnStartCombatantAction] = $VAR Atk;
-Atk = $SA_PARAM_GET();
-$IF ($GET_CHAR_HITPOINTS(Atk) <# 1)
-	{
-		$DELETE_COMBATANT_SA($CombatantContext(),"HugLink");
-		$DELETE_CHARACTER_SA($CombatantContext(),"IsHugged");
-		$SA_REMOVE();
-	};
\(END)

\(BEGIN)
name = monster_BearHugging
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Hugging");
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Hugging");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[GetAdjMaxMovement] = $RETURN 0;
[GetNumberOfAttacks] = $RETURN 0;
[OnStartCombatantAction] = $VAR Tgt;
-$VAR name;
-$VAR dmg;
-Tgt = $SA_PARAM_GET();
-$IF ($GET_CHAR_HITPOINTS(Tgt) ># 0)
-	{
-		name = $GET_CHAR_NAME($IndexOf($CombatantContext()));
-		$IF (name == "Black Bear"){dmg = ($RANDOM(4) +# $RANDOM(4) +# 2);};
-		$IF (name == "Brown Bear"||name == "Grizzly Bear"){dmg = ($RANDOM(6) +# $RANDOM(6) +# 2);};
-		$IF (name == "Cave Bear"||name == "Owlbear"||name == "Werebear" ){dmg = ($RANDOM(8) +# $RANDOM(8) +# 2);};
-		$IF (name == "Northern Bear"){dmg = ($RANDOM(6) +# $RANDOM(6) +# $RANDOM(6) +# 3);};
-		$SET_CHAR_HITPOINTS(Tgt,$GET_CHAR_HITPOINTS(Tgt) -# dmg);
-	};
-$IF ($GET_CHAR_HITPOINTS(Tgt) <# 1)
-	{
-		$IF ($GET_CHAR_HITPOINTS(Tgt) <# "-9")
-			{
-				$SET_CHAR_STATUS(Tgt,2);
-			}
-		$ELSE
-			{
-				$SET_CHAR_STATUS(Tgt,9);
-			};
-		$DELETE_COMBATANT_SA($CombatantContext(),"monster_BearHugging");
-	};
\(END)

\(BEGIN)
name = monster_BeholderAttacks
[StartCombatRound] = $GIVE_CHAR_ITEM( $Myself(), "monsterBeholderCharm" );
-$GIVE_CHAR_ITEM( $Myself(), "monsterBeholderSleep" );
-$GIVE_CHAR_ITEM( $Myself(), "monsterBeholderFleshToStone" );
-$GIVE_CHAR_ITEM( $Myself(), "monsterBeholderFear" );
-$GIVE_CHAR_ITEM( $Myself(), "monsterBeholderSlow" );
\(END)

\(BEGIN)
name = monster_Class

\(END)

\(BEGIN)
name = monster_CombatantAlignment
[CreateMonsterCombatant] = $VAR param;
-$VAR char;
-param = $SA_PARAM_GET();
-char = $IndexOf($CharacterContext());
-$IF (param == "good"){$SET_CHAR_ALIGNMENT(char,1);};
-$IF (param == "neutral"){$SET_CHAR_ALIGNMENT(char,4);};
-$IF (param == "evil"){$SET_CHAR_ALIGNMENT(char,7);};
\(END)

\(BEGIN)
name = monster_Displacement
[InvokeSpellOnTarget] = $SET_COMBATANT_SA($CombatantContext(),"IsDisplaced","");
\(END)

\(BEGIN)
name = monster_DragonFear
[CheckProximity] = $VAR target;
-$VAR myself;
-$VAR range;
-$VAR distance;
-$VAR saveVsSpell;
-$VAR roll;
-$VAR roll2;
-$VAR charClass;
-$VAR bclass;
-$VAR classes;
-$VAR charClass;
-$VAR remainingBaseClasses;
-$VAR baseClassNum;
-$VAR baseClassName;
-$VAR PClevel;
-$VAR PCclass;
-$VAR dragonList;
-$VAR dragonNum;
-$VAR dragonName;
-target = $GET_HOOK_PARAM(5);
-myself = $GET_HOOK_PARAM(6);
-$IF ($SA_COMBATANT_GET("IsDragonFear") != "-?-?-"){$RETURN;};
-$IF ($SA_COMBATANT_GET("IsDragonFlee") != "-?-?-"){$RETURN;};
-dragonList = "$Black Dragon$Blue Dragon$Gold Dragon$Green Dragon$Red Dragon$Silver Dragon$White Dragon";
-dragonNum = $DelimitedStringCount(dragonList);
-$WHILE (dragonNum >=# 0)
-	{
-		dragonNum = dragonNum -# 1;
-		dragonName = $DelimitedStringSubstring(dragonList,dragonNum);
-		$IF ($GET_CHAR_NAME($MyIndex()) == dragonName)
-			{
-				$RETURN;
-			};
-	};
-range = $SA_PARAM_GET();
-distance = $VisualDistance(target, myself);
-$IF (range <# distance){$RETURN;};
-saveVsSpell = $GET_CHAR_SAVEVSSP(target);
-roll = $RANDOM(20) +# 1;
-// determine level PC/NPC
-charClass = $GET_CHAR_CLASS(myself);
-bclass = "$fighter$cleric$ranger$paladin$magicUser$thief$druid";
-classes = "$0$1$2$3$4$5$6$01$014$12$14$15$04$05$045$45$06$46$046";
-PClevel = 0;
-remainingBaseClasses = $DelimitedStringSubstring(classes, charClass); //Eg: "025"
-baseClassNum = $MIDDLE(remainingBaseClasses,0,1);    // Eg: "0"
-$WHILE (baseClassNum != "")
-	{
-		remainingBaseClasses = $MIDDLE(remainingBaseClasses,1,999); // Eg: "25" or "5"
-		baseClassName = $DelimitedStringSubstring(bclass,baseClassNum); // Eg: "fighter"
-		$IF($GET_CHAR_Lvl(myself, baseClassName) ># PClevel)
-			{
-				PCclass = baseClassName; //Eg: "fighter"
-				PClevel = $GET_CHAR_Lvl(myself, baseClassName); // Eg: "3"
-			};
-		baseClassNum = $MIDDLE(remainingBaseClasses,0,1); // Eg: "2" or "5" or ""
-	};
-// is combatant a monster? if so, use monsterLevel
-$IF ($SA_COMBATANT_GET("monsterLevel") != "-?-?-")
-	{
-		PClevel = $SA_COMBATANT_GET("monsterLevel");
-	};
-// determine combatants reactions
-$IF (PClevel >=# 6){$RETURN $SET_COMBATANT_SA($Myself(),"ImmuneDragonFear", 12);};
-$IF (PClevel <# 3)
-	{
-		$IF (saveVsSpell ># roll)
-			{
-				roll2 = $RANDOM(2);
-				$IF (roll2 ==# 0)
-					{
-						$RETURN $SET_COMBATANT_SA($Myself(), "IsDragonFlee","Fleeing Dragon");
-					}
-				$ELSE
-					{
-						$RETURN $SET_COMBATANT_SA($Myself(),"IsDragonFear","Paralyzed by Dragon Fear");
-					};
-			};
-	}
-$ELSE
-	{
-		$RETURN $SET_CHAR_THAC0(myself,($GET_CHAR_THAC0(myself) +# 1));
-	};
\(END)

\(BEGIN)
name = monster_DrainStrength
[InvokeSpellOnTarget] = $VAR tgt;
-tgt = $IndexOf($TargetContext());
-$SET_CHARACTER_SA($TargetContext(),"IsDrainedStrength",$GET_PARTY_TIME() +# (($RANDOM(4) +# $RANDOM(4) +# 2) *# 10));
-// SA lowStr used to circumvent Min/Max
-$IF ($GET_CHAR_STR(tgt) <# 4 && $GET_COMBATANT_SA($TargetContext(),"lowStr") != "-?-?-")
-	{
-		$SET_COMBATANT_SA($TargetContext(),"lowStr",$GET_COMBATANT_SA($TargetContext(),"lowStr") -# 1);
-	}; 
-$IF ($GET_CHAR_STR(tgt) <# 4 && $GET_COMBATANT_SA($TargetContext(),"lowStr") == "-?-?-")
-	{
-		$SET_COMBATANT_SA($TargetContext(),"lowStr",2);
-	}; 
-$SET_CHAR_STR(tgt,$GET_CHAR_STR(tgt) -# 1);
-$SET_CHAR_STRMOD(tgt,"");
-$IF ($GET_COMBATANT_SA($TargetContext(),"lowStr") == 0 || $GET_CHAR_HITPOINTS(tgt) <# 1)
-	{
-		$DELETE_CHARACTER_SA($TargetContext(),"IsDrainedStrength");
-		$SET_CHAR_HITPOINTS(tgt,"-10");
-		$RETURN $SET_CHAR_STATUS(tgt,5);
-	};
\(END)

\(BEGIN)
name = monster_ElementalGrowth
[DoesSpellAttackSucceed] = $VAR tgt;
-$VAR hp;
-$VAR name;
-$IF ($SA_SPELL_GET("DamageMagical") == $SA_PARAM_GET() || $SA_SPELL_GET("DamageNonMagical") == $SA_PARAM_GET())
-	{
-		tgt = $IndexOf($TargetContext());
-		hp = $RANDOM(8) +# 1;
-		name = $GET_CHAR_NAME(tgt);
-		$SET_CHAR_MAXHITPOINTS(tgt,$GET_CHAR_MAXHITPOINTS(tgt) +# hp);
-		$SET_CHAR_HITPOINTS(tgt,$GET_CHAR_HITPOINTS(tgt) +# hp);
-		$SET_CHAR_THAC0(tgt,$GET_CHAR_THAC0(tgt) -# 1);
-		$SET_MONSTERTYPE_SA(name,"monsterLevel", $GET_MONSTERTYPE_SA(name,"monsterLevel") +# 1);
-		$SET_HOOK_PARAM(5,name +" grows ");
-		$RETURN "N";
-	};
\(END)

\(BEGIN)
name = monster_ElementalImmunity
[DoesAttackSucceed] = $VAR element;
-element = $SA_PARAM_GET();
-$IF (element == $SA_SPELL_GET("DamageMagical") || element == $SA_SPELL_GET("DamageNonMagical"))
-	{
-		$SET_HOOK_PARAM(5,$GET_CHAR_NAME($IndexOf($TargetContext())) +" is unaffected.");
-		$RETURN "N";
-	};
[DoesSpellAttackSucceed] = $VAR element;
-element = $SA_PARAM_GET();
-$IF (element == $SA_SPELL_GET("DamageMagical") || element == $SA_SPELL_GET("DamageNonMagical"))
-	{
-		$SET_HOOK_PARAM(5,$GET_CHAR_NAME($IndexOf($TargetContext())) +" is unaffected.");
-		$RETURN "N";
-	};
\(END)

\(BEGIN)
name = monster_ElementalResistance
[CreateMonsterCombatant] = $SET_COMBATANT_SA($CharacterContext(),"monster_ElementalResistance",$SA_PARAM_GET());
[ComputeDamage] = $VAR element;
-element = $SA_ITEM_GET("DamageMagical");
-$IF (element == $SA_PARAM_GET()){$RETURN $GET_HOOK_PARAM(5) /# 2;};
[ComputeSpellDamage] = $VAR element;
-element = $SA_SPELL_GET("DamageMagical");
-$IF (element == $SA_PARAM_GET()){$RETURN $GET_HOOK_PARAM(5) /# 2;};
\(END)

\(BEGIN)
name = monster_ElementalSlowing
[GetAdjMaxMovement] = $VAR element;
-$VAR element2;
-element = $SA_ITEM_GET("DamageMagical");
-element2 = $SA_SPELL_GET("DamageMagical");
-$IF ((element == $SA_PARAM_GET()) || (element2 == $SA_PARAM_GET())){$RETURN $GET_HOOK_PARAM(5) /# 2;};
\(END)

\(BEGIN)
name = monster_ElementalVulnerability
[CreateMonsterCombatant] = $SET_COMBATANT_SA($CharacterContext(),"monster_ElementalVulnerability",$SA_PARAM_GET());
[ComputeDamage] = $VAR element;
-element = $SA_ITEM_GET("DamageMagical");
-$IF (element == $SA_PARAM_GET()){$RETURN $GET_HOOK_PARAM(5) *# 2;};
[ComputeSpellDamage] = $VAR element;
-element = $SA_SPELL_GET("DamageMagical");
-$IF (element == $SA_PARAM_GET()){$RETURN $GET_HOOK_PARAM(5) *# 2;};
\(END)

\(BEGIN)
name = monster_Engulf1
[InvokeSpellOnTarget] = $SET_COMBATANT_SA($AttackerContext(),"CombatRoundStart",1);
\(END)

\(BEGIN)
name = monster_Engulf2
[InvokeSpellOnTarget] = $VAR Atk;
-$VAR Tgt;
-$IF ($GET_COMBATANT_SA($AttackerContext(),"CombatRoundStart") ==# 1)
-	{
-		$IF ($GET_CHARACTER_SA($TargetContext(),"IsHugged") == "-?-?-")
-			{
-				Atk = $IndexOf($AttackerContext());
-				Tgt = $IndexOf($TargetContext());
-// Attacker
-				$SET_COMBATANT_SA($AttackerContext(),"HugLink",Tgt);
-				$SET_COMBATANT_SA($AttackerContext(),"monster_Engulfing",Tgt);
-				$SET_COMBATANT_SA($AttackerContext(),"IsHosed",$RANDOM(4) +# $RANDOM(4) +# 2);
-// Target
-				$SET_COMBATANT_SA($TargetContext(),"monster_Engulfed",Atk);
-				$SET_COMBATANT_SA($TargetContext(),"HugLink",Atk);
-				$SET_CHARACTER_SA($TargetContext(),"IsHugged",1);
-			};
-	};
\(END)

\(BEGIN)
name = monster_Engulfed
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Engulfed");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[OnStartCombatantAction] = $VAR Atk;
-Atk = $SA_PARAM_GET();
-$IF ($GET_CHAR_HITPOINTS(Atk) <# 1)
-	{
-		$DELETE_COMBATANT_SA($CombatantContext(),"HugLink");
-		$DELETE_CHARACTER_SA($CombatantContext(),"IsHugged");
-		$SA_REMOVE();
-	};
\(END)

\(BEGIN)
name = monster_Engulfing
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,"Engulfing");
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[GetAdjMaxMovement] = $RETURN 0;
[GetNumberOfAttacks] = $RETURN 0;
[OnStartCombatantAction] = $VAR Tgt;
-$VAR name;
-$VAR count;
-Tgt = $SA_PARAM_GET();
-$IF ($GET_CHAR_HITPOINTS(Tgt) ># 0)
-	{
-		count = $GET_COMBATANT_SA($CombatantContext(),"IsHosed") -#1;
-		$SET_COMBATANT_SA($CombatantContext(),"IsHosed",count);
-		$IF (count <=# 0)
-			{
-// Target
-				$SET_CHAR_STATUS(Tgt,2);
-				$SET_CHAR_HITPOINTS(Tgt,0);
-			};
-	};
-$IF ($GET_CHAR_HITPOINTS(Tgt) <# 1)
-	{
-// Attacker
-		$DELETE_COMBATANT_SA($CombatantContext(),"monster_Engulfing");
-		$DELETE_COMBATANT_SA($CombatantContext(),"IsHosed");
-	};
\(END)

\(BEGIN)
name = monster_FireBatAttack
[InvokeSpellOnTarget] = $VAR Atk;
-$VAR Tgt;
-$VAR link;
-Atk = $IndexOf($AttackerContext());
-Tgt = $IndexOf($TargetContext());
-// Attacker
-$SET_COMBATANT_SA($AttackerContext(),"monster_FireBatDrain","");
-$IF ($GET_COMBATANT_SA($AttackerContext(),"monster_FireBatBloodCap") == "-?-?-")
-	{
-		$SET_COMBATANT_SA($AttackerContext(),"monster_FireBatBloodCap",3);
-	};
-$SET_COMBATANT_SA($AttackerContext(),"monster_FireBatLink",Tgt);
-// Target
-$SET_COMBATANT_SA($TargetContext(),"monster_FireBatDrainee","");
-$SET_CHARACTER_SA($TargetContext(),"IsHugged",1);
-// Link
-link = $GET_COMBATANT_SA($TargetContext(),"monster_FireBatLink");
-$IF (link == "-?-?-")
-	{
-		$SET_COMBATANT_SA($TargetContext(),"monster_FireBatLink","$255$" + Atk);
-	}
-$ELSE
-	{
-		link = link + "$" + Atk;
-		$SET_COMBATANT_SA($TargetContext(),"monster_FireBatLink",link);
-	};
\(END)

\(BEGIN)
name = monster_FireBatDrain
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[GetAdjMaxMovement] = $RETURN 0;
[GetNumberOfAttacks] = $RETURN 0;
[OnStartCombatantAction] = $VAR Tgt;
-$VAR name;
-$VAR cap;
-$VAR dmg;
-// Test Target and Compute & Apply Drain
-Tgt = $GET_COMBATANT_SA($CombatantContext(),"monster_FireBatLink");
-name = $GET_CHAR_NAME(Tgt);
-$IF ($GET_CHAR_STATUS(Tgt) ==# 0) 
-	{
-		cap = $GET_COMBATANT_SA($CombatantContext(),"monster_FireBatBloodCap");
-		dmg = $RANDOM(4) +# 1;
-		cap = cap -# 1;
-		$SET_COMBATANT_SA($CombatantContext(),"monster_FireBatBloodCap",cap);
-		$SET_CHAR_HITPOINTS(Tgt, $GET_CHAR_HITPOINTS(Tgt) -# dmg);
-// Is Target Dead?
-		$IF ($GET_CHAR_HITPOINTS(Tgt) <# 1)
-			{
-// Target
-				$SET_CHAR_STATUS(Tgt,1);
-// Attacker
-				$DELETE_COMBATANT_SA($CombatantContext(),"monster_FireBatDrain");
-				$DELETE_COMBATANT_SA($CombatantContext(),"monster_FireBatLink");
-			};
-// Am I Full?
-		$IF (cap <# 1)
-			{
-				$SET_CHAR_STATUS($MyIndex(),8);
-				$DELETE_COMBATANT_SA($CombatantContext(),"monster_FireBatDrain");
-				$DELETE_COMBATANT_SA($CombatantContext(),"monster_FireBatLink");
-				$SET_COMBATANT_SA($CombatantContext(),"IsFleeing","Fleeing Fire Bat");
-// Target
-				$DELETE_CHARACTER_SA($Name(name),"IsHugged");
-			};
-	}
-$ELSE
-	{
-// Someone Else Killed It
-// Attacker
-		$DELETE_COMBATANT_SA($CombatantContext(),"monster_FireBatDrain");
-		$DELETE_COMBATANT_SA($CombatantContext(),"monster_FireBatLink");
-	};
\(END)

\(BEGIN)
name = monster_FireBatDrainee
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[OnStartCombatantAction] = $VAR Atk;
-$VAR i;
-$VAR foes;
-$VAR alive;
-foes = $GET_COMBATANT_SA($Myself(),"monster_FireBatLink");
-i = 1;
-alive = "-1";
-Atk = $DelimitedStringSubstring(foes, i);
-$WHILE (Atk != "")
-	{
-		Atk = $DelimitedStringSubstring(foes, i);
-		$IF ($GET_CHAR_STATUS(Atk) ==# 0){alive = alive +# 1;};
-		i = i +# 1;
-	};
-// alive = alive -# 1;
-$IF (alive <# 1)
-	{
-		$DELETE_COMBATANT_SA($CombatantContext(),"monster_FireBatDrainee");
-		$DELETE_COMBATANT_SA($CombatantContext(),"monster_FireBatLink");
-		$DELETE_CHARACTER_SA($Myself(),"IsHugged");
-	};
\(END)

\(BEGIN)
name = monster_GiantSlugSpit
[CheckProximity] = $VAR target;
-$VAR myself;
-$VAR range;
-$VAR distance;
-target = $GET_HOOK_PARAM(6);
-myself = $GET_HOOK_PARAM(5);
-range = $SA_PARAM_GET();
-distance = $VisualDistance(target, myself);
-$SA_PARAM_SET(distance);
[DoesAttackSucceed] = $VAR random;
-$VAR distance;
-random = $RANDOM(100);
-distance = $SA_PARAM_GET();
-$IF ($GetCombatRound() ==# 1)
-	{
-		$IF (random <# 10){$RETURN "Y";}
-		$ELSE{$RETURN "N";};
-	};
-$IF (random <# 110 -# (10 *# distance)){$RETURN "Y";}
-$ELSE{$RETURN "N";};
\(END)

\(BEGIN)
name = monster_GiantWeaselAttack
[InvokeSpellOnTarget] = $VAR Atk;
-$VAR Tgt;
-$VAR link;
-Atk = $IndexOf($AttackerContext());
-Tgt = $IndexOf($TargetContext());
-// Attacker
-$SET_COMBATANT_SA($AttackerContext(),"monster_GiantWeaselDrain","");
-$SET_COMBATANT_SA($AttackerContext(),"monster_GiantWeaselLink",Tgt);
-// Target
-$SET_COMBATANT_SA($TargetContext(),"monster_GiantWeaselDrainee","");
-$SET_CHARACTER_SA($TargetContext(),"IsHugged",1);
-// Link
-link = $GET_COMBATANT_SA($TargetContext(),"monster_GiantWeaselLink");
-$IF (link == "-?-?-")
-	{
-		$SET_COMBATANT_SA($TargetContext(),"monster_GiantWeaselLink","$255$" + Atk);
-	}
-$ELSE
-	{
-		link = link + "$" + Atk;
-		$SET_COMBATANT_SA($TargetContext(),"monster_GiantWeaselLink",link);
-	};
\(END)

\(BEGIN)
name = monster_GiantWeaselDrain
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[GetAdjMaxMovement] = $RETURN 0;
[GetNumberOfAttacks] = $RETURN 0;
[OnStartCombatantAction] = $VAR Tgt;
-$VAR name;
-$VAR dmg;
-// Test Target and Compute & Apply Drain
-Tgt = $GET_COMBATANT_SA($CombatantContext(),"monster_GiantWeaselLink");
-name = $GET_CHAR_NAME(Tgt);
-$IF ($GET_CHAR_STATUS(Tgt) ==# 0) 
-	{
-		dmg = ($RANDOM(6) +# 1) +# ($RANDOM(6) +# 1);
-		$SET_CHAR_HITPOINTS(Tgt, $GET_CHAR_HITPOINTS(Tgt) -# dmg);
-// Is Target Dead?
-		$IF ($GET_CHAR_HITPOINTS(Tgt) <# 1)
-			{
-// Target
-				$SET_CHAR_STATUS(Tgt,1);
-// Attacker
-				$DELETE_COMBATANT_SA($CombatantContext(),"monster_GiantWeaselDrain");
-				$DELETE_COMBATANT_SA($CombatantContext(),"monster_GiantWeaselLink");
-			};
-	}
-$ELSE
-	{
-// Someone Else Killed It
-// Attacker
-		$DELETE_COMBATANT_SA($CombatantContext(),"monster_GiantWeaselDrain");
-		$DELETE_COMBATANT_SA($CombatantContext(),"monster_GiantWeaselLink");
-	};
\(END)

\(BEGIN)
name = monster_GiantWeaselDrainee
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[OnStartCombatantAction] = $VAR Atk;
-$VAR i;
-$VAR foes;
-$VAR alive;
-foes = $GET_COMBATANT_SA($Myself(),"monster_GiantWeaselLink");
-i = 1;
-alive = "-1";
-Atk = $DelimitedStringSubstring(foes, i);
-$WHILE (Atk != "")
-	{
-		Atk = $DelimitedStringSubstring(foes, i);
-		$IF ($GET_CHAR_STATUS(Atk) ==# 0){alive = alive +# 1;};
-		i = i +# 1;
-	};
-// alive = alive -# 1;
-$IF (alive <# 1)
-	{
-		$DELETE_COMBATANT_SA($CombatantContext(),"monster_GiantWeaselDrainee");
-		$DELETE_COMBATANT_SA($CombatantContext(),"monster_GiantWeaselLink");
-		$DELETE_CHARACTER_SA($Myself(),"IsHugged");
-	};
\(END)

\(BEGIN)
name = monster_HellHoundAttack
[StartCombatRound] = $GIVE_CHAR_ITEM( $Myself(), "monsterHellHoundBreath" );
\(END)

\(BEGIN)
name = monster_ImmuneCharm
\(END)

\(BEGIN)
name = monster_ImmuneFear
\(END)

\(BEGIN)
name = monster_ImmuneHold
\(END)

\(BEGIN)
name = monster_ImmunePoison
[InvokeSpellOnTarget] = $SET_CHARACTER_SA($CharacterContext(),"IsImmunePoison","");
\(END)

\(BEGIN)
name = monster_ImmuneSleep
\(END)

\(BEGIN)
name = monster_ImmuneSpellsGreenSlime
[ComputeDamage] = $IF (($SA_SPELL_GET("DamageMagical") != "cold") || ($SA_SPELL_GET("DamageMagical") != "fire")){ $RETURN "0";};
\(END)

\(BEGIN)
name = monster_ImmuneSpellsIronGolem
[DoesAttackSucceed] = $IF ($SA_SPELL_GET("DamageMagical") != "=?-?-"){$RETURN "N";};
\(END)

\(BEGIN)
name = monster_MummyFear
[CheckProximity] = $VAR target;
-$VAR myself;
-$VAR range;
-$VAR distance;
-$VAR saveVsSpell;
-$VAR roll;
-$IF ($GET_CHAR_NAME($MyIndex()) == "Mummy"){$RETURN;};
-$IF ($SA_COMBATANT_GET("IsMummyFear") != "-?-?-") {$RETURN;};
-$IF ($SA_COMBATANT_GET("IsMummyFlee") != "-?-?-") {$RETURN;};
-target = $GET_HOOK_PARAM(5);
-myself = $GET_HOOK_PARAM(6);
-range = $SA_PARAM_GET();
-distance = $VisualDistance(target, myself);
-$IF (range <# distance) {$RETURN;};
-$IF ($SA_COMBATANT_GET("ImmuneIsMummyFear") != "-?-?-") {$RETURN;};
-saveVsSpell = $GET_CHAR_SAVEVSSP(target);
-roll = $RANDOM(20) +# 1;
-$IF (saveVsSpell ># roll)
-	{
-		roll = $RANDOM(2);
-		$IF (roll){$SET_COMBATANT_SA($TargetContext(),"IsMummyFlee", "$IndexOf($CombatantContext())");}
-		$ELSE{$SET_COMBATANT_SA($TargetContext(),"IsMummyFear","Paralyzed by Mummy Fear");};
-	}
-$ELSE{$SET_COMBATANT_SA($TargetContext(),"ImmuneMummyFear", 4);};
\(END)

\(BEGIN)
name = monster_PlayerControl
[AutoAction] = $RETURN "CP";
\(END)

\(BEGIN)
name = monster_Poison
[InvokeSpellOnTarget] = $VAR time;
-time = $GET_PARTY_TIME();
-$IF ($SA_CHARACTER_GET("IsImmunePoison") != "-?-?-"){$RETURN;};
-$IF ($SA_CHARACTER_GET("IsProtectedPoisonCaster") != "-?-?-"){$RETURN;};
-$IF ($SA_CHARACTER_GET("IsProtectedPoisonTarget") != "-?-?-"){$RETURN;};
-$SET_CHARACTER_SA($TargetContext(),"IsPoisoned",time);
-$SET_CHAR_STATUS($IndexOf($TargetContext()),2);
-$SET_CHAR_HITPOINTS($IndexOf($TargetContext()),"-11");
\(END)

\(BEGIN)
name = monster_Ranger
[ComputeDamage] = $VAR rangerLvl;
-rangerLvl = $GET_COMBATANT_SA($Myself(),"monsterLevel");
-$IF ($GET_ISGIANT($TargetContext()) != "0"){$RETURN $GET_HOOK_PARAM(5) +# rangerLvl;};
\(END)

\(BEGIN)
name = monster_RearClawRake1
[InvokeSpellOnTarget] = $SET_COMBATANT_SA($AttackerContext(),"CombatRoundStart",1);
\(END)

\(BEGIN)
name = monster_RearClawRake2
[InvokeSpellOnTarget] = $VAR Atk;
-$VAR Tgt;
-$VAR name;
-$VAR dmg;
-$VAR i;
-$VAR AC;
-$VAR TH;
-Atk = $IndexOf($AttackerContext());
-Tgt = $IndexOf($TargetContext());
-$IF ($GET_CHAR_HITPOINTS(Tgt) <# 1) {$RETURN;};
-$IF ($GET_COMBATANT_SA($AttackerContext(),"CombatRoundStart") ==# 1)
-	{
- 		i = 0;
-		AC = $GET_CHAR_AC(Tgt);
-		TH = $GET_CHAR_THAC0(Atk);
-		$WHILE (i <# 2)
-			{
-				$IF($RANDOM(20) +# 1 >=# TH -# AC)
-					{
-						name = $GET_CHAR_NAME(Atk);
-						$IF (name == "Giant Lynx"){dmg = ($RANDOM(3) +# 1);};
-						$IF (name == "Leopard"||name == "Mountain Lion"){dmg = ($RANDOM(4) +# 1);};
-						$IF (name == "Jaguar"||name == "Weretiger"){dmg = ($RANDOM(4) +# 2);};
-						$IF (name == "Lion"){dmg = ($RANDOM(6) +# 2);};
-						$IF (name == "Spotted Lion"||name == "Tiger"||name == "Sabre-tooth Tiger"){dmg = ($RANDOM(4) +# $RANDOM(4) +# 2);};
-						$SET_CHAR_HITPOINTS(Tgt,$GET_CHAR_HITPOINTS(Tgt) -# dmg);
-					};
-				i = i +# 1;
-			};
-		$IF ($GET_CHAR_HITPOINTS(Tgt) <# 1)
-			{
-				$IF ($GET_CHAR_HITPOINTS(Tgt) <# "-9"){$SET_CHAR_STATUS(Tgt,2);}
-				$ELSE{$SET_CHAR_STATUS(Tgt,9);};
-			};
-	};
\(END)

\(BEGIN)
name = monster_Regeneration
[StartCombatRound] = $SET_CHAR_HITPOINTS($IndexOf($CharacterContext()), ($GET_CHAR_HITPOINTS($IndexOf($CharacterContext())) +# $SA_PARAM_GET()));
\(END)

\(BEGIN)
name = monster_Revulsion
[CheckProximity] = $VAR target;
-$VAR myself;
-$VAR range;
-$VAR distance;
-$VAR saveVsPoison;
-$VAR roll;
-$IF ($GET_CHAR_NAME($MyIndex()) == "Troglodyte"){$RETURN;};
-$IF ($SA_COMBATANT_GET("ImmuneRevulsion") != "-?-?-"){$RETURN;};
-target = $GET_HOOK_PARAM(5);
-myself = $GET_HOOK_PARAM(6);
-range = $SA_PARAM_GET();
-distance = $VisualDistance(target, myself);
-$IF (range <# distance) {$RETURN;};
-saveVsPoison = $GET_CHAR_SAVEVSPPDM(target);
-roll = $RANDOM(20) +# 1;
-$IF (saveVsPoison ># roll){$SET_CHAR_THAC0(target,($GET_CHAR_THAC0(target) +# 2));}
-$ELSE{$SET_COMBATANT_SA($CombatantContext(), "ImmuneRevulsion", 4);};
\(END)

\(BEGIN)
name = monster_SlimeWeakness
\(END)

\(BEGIN)
name = monster_SpellcasterLevel
[SpellCasterLevel] = $RETURN $GET_COMBATANT_SA($AttackerContext(), "monsterLevel");
\(END)

\(BEGIN)
name = monster_SpellImmunity
Parameters = "parameter is delimited string";
\(END)

\(BEGIN)
name = monster_StirgeAttack
[InvokeSpellOnTarget] = $VAR Atk;
-$VAR Tgt;
-$VAR link;
-Atk = $IndexOf($AttackerContext());
-Tgt = $IndexOf($TargetContext());
-// Attacker
-$SET_COMBATANT_SA($AttackerContext(),"monster_StirgeDrain","");
-$IF ($GET_COMBATANT_SA($AttackerContext(),"monster_StirgeBloodCap") == "-?-?-")
-  {
-    $SET_COMBATANT_SA($AttackerContext(),"monster_StirgeBloodCap",12);
-  };
-$SET_COMBATANT_SA($AttackerContext(),"monster_StirgeLink",Tgt);
-// Target
-$SET_COMBATANT_SA($TargetContext(),"monster_StirgeDrainee","");
-$SET_CHARACTER_SA($TargetContext(),"IsHugged",1);
-// Link
-link = $GET_COMBATANT_SA($TargetContext(),"monster_StirgeLink");
-$IF (link == "-?-?-")
-  {
-    $SET_COMBATANT_SA($TargetContext(),"monster_StirgeLink","$255$" + Atk);
-  }
-$ELSE
-  {
-    link = link + "$" + Atk;
-    $SET_COMBATANT_SA($TargetContext(),"monster_StirgeLink",link);
-  };
\(END)

\(BEGIN)
name = monster_StirgeDrain
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[GetAdjMaxMovement] = $RETURN 0;
[GetNumberOfAttacks] = $RETURN 0;
[OnStartCombatantAction] = $VAR Tgt;
-$VAR name;
-$VAR cap;
-$VAR dmg;
-// Test Target and Compute & Apply Drain
-Tgt = $GET_COMBATANT_SA($CombatantContext(),"monster_StirgeLink");
-name = $GET_CHAR_NAME(Tgt);
-$IF ($GET_CHAR_STATUS(Tgt) ==# 0) 
-  {
-    cap = $GET_COMBATANT_SA($CombatantContext(),"monster_StirgeBloodCap");
-    dmg = $RANDOM(4) +# 1;
-    $IF (cap <# dmg) {dmg = cap;};
-    cap = cap -# dmg;
-    $SET_COMBATANT_SA($CombatantContext(),"monster_StirgeBloodCap",cap);
-    $SET_CHAR_HITPOINTS(Tgt, $GET_CHAR_HITPOINTS(Tgt) -# dmg);
-// Is Target Dead?
-    $IF ($GET_CHAR_HITPOINTS(Tgt) <# 1)
-      {
-// Target
-        $SET_CHAR_STATUS(Tgt,1);
-// Attacker
-        $DELETE_COMBATANT_SA($CombatantContext(),"monster_StirgeDrain");
-        $DELETE_COMBATANT_SA($CombatantContext(),"monster_StirgeLink");
-      };
-// Am I Full?
-    $IF (cap <# 1)
-      {
-        $SET_CHAR_STATUS($MyIndex(),8);
-        $DELETE_COMBATANT_SA($CombatantContext(),"monster_StirgeDrain");
-        $DELETE_COMBATANT_SA($CombatantContext(),"monster_StirgeLink");
-        $SET_COMBATANT_SA($CombatantContext(),"IsFleeing","Fleeing Stirge");
-// Target
-        $DELETE_CHARACTER_SA($Name(name),"IsHugged");
-      };
-  }
-$ELSE
-  {
-// Someone Else Killed It
-// Attacker
-    $DELETE_COMBATANT_SA($CombatantContext(),"monster_StirgeDrain");
-    $DELETE_COMBATANT_SA($CombatantContext(),"monster_StirgeLink");
-  };
\(END)

\(BEGIN)
name = monster_StirgeDrainee
[CharDisplayStatus] = $SET_HOOK_PARAM( 7,$SA_PARAM_GET());
-$SET_HOOK_PARAM( 6,"");
-$RETURN 1;
[OnStartCombatantAction] = $VAR Atk;
-$VAR i;
-$VAR foes;
-$VAR alive;
-foes = $GET_COMBATANT_SA($Myself(),"monster_StirgeLink");
-i = 1;
-alive = "-1";
-Atk = $DelimitedStringSubstring(foes, i);
-$WHILE (Atk != "")
-	{
-		Atk = $DelimitedStringSubstring(foes, i);
-		$IF ($GET_CHAR_STATUS(Atk) ==# 0){alive = alive +# 1;};
-		i = i +# 1;
-	};
-// alive = alive -# 1;
-$IF (alive <# 1)
-	{
-		$DELETE_COMBATANT_SA($CombatantContext(),"monster_StirgeDrainee");
-		$DELETE_COMBATANT_SA($CombatantContext(),"monster_StirgeLink");
-		$DELETE_CHARACTER_SA($Myself(),"IsHugged");
-	};
\(END)

\(BEGIN)
name = monster_SummonSlaad
[StartCombatRound] = $VAR round;
-round = $GetCombatRound();
-$IF (round ==# 3) {$AddCombatant("Red Slaad","1");};
\(END)

\(BEGIN)
name = monster_TrollGetUp
[StartCombatRound] = $VAR cbt; // combatant
-$VAR hp; // hit points
-$VAR round;
-$VAR getUp;
-$VAR name;
-$VAR nt;
-$VAR x;
-$VAR y;
-$VAR mhp; // max hit point
-$VAR i;
-$VAR n;
-cbt = $SA_PARAM_GET();
-hp = $GET_CHAR_HITPOINTS(cbt);
-$IF (hp <=# 0)
-  {
-    name = $GET_CHAR_NAME(cbt);
-    round = $GetCombatRound();
-    $IF ($GET_COMBATANT_SA($CombatantContext(),"timeToRise") == "-?-?-")
-      {
-        getUp = ($RANDOM(6) +# $RANDOM(6) +# $RANDOM(6) +# 3);
-        $SET_COMBATANT_SA($CombatantContext(),"timeToRise", round +# getUp);
-      };
-    $IF (round ==# ($SA_COMBATANT_GET("timeToRise")))
-      {
-        i = $NextCreatureIndex("",0);
-        $WHILE (i != "")
-          {
-            n = i;
-            i = $NextCreatureIndex(i,0);
-          };
-        nt = n +# 1;
-        x = $CombatantLocation(cbt,"X");
-        y = $CombatantLocation(cbt,"Y");
-        mhp = $GET_CHAR_MAXHITPOINTS(cbt);
-        $AddCombatant(name,0);
-        $TeleportCombatant(nt,x,y);
-        $SET_CHAR_MAXHITPOINTS(nt,mhp); 
-        $SET_CHAR_HITPOINTS(nt,mhp);
-      };
-  };
\(END)

\(BEGIN)
name = monster_TrollRegeneration
[StartCombatRound] = $VAR target;
-$VAR currHP;
-$VAR round;
-target = $IndexOf($Myself());
-currHP = $GET_CHAR_HITPOINTS(target);
-round = $GetCombatRound();
-$IF (currHP <# 42)
-  {
-    $IF ($SA_COMBATANT_GET("timeToRegen") == "-?-?-")
-      {
-        $SET_COMBATANT_SA($Myself(),"timeToRegen",round +# 3);
-      };
-  };
-$IF (round ==# $SA_COMBATANT_GET("timeToRegen"))
-  {
-    $RETURN $SET_COMBATANT_SA($Myself(),"monster_Regeneration",$SA_PARAM_GET());
-  };
\(END)

\(BEGIN)
name = monster_VulnerableToHolyWater
[ComputeDamage] = $VAR vulnHolyWater;
-vulnHolyWater = $SA_ITEM_GET("item_HolyWater");
-$IF (vulnHolyWater >=# 0){$RETURN $RANDOM(4) +# $RANDOM(4) +# 2;};
\(END)

\(BEGIN)
name = monster_WeaponDamageOnlyOne
[ComputeDamage] = $VAR oneDamage;
-oneDamage = $SA_ITEM_GET("item_MagicalWespon");
-$IF (oneDamage >=# 3){$RETURN "1";};
\(END)

\(BEGIN)
name = monster_WeaponImmunity
[DoesAttackSucceed] = $VAR item;
-item = $SA_ITEM_GET("item_MagicalWeapon");
-$IF ($GET_CHAR_TYPE($IndexOf($AttackerContext())) ==# 3){$RETURN;};
-$IF (item == "-?-?-"){$RETURN "N";};
-$IF (item <# $SA_PARAM_GET()){$RETURN "N";};
\(END)

\(BEGIN)
name = monster_WeaponImmunityType
[DoesAttackSucceed] = $VAR item;
-item = $SA_ITEM_GET("item_WeaponType");
-$IF (item ==# $SA_PARAM_GET()){$RETURN "N";};
\(END)

\(BEGIN)
name = monster_WeaponResistance
[CreateMonsterCombatant] = $SET_COMBATANT_SA($CharacterContext(),"monster_WeaponResistance",$SA_PARAM_GET());
[ComputeDamage] = $VAR item;
-item = $SA_ITEM_GET("item_MagicalWeapon");
-$IF ($GET_CHAR_TYPE($IndexOf($AttackerContext())) ==# 3){$RETURN;};
-$IF (item == "-?-?-")
-	{
-		$IF (item <# $SA_PARAM_GET()){$RETURN $GET_HOOK_PARAM(5) /# 2;};
-	};
\(END)

\(BEGIN)
name = monster_WeaponResistanceType
[CreateMonsterCombatant] = $SET_COMBATANT_SA($CharacterContext(),"monster_WeaponResistanceType",$SA_PARAM_GET());
[ComputeDamage] = $VAR weapon;
-weapon = $SA_ITEM_GET("item_WeaponType");
-$IF (weapon == $SA_PARAM_GET()){$RETURN $GET_HOOK_PARAM(5) /# 2;};
\(END)

\(BEGIN)
name = race_Elf
[DoesAttackSucceed] = $VAR heldItem;
-$VAR elfItem;
-heldItem = $GET_CHAR_Ready($Myself(), "WEAPON", 0);
-elfItem = $SA_ITEM_GET("item_ElfBonus");
-$IF (elfItem != "-?-?-")
-	{
-		$IF(heldItem == elfItem)
-			{
-				$RETURN $SET_CHAR_THAC0($MyIndex(),$GET_HOOK_PARAM(6) -# 1)
-			};
-	};
[PostCreateCharacter] = $SET_CHARACTER_SA($CharacterContext(),"IsCharmResistant","Elf");
-$SET_CHARACTER_SA($CharacterContext(),"IsSleepResistant","Elf");
\(END)

\(BEGIN)
name = race_HalfElf
[PostCreateCharacter] = $SET_CHARACTER_SA($CharacterContext(),"IsCharmResistantMin","Half-Elf");
-$SET_CHARACTER_SA($CharacterContext(),"IsSleepResistantMin","Half-Elf");
\(END)

\(BEGIN)
name = race_ShortSaveBonus
[CreateMonsterCombatant] = $VAR me;
-me = $IndexOf($CharacterContext());
-$IF ($GET_CHAR_CON(me) <# $SA_PARAM_GET())
-	{
-		$SET_CHAR_CON(me,$SA_PARAM_GET());
-	};
-$SET_CHARACTER_SA($CharacterContext(),"IsShortSaveBonus",($GET_CHAR_CON(me) *# -2) /# 7);
[PostCreateCharacter] = $SET_CHARACTER_SA($CharacterContext(),"IsShortSaveBonus",($GET_CHAR_CON($IndexOf($CharacterContext())) *# -2) /# 7);
\(END)

\(BEGIN)
name = rangeGhast
[IsCombatReady] = $IF ($GET_HASPOISONIMMUNITY($CharacterContext()) != 1 && $GET_CHARACTER_SA($CharacterContext(),"IsImmunePoison") == "-?-?-")
-	{
-		$CastSpellOnTarget($CharacterContext(),"CarrionStench");
-	};
-$SA_REMOVE();
\(END)

\(BEGIN)
name = SaveAdjPPDM
[SaveVsPPDM_Save] = $VAR adj;
-adj = $SA_PARAM_GET();
-$SA_REMOVE();
-$RETURN $GET_HOOK_PARAM(0) +# adj;
\(END)

\(BEGIN)
name = SaveAdjSpell
[SaveVsSp_Save] = $VAR adj;
-adj = $SA_PARAM_GET();
-$SA_REMOVE();
-$RETURN $GET_HOOK_PARAM(0) +# adj;
\(END)

\(BEGIN)
name = spell_Attack
[InvokeSpellOnTarget] = $IF ($GET_COMBATANT_SA($AttackerContext(),"IsInvisible"))
-	{
-		$DELETE_CHARACTER_SA($Myself(),"IsInvisible");
-		$DELETE_COMBATANT_SA($Myself(),"IsInvisible");
-	};
\(END)

\(BEGIN)
name = spell_Barkskin
[InvokeSpellOnTarget] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger") {lvl = lvl -# 7;};
-$SET_CHARACTER_SA($TargetContext(),"IsBarkskinned",$GET_PARTY_TIME() +# lvl +# 4);
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger") {lvl = lvl -# 7;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_Bless
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR mySide;
-mySide = $GET_COMBATANT_SA($AttackerContext(),"side");
-$IF (mySide != "-?-?-")
-	{
-		$IF (mySide !=# $GET_COMBATANT_SA($TargetContext(),"side")){$RETURN;};
-		$IF ($VisualDistance($IndexOf($TargetContext()),$IndexOf($NEAREST_ENEMY_TO($TargetContext()))) <# 2){$RETURN;};
-		$SET_CHARACTER_SA($TargetContext(),"IsBlessed",$GET_PARTY_TIME() +# 6);
-		$SET_COMBATANT_SA($TargetContext(),"IsBlessed1",1);
-	}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"IsBlessed",$GET_PARTY_TIME() +# 6);};
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "paladin"){lvl = lvl -# 8;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_Blind
[InvokeSpellOnTarget] = $IF ($GET_CHARACTER_SA($TargetContext(),"saved"))
-  {$RETURN;};
-$IF ($RANDOM(20) +# 1 <# $GET_CHAR_THAC0($IndexOf($AttackerContext())) -# $GET_CHAR_AC($IndexOf($TargetContext())))
-  {$RETURN;};
-$SET_CHARACTER_SA($TargetContext(),"IsBlind","Blind");
\(END)

\(BEGIN)
name = spell_Blink
[InvokeSpellOnTarget] = $VAR lvl;
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),"magicUser");
-$SET_CHARACTER_SA($AttackerContext(),"IsBlinking",$GET_PARTY_TIME() +# lvl);
-$IF ($GET_COMBATANT_SA($AttackerContext(),"side") != "-?-?-")
-	{
-		$SET_COMBATANT_SA($AttackerContext(),"IsBlinking1",1);
-		$SET_COMBATANT_SA($AttackerContext(),"IsBlinking2",1);
-	};
\(END)

\(BEGIN)
name = spell_BurningHandsRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_CauseDisease
[InvokeSpellOnTarget] = $VAR tgt;
-$VAR minhp;
-tgt = $IndexOf($TargetContext());
-$IF ($GET_CHARACTER_SA($TargetContext(),"IsImmuneDisease") != "-?-?-"){$RETURN;};
-$IF ($GET_CHARACTER_SA($TargetContext(),"saved")){$RETURN;};
-$IF ($RANDOM(20) +# 1 <# $GET_CHAR_THAC0($IndexOf($AttackerContext())) -# $GET_CHAR_AC(tgt))
-  {$RETURN;};
-$SET_CHARACTER_SA($TargetContext(),"str",$GET_CHAR_STR(tgt));
-$SET_CHARACTER_SA($TargetContext(),"strmod",$GET_CHAR_STRMOD(tgt));
-minhp = $GET_CHAR_MAXHITPOINTS(tgt) /# 10;
-$IF (minhp <# 1){minhp = 1;};
-$SET_CHARACTER_SA($TargetContext(),"minhp",minhp);
-$SET_CHARACTER_SA($TargetContext(),"IsDiseasedSpell",$GET_PARTY_TIME() +# (($RANDOM(6) +# 1) *# 10));
\(END)

\(BEGIN)
name = spell_Charm
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR classList;
-$VAR classCount;
-$VAR canBeCharmed;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-$IF ($SA_COMBATANT_GET("monster_ImmuneCharm") != "-?-?-"){$RETURN;};
-$IF($GET_CANBEHELDORCHARMED($TargetContext()) == ""){$RETURN;};
-$IF ($GET_MONSTERTYPE_SA($IndexOf($TargetContext()),"IsPerson") != "-?-?-"){$RETURN;};
-$SET_COMBATANT_SA($CombatantContext(),"IsCharmed","Charmed");
-classList = "$0$1$2$3$4$5$6$7$8$9$10$11$12$13$14$15$16$17$18";
-classCount = $DelimitedStringCount(classList);
-$WHILE (classCount >=# 0)
-	{
-		canBeCharmed = $DelimitedStringSubstring(classList,classCount);
-		$IF (canBeCharmed != $GET_CHAR_CLASS($MyIndex())){$RETURN;};
-		classCount = classCount -# 1;
-	};
-$SET_COMBATANT_SA($TargetContext(),"IsCharmed", "Charmed");
-$SetFriendly($IndexOf($TargetContext()), 1);
\(END)

\(BEGIN)
name = spell_CharmMonster
[InvokeSpellOnTarget] = $VAR side;  //caster's side
-$VAR tgt;
-$VAR name;  //target name
-$VAR clvl;  //caster level
-$VAR lvl;   //target level
-$VAR tlvl;  //temporary target level
-$VAR bclass;
-$VAR cls;
-$VAR index;
-$VAR i;
-$VAR opr;   //once per round
-$VAR rnd;
-$VAR tgtnum;//target number
-opr = $GET_COMBATANT_SA($AttackerContext(),"CombatRoundStart");
-$IF (opr == "-?-?-"||opr == 0)
-	{
-		$SET_COMBATANT_SA($AttackerContext(),"CombatRoundStart",5);
-		$SET_COMBATANT_SA($AttackerContext(),"tgtnum",0);
-		$SET_COMBATANT_SA($AttackerContext(),"PointPool",$RANDOM(4) +# $RANDOM(4) +# 2);
-	};
-rnd = $GET_COMBATANT_SA($AttackerContext(), "PointPool");
-$IF (rnd <# 1) {$RETURN;};
-clvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),"magicUser");
-side = $GET_COMBATANT_SA($AttackerContext(), "side");
-tgt = $IndexOf($TargetContext());
-name = $GET_CHAR_NAME(tgt);
-tlvl = $GET_MONSTERTYPE_SA(name,"monsterLevel");
-$IF (tlvl != "-?-?-") {lvl = tlvl;}
-$ELSE
-	{
-		lvl = 0;
-		i = 0;
-		bclass = "$fighter$cleric$ranger$paladin$magicUser$thief$druid";
-		cls = 0;
-		$WHILE (cls != "")
-			{
-				cls = $DelimitedStringSubstring(bclass,i);
-				tlvl = $GET_CHAR_Lvl(index,cls);
-				$IF (tlvl ># lvl) {lvl = tlvl;};
-				i = i +# 1;
-			};
-	};
-$SET_COMBATANT_SA($AttackerContext(), "tgtnum",$GET_COMBATANT_SA($AttackerContext(),"tgtnum") +# 1);
-tgtnum = $GET_COMBATANT_SA($AttackerContext(),"tgtnum");
-$IF (tgtnum)
-	{
-		$IF (lvl ># 3)
-			{
-				$SET_COMBATANT_SA($AttackerContext(),"PointPool",0);
-				$IF ($GET_CANBEHELDORCHARMED($TargetContext()) != 1) {$RETURN;};
-				$IF ($GET_CHARACTER_SA($TargetContext(),"saved" )) {$RETURN;};
-				$SetFriendly(tgt,side);
-				$SET_COMBATANT_SA($TargetContext(),"IsCharmed",clvl);
-				$RETURN;
-			};
-	};
-$IF (lvl ># rnd) {$RETURN;}
-$ELSE
-	{
-		$SET_COMBATANT_SA($AttackerContext(),"PointPool",rnd -# lvl);
-		$IF ($GET_CANBEHELDORCHARMED($TargetContext()) != 1) {$RETURN;};
-		$IF ($GET_CHARACTER_SA($TargetContext(),"saved" )) {$RETURN;};
-		$SetFriendly(tgt,side);
-		$SET_COMBATANT_SA($TargetContext(),"IsCharmed",clvl);
-	};
\(END)

\(BEGIN)
name = spell_CharmPerson
[InvokeSpellOnTarget] = $VAR cls;
-$VAR lvl;
-$VAR tgt;
-$VAR name;
-tgt = $IndexOf($TargetContext());
-name = $GET_CHAR_NAME(tgt);
-$IF ($GET_CHARACTER_SA($TargetContext(),"saved" )) {$RETURN;};
-$IF ($GET_CANBEHELDORCHARMED($TargetContext()) != 1){$RETURN;};
-$IF ($GET_MONSTERTYPE_SA(name,"monsterLevel") != "-?-?-")
-	{  //  MONSTERTYPE_SA checks go here
-		$IF ($GET_MONSTERTYPE_SA(name,"IsPerson") == "-?-?-") {$RETURN;};
-	};
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger") {lvl = lvl -# 8;};
-$SetFriendly(tgt,$GET_COMBATANT_SA($Myself(),"side"));
-$SET_COMBATANT_SA($TargetContext(),"IsCharmed",lvl);
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger") {lvl = lvl -# 8;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_CharmPersonOrMammal
[InvokeSpellOnTarget] = $VAR cls;
-$VAR lvl;
-$VAR tgt;
-$VAR name;
-tgt = $IndexOf($TargetContext());
-name = $GET_CHAR_NAME(tgt);
-$IF ($GET_CHARACTER_SA($TargetContext(),"saved" )) {$RETURN;};
-$IF ($GET_CANBEHELDORCHARMED($TargetContext()) != 1){$RETURN;};
-$IF ($GET_MONSTERTYPE_SA(name,"monsterLevel") != "-?-?-")
-	{  //  MONSTERTYPE_SA checks go here
-		$IF ($GET_MONSTERTYPE_SA(name,"IsPerson") == "-?-?-" && $GET_ISMAMMAL($TargetContext()) != 1){$RETURN;};
-	};
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger") {lvl = lvl -# 8;};
-$SetFriendly(tgt,$GET_COMBATANT_SA($Myself(),"side"));
-$SET_COMBATANT_SA($TargetContext(),"IsCharmed",lvl);
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger") {lvl = lvl -# 7;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_CharmPlant
[InvokeSpellOnTarget] = $VAR cls;
-$VAR lvl;
-$VAR tgt;
-$VAR name;
-tgt = $IndexOf($TargetContext());
-name = $GET_CHAR_NAME(tgt);
-$IF ($GET_CHARACTER_SA($TargetContext(),"saved" )) {$RETURN;};
-$IF ($GET_CANBEHELDORCHARMED($TargetContext()) != 1){$RETURN;};
-$IF ($GET_MONSTERTYPE_SA(name,"monsterLevel") != "-?-?-")
-	{  //  MONSTERTYPE_SA checks go here
-		$IF ($GET_MONSTERTYPE_SA(name,"IsPlant") == "-?-?-") {$RETURN;};
-	};
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$SetFriendly(tgt,$GET_COMBATANT_SA($Myself(),"side"));
-$SET_COMBATANT_SA($TargetContext(),"IsCharmed",lvl);
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_Cloudkill
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[SpellLingerBlockage] = $IF ($GET_HASPOISONIMMUNITY($CombatantContext()))
-  {$RETURN "N";};
\(END)

\(BEGIN)
name = spell_ColdResistant
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR expiration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-expiration = $GET_PARTY_TIME();
-expiration = expiration +# $SA_PARAM_GET();
-$SET_CHARACTER_SA($TargetContext(),"IsResistantCold", "expiration");
[SpellDuration] = $SA_PARAM_SET($GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = spell_Confusion
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR target;
-$VAR monName;
-$VAR monLvl;
-$VAR opr; // once per round
-$VAR rnd;
-$VAR rnd2;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-target = $IndexOf($TargetContext());
-$IF ($GET_CHAR_STATUS(target) != 0){$RETURN;};
-monName = $GET_CHAR_NAME(target);
-$IF (($GET_MONSTERTYPE_SA(monName,"zConfusionSA") != "-?-?-")||
-($GET_COMBATANT_SA($TargetContext(),"zConfusionSA") != "-?-?-")){$RETURN;};
-monLvl = $GET_MONSTERTYPE_SA(monName,"monsterLevel");
-$IF (monLvl != "-?-?-")
-	{
-		$IF ((monLvl ==# 1)||(monLvl ==# 2)){$SET_CHAR_SAVEVSSP(target, 17 );};
-		$IF ((monLvl ==# 3)||(monLvl ==# 4)){$SET_CHAR_SAVEVSSP(target, 16 );};
-		$IF ((monLvl ==# 5)||(monLvl ==# 6)){$SET_CHAR_SAVEVSSP(target, 14 );};
-		$IF ((monLvl ==# 7)||(monLvl ==# 8)){$SET_CHAR_SAVEVSSP(target, 13 );};
-		$IF ((monLvl ==# 9)||(monLvl ==# 10)){$SET_CHAR_SAVEVSSP(target, 11 );};
-		$IF ((monLvl ==# 11)||(monLvl ==# 12)){$SET_CHAR_SAVEVSSP(target, 10 );};
-		$IF ((monLvl ==# 13)||(monLvl ==# 14)){$SET_CHAR_SAVEVSSP(target, 8 );};
-		$IF ((monLvl ==# 15)||(monLvl ==# 16)){$SET_CHAR_SAVEVSSP(target, 7 );};
-		$IF (monLvl >=# 17){$SET_CHAR_SAVEVSSP(target, 6 );};
-	};
-opr = $GET_COMBATANT_SA($AttackerContext(), "CombatRoundStart");
-$IF (opr  == "-?-?-")
-	{
-		$SET_COMBATANT_SA( $AttackerContext(), "CombatRoundStart",5);
-		rnd = (($RANDOM(4) +# 1) +# ($RANDOM(4) +# 1));
-		$SET_COMBATANT_SA( $AttackerContext(), "PointPool", rnd);
-	};
-opr = $GET_COMBATANT_SA($AttackerContext(), "CombatRoundStart");
-$IF (opr  <# 2)
-	{
-		$SET_COMBATANT_SA( $AttackerContext(), "CombatRoundStart", 3);
-		rnd = (($RANDOM(4) +# 1) +# ($RANDOM(4) +# 1));
-		$SET_COMBATANT_SA( $AttackerContext(), "PointPool", rnd);
-	};
-rnd = $GET_COMBATANT_SA( $AttackerContext(), "PointPool");
-$IF (rnd <# 1) {$RETURN;};
-rnd2 = ($RANDOM(20) +# 1);
-$IF ($GET_CHAR_SAVEVSSP(target) ># rnd2)
-	{
-		$SET_COMBATANT_SA($TargetContext(),"IsConfusedExtended",1);
-		$SET_COMBATANT_SA($TargetContext(),"CombatRoundStart",1);
-	};
-rnd = $RANDOM(10) +# 1;
-$IF (rnd ==# 1){$SetFriendly(target,1);$RETURN;};
-$IF (rnd <=# 6){$SET_COMBATANT_SA($TargetContext(),"IsConfused","Confused");$RETURN;};
-$IF (rnd ==# 7){$SetFriendly(target,1);$RETURN;};
-$IF (rnd ==# 8){$SetFriendly(target,2);$RETURN;};
-$SetFriendly(target,2);
\(END)

\(BEGIN)
name = spell_ConfusionDruid
[SpellCasterLevel] = $RETURN $GET_CHAR_DRUIDLVL($IndexOf($AttackerContext()));
\(END)

\(BEGIN)
name = spell_Curse
[InvokeSpellOnTarget] = $VAR cls;
-$VAR lvl;
-$VAR atk;
-$IF ($GET_CHARACTER_SA($TargetContext(),"saved"))
-  {$RETURN;};
-atk = $IndexOf($AttackerContext());
-$IF ($RANDOM(20) +# 1 <# $GET_CHAR_THAC0(atk) -# $GET_CHAR_AC($IndexOf($TargetContext())))
-  {$RETURN;};
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl(atk,cls);
-$IF (cls == "paladin") {lvl = lvl -# 8;};
-$SET_CHARACTER_SA($TargetContext(),"IsBestowedCurse",$GET_PARTY_TIME() +# (10 *# lvl));
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "paladin"){lvl = lvl -# 8;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_CurseMinor
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR mySide;
-mySide = $GET_COMBATANT_SA($AttackerContext(),"side");
-$IF (mySide ==# $GET_COMBATANT_SA($TargetContext(),"side")){$RETURN;};
-$SET_CHARACTER_SA($TargetContext(),"IsCursed",$GET_PARTY_TIME() +# 6);
\(END)

\(BEGIN)
name = spell_DeathSpell
[InvokeSpellOnTarget] = $VAR target;
-$VAR status;
-$VAR opr;
-$VAR rnd;
-$VAR monName;
-$VAR monLvl;
-$VAR charLvl;
-$VAR clr;
-$VAR ftr;
-$VAR pal;
-$VAR rgr;
-$VAR thf;
-$VAR mu;
-$VAR dru;
-$VAR pv; // point value
-target = $IndexOf($TargetContext());
-status = $GET_CHAR_STATUS(target);
-$IF (status ==# 5||status ==# 4||status ==# 3||status ==# 2) {$RETURN;};
-$IF ($GET_CHAR_UNDEAD(target) !=# 0) {$RETURN;};
-opr = $GET_COMBATANT_SA($AttackerContext(),"IsStartCombatRound");
-$IF (opr  == "-?-?-")
-	{
-		$SET_COMBATANT_SA($AttackerContext(),"IsStartCombatRound", 5);
-		rnd = ($RANDOM(80) +# 4);
-		$SET_COMBATANT_SA($AttackerContext(),"PointPool", rnd);
-	};
-opr = $GET_COMBATANT_SA($AttackerContext(),"IsStartCombatRound");
-$IF (opr  <# 2)
-	{
-		$SET_COMBATANT_SA($AttackerContext(),"IsStartCombatRound", 3);
-		rnd = (($RANDOM(10) +# 1) +# ($RANDOM(10) +# 1) +# ($RANDOM(10) +# 1) +# ($RANDOM(10) +# 1));
-		$SET_COMBATANT_SA($AttackerContext(),"PointPool", rnd);
-	};
-rnd = $GET_COMBATANT_SA($AttackerContext(),"PointPool");
-$IF (rnd <# 1) {$RETURN;};
-monName = $GET_CHAR_NAME($IndexOf($TargetContext()));
-monLvl = $GET_MONSTERTYPE_SA(monName,"monsterLevel");
-$IF (monLvl != "-?-?-") {charLvl = monLvl;}
-$ELSE
-	{
-		charLvl = 0;
-		clr = $GET_CHAR_Lvl(target,"cleric");
-		ftr = $GET_CHAR_Lvl(target,"fighter");
-		pal = $GET_CHAR_Lvl(target,"paladin");
-		rgr = $GET_CHAR_Lvl(target,"ranger");
-		thf = $GET_CHAR_Lvl(target,"thief");
-		mu = $GET_CHAR_Lvl(target,"magicUser");
-		dru = $GET_CHAR_Lvl(target,"druid");
-		$IF (clr ># charLvl) {charLvl = clr;};
-		$IF (ftr ># charLvl) {charLvl = ftr;};
-		$IF (pal ># charLvl) {charLvl = pal;};
-		$IF (rgr ># charLvl) {charLvl = rgr;};
-		$IF (thf ># charLvl) {charLvl = thf;};
-		$IF (mu ># charLvl) {charLvl = mu;};
-		$IF (dru ># charLvl) {charLvl = dru;};
-	};
-$IF (charLvl ># 9 ){pv = "-?-?-";};
-$IF (charLvl ==# 8 || charLvl ==# 9 ){pv =# 20;};
-$IF (charLvl ==# 5 || charLvl ==# 6 || charLvl ==# 7 ){pv =# 10;};
-$IF (charLvl ==# 2 || charLvl ==# 3 || charLvl ==# 4 ){pv =# 3;};
-$IF (charLvl ==# 1 ){pv =# 1;};
-$IF (pv != "-?-?-" )
-	{
-		$IF ( rnd >=# pv )
-			{
-				rnd = rnd -# pv;
-				$SET_COMBATANT_SA($AttackerContext(), "PointPool", rnd);
-				$SET_CHAR_HITPOINTS(target, "-11");
-				$SET_CHAR_STATUS(target, 2);
-			};
-	};
\(END)

\(BEGIN)
name = spell_DetectEvil
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR name;
-$VAR monMT;
-name = $GET_CHAR_NAME($IndexOf($TargetContext()));
-monMT = $GET_MONSTERTYPE_SA(name,"monster_CombatantAlignment");
-$DEBUG ($SA_NAME() + " monMT = " + monMT);
-$IF (monMT == "evil")
-	{
-		$SET_COMBATANT_SA($TargetContext(),"IsDetectedEvil","Evil");
-	};
[RemoveLinger] = $RETURN "TARGET";
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "paladin"){lvl = lvl -# 8;};
-$IF (cls == "ranger"){lvl = lvl -# 7;};
-$RETURN lvl;
(END)

\(BEGIN)
name = spell_DetectMagic
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $SET_CHARACTER_SA($TargetContext(),"IsDetectingMagic",$GET_PARTY_TIME() +# $SA_SPELL_GET("time"));
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "paladin"){lvl = lvl -# 8;};
-$IF (cls == "ranger"){lvl = lvl -# 7;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_DetectMagicMage
[InvokeSpellOnTarget] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($MyIndex(),cls);
-$IF (cls == "ranger") {lvl = lvl -# 8;};
-$SET_CHARACTER_SA($TargetContext(),"IsDetectingMagic",$GET_PARTY_TIME() +# (lvl *# 2));
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($MyIndex(),cls);
-$IF (cls == "ranger") {lvl = lvl -# 8;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_DimensionDoor
[InvokeSpellOnTarget] = $TeleportCombatant($IndexOf($AttackerContext()),$GET_HOOK_PARAM(5),$GET_HOOK_PARAM(6));
[IsValidTarget] = $VAR x0;
-$VAR y0;
-$VAR x1;
-$VAR y1;
-x1 = $GET_HOOK_PARAM(5);
-y1 = $GET_HOOK_PARAM(6);
-x0 = $CombatantLocation($IndexOf($Myself()),"X");
-y0 = $CombatantLocation($IndexOf($Myself()),"Y");
-$IF ($IsLineOfSight(x0,y0,x1,y1,1)){$RETURN "N";}
-$ELSE{$RETURN "";};
\(END)

\(BEGIN)
name = spell_Disease
[InvokeSpellOnTarget] = $IF ($GET_CHAR_PALADINLVL($IndexOf($TargetContext())) >=# 1){$RETURN;};
-$IF($GET_CHARACTER_SA($TargetContext(),"IsImmuneDisease") != "-?-?-"){$RETURN;};
-$SET_CHARACTER_SA($TargetContext(),"IsDiseased","Diseased");
\(END)

\(BEGIN)
name = spell_Dispel
[InvokeSpellOnTarget] = $VAR target;
-$VAR name;
-$VAR caster;
-$VAR class; // caster's class (creator)
-$VAR cLvl; // caster's level (creator)
-$VAR dLvl; // caster's level (destroyer)
-$VAR percent;
-$VAR potion;
-$VAR pCount;
-$VAR pName;
-$VAR rndm;
-target = $IndexOf($TargetContext());
-name = $GET_CHAR_NAME(target);
-caster = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-cLvl = $GET_CHARACTER_SA($TargetContext(),"DispelLevel");
-dLvl = $GET_CHAR_Lvl(caster,class);
-potion = "$Potion$Potion|1$Potion|2$Potion|3$Potion|4";
-pCount = $DelimitedStringCount(potion);
-pName = $DelimitedStringSubstring(potion, pCount);
-rndm = $RANDOM(100) +# 1;
-// potions
-$IF (dLvl ># 21)
-	{
-		$WHILE (pCount ># 0)
-			{
-				pCount = pCount -# 1;
-				$IF ($GET_ITEM_SA(pName, "item_Potion") != "-?-?-")
-					{
-						$TAKE_CHAR_ITEM($Name(name), pName);
-						$GIVE_CHAR_ITEM($Name(name),"Empty Bottle");
-					};
-			};
-	};
-$IF (dLvl ># cLvl)
-	{
-		percent = (dLvl -# cLvl) *# 5 +# 50;
-	}
-$ELSE
-	{
-		percent = 50 -# (cLvl -# dLvl) *# 2;
-	};
-$IF (rndm <=# percent)
-	{
-		$WHILE (pCount ># 0)
-			{
-				pCount = pCount -# 1;
-				$IF ($GET_ITEM_SA(pName, "item_Potion") != "-?-?-")
-					{
-						$TAKE_CHAR_ITEM($Name(name), pName);
-						$GIVE_CHAR_ITEM($Name(name),"Empty Bottle");
-					};
-			};
-	};
-// spells and spell effects
-$IF (dLvl ># cLvl)
-	{
-		percent = (dLvl -# cLvl) *# 5 +# 50;
-	}
-$ELSE
-	{
-		percent = 50 -# (cLvl -# dLvl) *# 2;
-	};
-$IF (rndm <=# percent)
-	{
-		$RUN_CHAR_SCRIPTS(target,"Dispel");
-		$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
-		$SET_SPELL_SA($SpellContext(),"Dispelled","yes");
-		$RETURN;
-	};
[SpellLingeringScripts] = $VAR cLvl; // caster's level (creator)
-$VAR dLvl; // caster's level (destroyer)
-$VAR percent;
-$VAR rndm;
-$IF ($GET_SPELL_SA($SpellContext(),"Dispelled") != "-?-?-")
-{ $RETURN "RemoveLinger"; };
-cLvl = $GET_HOOK_PARAM(7);
-dLvl = $GET_HOOK_PARAM(6);
-rndm = $RANDOM(100) +# 1;
-$IF (dLvl ># cLvl)
-	{
-		percent = (dLvl -# cLvl) *# 5 +# 50;
-	}
-$ELSE
-	{
-		percent = 50 -# (cLvl -# dLvl) *# 2;
-	};
-$IF (rndm <=# percent)
-	{
-		$RETURN "RemoveLinger";
-	};
\(END)

\(BEGIN)
name = spell_DispelEvil
name = spell_DispelEvil
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR lvl;
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),$SA_PARAM_GET());
-$SET_CHARACTER_SA($TargetContext(),"IsDispellingEvil",$GET_PARTY_TIME() +# lvl);
-$SET_CHARACTER_SA($TargetContext(),"CanDispel",1);
\(END)

\(BEGIN)
name = spell_DispelGood
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR lvl;
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),$SA_PARAM_GET());
-$SET_CHARACTER_SA($TargetContext(),"IsDispellingGood",$GET_PARTY_TIME() +# lvl);
-$SET_CHARACTER_SA($TargetContext(),"CanDispel",1);
\(END)

\(BEGIN)
name = spell_Drain
[InvokeSpellOnTarget] = $VAR target;
-$VAR charLvl;
-$VAR charClass;
-$VAR classes;
-$VAR bclass;
-$VAR baseClassNum;
-$VAR baseClassName;
-$VAR baseClassDefinition;
-$VAR remainingBaseClasses;
-$VAR highestBaseClassLevel;
-$VAR highestBaseClassName;
-$VAR deduction;
-$VAR hit0;
-$VAR monLvl;
-$VAR name;
-$VAR div;
-$VAR xpLow;
-$VAR xpNew;
-$VAR build;
-name = $GET_CHAR_NAME($IndexOf($TargetContext()));
-monLvl = $GET_MONSTERTYPE_SA(name,"monsterLevel"); 
-$IF (monLvl != "-?-?-") 
-  {
-    $IF ($GET_COMBATANT_SA($TargetContext(), "monsterLevel") != "-?-?-"){charLvl = (($GET_COMBATANT_SA($TargetContext(  ), "monsterLevel") -# 1));}
-    $ELSE {charLvl = monLvl -# 1;};
-    target = $IndexOf($TargetContext());
-    hit0 = $GET_CHAR_THAC0(target);
-    $IF ((charLvl ==# 15) ||(charLvl ==# 13) ||(charLvl ==# 11) ||(charLvl ==# 7)){$SET_CHAR_THAC0(target, (hit0 +# 1));};
-    $IF ((charLvl ==# 9) ||(charLvl ==# 5) ||(charLvl ==# 3) ||(charLvl ==# 1)){$SET_CHAR_THAC0(target, (hit0 +# 2));};
-    $SET_CHAR_HITPOINTS(target,$GET_CHAR_HITPOINTS(target) -# ($RANDOM(8) +# 1));
-    $SET_COMBATANT_SA($TargetContext(), "monsterLevel", charLvl);
-  };
-$IF (monLvl == "-?-?-")
-  {
-    target = $IndexOf($TargetContext());
-    charClass = $GET_CHAR_CLASS(target);
-    div = 1; // Number of classes for dividing hit point reduction
-    $IF (charClass ># 6) {div = 2;};
-    $IF (charClass == 8 || charClass == 14 || charClass == 18) {div = 3;};
-    bclass = "$|fighter|10$|cleric|8$|ranger|8$|paladin|10$|magicUser|4$|thief|6$|druid|8";
-    classes = "$0$1$2$3$4$5$6$01$014$12$14$15$04$05$045$45$06$46$046";
-    highestBaseClassLevel = 0;
-    remainingBaseClasses = $DelimitedStringSubstring(classes, charClass); //Eg: "025"
-    baseClassNum = $MIDDLE(remainingBaseClasses,0,1);    // Eg: "0"
-    $WHILE (baseClassNum != "")
-      {
-        remainingBaseClasses = $MIDDLE(remainingBaseClasses,1,999); // Eg: "25" or "5"
-        baseClassDefinition = $DelimitedStringSubstring(bclass,baseClassNum); // Eg: "|fighter|10"
-        baseClassName = $DelimitedStringSubstring(baseClassDefinition,0); // Eg: "fighter"
-        $IF($GET_CHAR_Lvl(target, baseClassName) ># highestBaseClassLevel)
-          {
-            highestBaseClassName = baseClassName; //Eg: "fighter"
-            highestBaseClassLevel = $GET_CHAR_Lvl(target, baseClassName); // Eg: "3"
-            deduction = $DelimitedStringSubstring(baseClassDefinition,1); // Eg: "10"
-          };
-        baseClassNum = $MIDDLE(remainingBaseClasses,0,1); // Eg: "2" or "5" or ""
-      };
-    charLvl = $GET_CHAR_Lvl(target,highestBaseClassName);
-    xpLow = $DAT_Baseclass_Experience(highestBaseClassName,(charLvl -# 1));
-    xpNew = xpLow +# (($DAT_Baseclass_Experience(highestBaseClassName,(charLvl)) -# xpLow) /# 2);
-    deduction = $RANDOM(deduction /# div) +# 1;
-    $IF ($GET_CHARACTER_SA($TargetContext(),"IsDrained") == "-?-?-")
-      {
-        $SET_CHARACTER_SA($TargetContext(),"IsDrained","$|" + highestBaseClassName + "|" + charLvl + "|" + deduction + "$|99");
-      }
-    $ELSE
-      {
-        build = $GET_CHARACTER_SA($TargetContext(),"IsDrained");
-        $SET_CHARACTER_SA($TargetContext(),"IsDrained","$|" + highestBaseClassName + "|" + charLvl + "|" + deduction + build);
-      };
-    $SET_CHAR_Lvl(target,highestBaseClassName,(charLvl -# 1));
-    $SET_CHAR_HITPOINTS(target,$GET_CHAR_HITPOINTS(target) -# deduction);
-    $SET_CHAR_MAXHITPOINTS(target,$GET_CHAR_MAXHITPOINTS(target) -# deduction);
-    $SET_CHAR_Exp(target,highestBaseClassName,xpNew);
-  };
-$IF (charLvl <=# 1)
-  {
-    $SET_CHAR_HITPOINTS(target,"-11");
-    $SET_CHAR_MAXHITPOINTS(target, "0");
-    $SET_CHARACTER_SA($TargetContext(),"IsGone",5);
-  };
\(END)

\(BEGIN)
name = spell_DrainVamp
[InvokeSpellOnTarget] = $VAR target;
-$VAR charLvl;
-$VAR charClass;
-$VAR classes;
-$VAR bclass;
-$VAR baseClassNum;
-$VAR baseClassName;
-$VAR baseClassDefinition;
-$VAR remainingBaseClasses;
-$VAR highestBaseClassLevel;
-$VAR highestBaseClassName;
-$VAR deduction;
-$VAR hit0;
-$VAR monLvl;
-$VAR name;
-$VAR div;
-$VAR xpLow;
-$VAR xpNew;
-$VAR build;
-name = $GET_CHAR_NAME($IndexOf($TargetContext()));
-monLvl = $GET_MONSTERTYPE_SA(name,"monsterLevel"); 
-$IF (monLvl != "-?-?-") 
-  {
-    $IF ($GET_COMBATANT_SA($TargetContext(), "monsterLevel") != "-?-?-"){charLvl = (($GET_COMBATANT_SA($TargetContext(  ), "monsterLevel") -# 1));}
-    $ELSE {charLvl = monLvl -# 1;};
-    target = $IndexOf($TargetContext());
-    hit0 = $GET_CHAR_THAC0(target);
-    $IF ((charLvl ==# 15) ||(charLvl ==# 13) ||(charLvl ==# 11) ||(charLvl ==# 7)){$SET_CHAR_THAC0(target, (hit0 +# 1));};
-    $IF ((charLvl ==# 9) ||(charLvl ==# 5) ||(charLvl ==# 3) ||(charLvl ==# 1)){$SET_CHAR_THAC0(target, (hit0 +# 2));};
-    $SET_CHAR_HITPOINTS(target,$GET_CHAR_HITPOINTS(target) -# ($RANDOM(8) +# 1));
-    $SET_COMBATANT_SA($TargetContext(), "monsterLevel", charLvl);
-  };
-$IF (monLvl == "-?-?-")
-  {
-    target = $IndexOf($TargetContext());
-    charClass = $GET_CHAR_CLASS(target);
-    div = 1; // Number of classes for dividing hit point reduction
-    $IF (charClass ># 6) {div = 2;};
-    $IF (charClass == 8 || charClass == 14 || charClass == 18) {div = 3;};
-    bclass = "$|fighter|10$|cleric|8$|ranger|8$|paladin|10$|magicUser|4$|thief|6$|druid|8";
-    classes = "$0$1$2$3$4$5$6$01$014$12$14$15$04$05$045$45$06$46$046";
-    highestBaseClassLevel = 0;
-    remainingBaseClasses = $DelimitedStringSubstring(classes, charClass); //Eg: "025"
-    baseClassNum = $MIDDLE(remainingBaseClasses,0,1);    // Eg: "0"
-    $WHILE (baseClassNum != "")
-      {
-        remainingBaseClasses = $MIDDLE(remainingBaseClasses,1,999); // Eg: "25" or "5"
-        baseClassDefinition = $DelimitedStringSubstring(bclass,baseClassNum); // Eg: "|fighter|10"
-        baseClassName = $DelimitedStringSubstring(baseClassDefinition,0); // Eg: "fighter"
-        $IF($GET_CHAR_Lvl(target, baseClassName) ># highestBaseClassLevel)
-          {
-            highestBaseClassName = baseClassName; //Eg: "fighter"
-            highestBaseClassLevel = $GET_CHAR_Lvl(target, baseClassName); // Eg: "3"
-            deduction = $DelimitedStringSubstring(baseClassDefinition,1); // Eg: "10"
-          };
-        baseClassNum = $MIDDLE(remainingBaseClasses,0,1); // Eg: "2" or "5" or ""
-      };
-    charLvl = $GET_CHAR_Lvl(target,highestBaseClassName);
-    xpLow = $DAT_Baseclass_Experience(highestBaseClassName,(charLvl -# 1));
-    xpNew = xpLow +# (($DAT_Baseclass_Experience(highestBaseClassName,(charLvl)) -# xpLow) /# 2);
-    deduction = $RANDOM(deduction /# div) +# $RANDOM(deduction /# div) +# 2;
-    $IF ($GET_CHARACTER_SA($TargetContext(),"IsDrained") == "-?-?-")
-      {
-        $SET_CHARACTER_SA($TargetContext(),"IsDrained","$|" + highestBaseClassName + "|" + charLvl + "|" + deduction + "$|99");
-      }
-    $ELSE
-      {
-        build = $GET_CHARACTER_SA($TargetContext(),"IsDrained");
-        $SET_CHARACTER_SA($TargetContext(),"IsDrained","$|" + highestBaseClassName + "|" + charLvl + "|" + deduction + build);
-      };
-    $SET_CHAR_Lvl(target,highestBaseClassName,(charLvl -# 2));
-    $SET_CHAR_HITPOINTS(target,$GET_CHAR_HITPOINTS(target) -# deduction);
-    $SET_CHAR_MAXHITPOINTS(target,$GET_CHAR_MAXHITPOINTS(target) -# deduction);
-    $SET_CHAR_Exp(target,highestBaseClassName,xpNew);
-  };
-$IF (charLvl <=# 1)
-  {
-    $SET_CHAR_HITPOINTS(target,"-11");
-    $SET_CHAR_MAXHITPOINTS(target, "0");
-    $SET_CHARACTER_SA($TargetContext(),"IsGone",5);
-  };
\(END)

\(BEGIN)
name = spell_Enlarge
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5 ));
[InvokeSpellOnTarget] = $VAR tgt;
-$VAR cls;
-$VAR lvl;
-$VAR pick;
-$VAR list1;
-$VAR list2;
-$IF ($GET_COMBATANT_SA($TargetContext(),"side") != $GET_COMBATANT_SA($AttackerContext(),"side"))
- {$IF ($GET_CHAR_SAVEVSSP(tgt) == 1) {$RETURN;};};
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($MyIndex(),cls);
-$IF (cls == "ranger") {lvl = lvl -# 8;};
-tgt = $IndexOf($TargetContext());
-pick = lvl;
-$IF (pick ># 10) {pick = 10;};
-$IF ($GET_CHARACTER_SA($TargetContext(),"myStr") == "-?-?-")
-	{
-		$SET_CHARACTER_SA($TargetContext(),"myStr",$GET_CHAR_STR(tgt));
-		$SET_CHARACTER_SA($TargetContext(),"myStrMod",$GET_CHAR_STRMOD(tgt));
-	};
-$IF ($GET_CHARACTER_SA($TargetContext(),"mySize") == "-?-?-")
-	{$SET_CHARACTER_SA($TargetContext(),"mySize",$GET_CHAR_SIZE(tgt));};
-list1 = "|$18$0|$18$0|$18$01|$18$51|$18$76|$18$91|$18$100|$19$0|$20$0|$21$0|$22$0";
-list2 = $DelimitedStringSubstring(list1,pick);
-$IF ($GET_CHAR_STR(tgt) <# $DelimitedStringSubstring(list2,0))
- {$SET_CHAR_STR(tgt,$DelimitedStringSubstring(list2,0));};
-$IF ($GET_CHAR_STR(tgt) == 18)
-	{
-		$IF ($GET_CHAR_STRMOD(tgt) <# $DelimitedStringSubstring(list2,1))
-			{
-				$SET_CHAR_STRMOD(tgt,$DelimitedStringSubstring(list2,1));
-			};
-	}
-$ELSE {$SET_CHAR_STRMOD(tgt,$DelimitedStringSubstring(list2,1));};
-$IF (pick ># 4) {$SET_CHAR_SIZE(tgt,3);};
-$SET_CHARACTER_SA($TargetContext(),"IsEnlarged",lvl);
-$SET_CHARACTER_SA($TargetContext(),"enlarged",$GET_PARTY_TIME() +# (lvl *# 10));
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger") {lvl = lvl -# 8;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_Entangle
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[Entangled1] = $RETURN $SET_HOOK_PARAM(8 ,"Slowed by Plants");
[InvokeSpellOnTarget] = $VAR atk;
-$VAR tgt;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-tgt = $IndexOf($TargetContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-$IF ($GET_CHAR_SAVEVSSP(tgt) ># $RANDOM(20))
-  {$SET_COMBATANT_SA($TargetContext(),"IsEntangled0",$GET_PARTY_TIME() +# 10);}
-$ELSE
-  {$SET_COMBATANT_SA($TargetContext(),"IsEntangled1",$GET_CHAR_MAXMOVE(tgt) /# 2);};
[MovementAdjustments] = $VAR speed;
-speed = $GET_HOOK_PARAM(5);
-speed = speed /# 2;
-$SET_HOOK_PARAM(5, speed);
[RemoveLinger] = $RETURN "AREA";
[SpellLingerBlockage] = $IF ($GET_COMBATANT_SA($CombatantContext(),"IsEntangled1") != "-?-?-"){$RETURN "N";};
\(END)

\(BEGIN)
name = spell_FaerieFireDruid
[SpellCasterLevel] = $RETURN $GET_CHAR_DRUIDLVL($IndexOf($AttackerContext()));
\(END)

\(BEGIN)
name = spell_FaerieFireRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 7);
\(END)

\(BEGIN)
name = spell_Fear
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-$SET_COMBATANT_SA($TargetContext(),"IsAfraid","");
\(END)

\(BEGIN)
name = spell_Feeblemind
[InvokeSpellOnTarget] = $VAR adj;
-$VAR target;
-target = $IndexOf($TargetContext());
-$IF ($GET_CHAR_RACE(target) == "Human")
-  {
-    $IF ($GET_CHAR_Lvl(target,"magicUser") ># 0) {adj = 4;};
-    $IF ($GET_CHAR_Lvl(target,"ranger") ># 8) {adj = 2;};
-    $IF ($GET_CHAR_Lvl(target,"druid") ># 0||$GET_CHAR_Lvl(target,"ranger") ==# 8) {adj = 1;};
-    $IF ($GET_CHAR_Lvl(target,"cleric") ># 0||$GET_CHAR_Lvl(target,"paladin") ># 8) {adj = "-1";};
-  }
-$ELSE
-  {
-    $IF (($GET_CHAR_Lvl(target,"magicUser") ># 0)||($GET_CHAR_Lvl(target,"druid") ># 0)||($GET_CHAR_Lvl(target,"ranger") ># 7)||($GET_CHAR_Lvl(target,"cleric") ># 0)){adj = 2;};
-  };
-$IF (adj == "") {$RETURN;};
-$IF ($GET_CHAR_SAVEVSSP(target) +# adj ># $RANDOM(20) +# 1)
-  {
-    $SET_CHARACTER_SA($TargetContext(),"IsFeebleminded","$" + $GET_CHAR_INT(target) + "$" + $GET_CHAR_WIS(target));
-    $SET_CHAR_INT(target,2);
-    $SET_CHAR_WIS(target,2);
-   };
\(END)

\(BEGIN)
name = spell_FeeblemindDruid
[SpellCasterLevel] = $RETURN $GET_CHAR_DRUIDLVL($IndexOf($AttackerContext()));
\(END)

\(BEGIN)
name = spell_FireResistant
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR expiration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-expiration = $GET_PARTY_TIME();
-expiration = expiration +# $SA_PARAM_GET();
-$SET_CHARACTER_SA($TargetContext(),"IsResistantFire", "expiration");
[RemoveLinger] = $RETURN "TARGETS";
[SpellDuration] = $SA_PARAM_SET($GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = spell_FireShield
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR expiration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-expiration = $GET_PARTY_TIME();
-expiration = expiration +# $SA_PARAM_GET();
-$DialogSelect(0);
-$DialogSet(6,"Hot Flames");
-$DialogSet(7,"Cold Flames");
-$DialogSet(8,"Abort Spell");
-$DialogSet(18,"Please select whether Hot Flames will be used for the Fire Shield, which provide protection against cold attacks, or Cold Flames will be used which will provide some protection against fire attacks.");
-$DialogDisplay();
-$IF ($DialogGet(6) == "0"){$RETURN $SET_CHARACTER_SA($TargetContext(),"IsFireShieldedHot", "expiration");};
-$IF ($DialogGet(6) == "1"){$RETURN $SET_CHARACTER_SA($TargetContext(),"IsFireShieldedCold", "expiration");}
-$ELSE {$RETURN;};
[RemoveLinger] = $RETURN "TARGETS";
[SpellDuration] = $SA_PARAM_SET($GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = spell_FixBlind
Info = "cure blindness, heal for FIX";
[FixCharacter] = $VAR blind;
-blind = $GET_CHARACTER_SA($CharacterContext(),"IsBlind");
-$RETURN blind != "-?-?-";
\(END)

\(BEGIN)
name = spell_FixCure
Info = "cure light/serious/critical wounds, heal for FIX";
[FixCharacter] = $VAR char;
-$VAR HP;
-$VAR maxHP;
-char = $IndexOf($CharacterContext());
-HP = $GET_CHAR_HITPOINTS(char);
-maxHP = $GET_CHAR_MAXHITPOINTS(char);
-$RETURN maxHP ># HP;
\(END)

\(BEGIN)
name = spell_FixCurse
Info = "remove curse for FIX";
[FixCharacter] = $VAR curse;
-curse = $GET_CHARACTER_SA($CharacterContext(),"IsCursed");
-$RETURN curse != "-?-?-";
\(END)

\(BEGIN)
name = spell_FixDisease
Info = "cure disease, heal for FIX";
[FixCharacter] = $VAR disease;
-disease = $GET_CHARACTER_SA($CharacterContext(),"IsDiseased");
-$RETURN disease != "-?-?-";
\(END)

\(BEGIN)
name = spell_FixDrain
Info = "restoration for FIX";
[FixCharacter] = $VAR drain;
-drain = $GET_CHARACTER_SA($CharacterContext(),"IsDrained");
-$RETURN drain != "-?-?-";
\(END)

\(BEGIN)
name = spell_FixFeeblemind
Info = "heal for FIX";
[FixCharacter] = $VAR feeblemind;
-feeblemind = $GET_CHARACTER_SA($CharacterContext(),"IsFeebleminded");
-$RETURN feeblemind != "-?-?-";
\(END)

\(BEGIN)
name = spell_FixPoison
Info = "slow/neutralize poison for FIX";
[FixCharacter] = $VAR poison;
-poison = $GET_CHARACTER_SA($CharacterContext(),"IsPoisoned");
-$RETURN poison != "-?-?-";
\(END)

\(BEGIN)
name = spell_FixRaise
Info = "raise dead, resurrection for FIX";
[FixCharacter] = $VAR char;
-$VAR status;
-char = $IndexOf($CharacterContext());
-status = $GET_CHAR_STATUS(char);
-$RETURN status ==# 2;
\(END)

\(BEGIN)
name = spell_FriendsRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_Fumble
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR expiration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-expiration = $GET_PARTY_TIME();
-expiration = expiration +# $SA_PARAM_GET();
-$SET_CHARACTER_SA($TargetContext(), "IsFumbling", "expiration");
[SpellDuration] = $SA_PARAM_SET($GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = spell_Haste
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR expiration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-expiration = $GET_PARTY_TIME();
-expiration = expiration +# $SA_PARAM_GET();
-$SET_COMBATANT_SA($TargetContext(),"IsFast","expiration");
\(END)

\(BEGIN)
name = spell_Heal
[InvokeSpellOnTarget] = $VAR target;
-target = $IndexOf($TargetContext());
-$IF ($GET_CHAR_STATUS(target) <# 2)
-	{
-		$IF ($GET_CHAR_HITPOINTS(target) <# ($GET_CHAR_MAXHITPOINTS(target) -# 4))
-			{
-				$SET_CHAR_STATUS(target,0);
-				$SET_CHAR_HITPOINTS(target,($GET_CHAR_MAXHITPOINTS(target)-#($RANDOM(4)+#1)));
-			}
-		$ELSE
-			{
-				$SET_CHAR_STATUS(target,0);
-				$SET_CHAR_HITPOINTS(target,($GET_CHAR_MAXHITPOINTS(target)));
-			};
-	}
-$ELSE{$RETURN;};
\(END)

\(BEGIN)
name = spell_HoldAnimal
[InvokeSpellOnTarget] = $VAR cls;
-$VAR lvl;
-$IF ($GET_CHARACTER_SA($TargetContext(),"saved")){$RETURN;};
-$IF($GET_CANBEHELDORCHARMED($TargetContext()) == "" || $GET_ISANIMAL($TargetContext()) == ""){$RETURN;};
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger"){lvl = lvl -# 7;};
-$SET_COMBATANT_SA($TargetContext(),"IsHeld",$GET_PARTY_TIME() +# (lvl *# 2));
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger"){lvl = lvl -# 7;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_HoldMonster
[InvokeSpellOnTarget] = $VAR lvl;
-$IF ($GET_CHARACTER_SA($TargetContext(),"saved")){$RETURN;};
-$IF ($GET_CANBEHELDORCHARMED($TargetContext()) != 1){$RETURN;};
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),"magicUser");
-$SET_COMBATANT_SA($TargetContext(),"IsHeld",$GET_PARTY_TIME() +# lvl);
\(END)

\(BEGIN)
name = spell_HoldPersonCleric
[InvokeSpellOnTarget] = $VAR cls;
-$VAR lvl;
-$VAR tgt;
-$VAR name;
-tgt = $IndexOf($TargetContext());
-$IF ($GET_CHARACTER_SA($TargetContext(),"saved")){$RETURN;};
-name = $GET_CHAR_NAME(tgt);
-$IF ($GET_CANBEHELDORCHARMED($TargetContext()) != 1){$RETURN;};
-$IF ($GET_MONSTERTYPE_SA(name,"monsterLevel") != "-?-?-")
-	{  //  MONSTERTYPE_SA checks go here
-		$IF ($GET_MONSTERTYPE_SA(name,"IsPerson") == "-?-?-") {$RETURN;};
-	};
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "paladin"){lvl = lvl -# 8;};
-$SET_COMBATANT_SA($TargetContext(),"IsHeld",$GET_PARTY_TIME() +# 4 +# lvl);
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "paladin"){lvl = lvl -# 8;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_HoldPersonMU
[InvokeSpellOnTarget] = $VAR lvl;
-$VAR name;
-$IF ($GET_CHARACTER_SA($TargetContext(),"saved")){$RETURN;};
-$IF ($GET_CANBEHELDORCHARMED($TargetContext()) != 1){$RETURN;};
-name = $GET_CHAR_NAME($IndexOf($TargetContext()));
-$IF ($GET_MONSTERTYPE_SA(name,"monsterLevel") != "-?-?-")
-	{  //  MONSTERTYPE_SA checks go here
-		$IF ($GET_MONSTERTYPE_SA(name,"IsPerson") == "-?-?-") {$RETURN;};
-	};
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),"magicUser");
-$SET_COMBATANT_SA($TargetContext(),"IsHeld",$GET_PARTY_TIME() +# (lvl *# 2));
\(END)

\(BEGIN)
name = spell_ImmuneDragonBreath
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-$SET_COMBATANT_SA($CombatantContext(),"IsImmuneDB", 4);
\(END)

\(BEGIN)
name = spell_ImmuneNormalMissiles
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR expiration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-expiration = $GET_PARTY_TIME();
-expiration = expiration +# $SA_PARAM_GET();
-$SET_CHARACTER_SA($TargetContext(), "IsImmuneNormalMissiles", "expiration");
[SpellDuration] = $SA_PARAM_SET($GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = spell_ImmuneSpells
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR expiration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-expiration = $GET_PARTY_TIME();
-expiration = expiration +# $SA_PARAM_GET();
-$SET_CHARACTER_SA($CharacterContext(),"IsImmuneSpells","expiration");
[SpellDuration] = $SA_PARAM_SET($GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = spell_ImmuneSpellsMinor
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-$SET_CHARACTER_SA($CharacterContext(),"IsImmuneSpellsMinor","");
\(END)

\(BEGIN)
name = spell_InsectPlagueDruid
[CheckProximity] = $VAR target;
-$VAR myself;
-$VAR range;
-$VAR distance;
-$VAR saveVsSpell;
-$VAR roll;
-$VAR PClevel;
-target = $GET_HOOK_PARAM(6);
-myself = $GET_HOOK_PARAM(5);
-range = $SA_PARAM_GET();
-distance = $VisualDistance(target, myself);
-$IF (range <# distance) {$RETURN;};
-saveVsSpell = $GET_CHAR_SAVEVSSP(target);
-roll = $RANDOM(20) +# 1;
-PClevel = $GET_CHAR_CLERICLVL(target) || $GET_CHAR_DRUIDLVL(target) || $GET_CHAR_FIGHTERLVL(target) || $GET_CHAR_MAGICUSERLVL(target) || $GET_CHAR_PALADINLVL(target) || $GET_CHAR_RANGERLVL(target) || $GET_CHAR_THIEFLVL(target);
-$IF (PClevel <# 3)
-  {
-    $SET_COMBATANT_SA($TargetContext(),"IsInsectFlee", "$IndexOf($CombatantContext())");
-  };
-$IF (PClevel <# 6)
-  {
-    $IF (saveVsSpell ># roll)
-      {
-        $SET_COMBATANT_SA($TargetContext(),"IsInsectFlee", "$IndexOf($CombatantContext())");
-      };
-  };
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[RemoveLinger] = $RETURN "AREA";
[SpellCasterLevel] = $RETURN $GET_CHAR_DRUIDLVL($IndexOf($AttackerContext()));
\(END)

\(BEGIN)
name = spell_Invisible
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-$SET_CHARACTER_SA($TargetContext(),"IsInvisibleSpell",2);
[RemoveLinger] = $RETURN "TARGETS";
\(END)

\(BEGIN)
name = spell_InvisibleToAnimals
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-$SET_CHARACTER_SA($TargetContext(),"IsInvisibleToAnimals","");
[RemoveLinger] = $RETURN "TARGETS";
\(END)

\(BEGIN)
name = spell_InvisibilityToAnimalsDruid
[SpellCasterLevel] = $RETURN $GET_CHAR_DRUIDLVL($IndexOf($AttackerContext()));
\(END)

\(BEGIN)
name = spell_InvisibilityToAnimalsRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 7);
\(END)

\(BEGIN)
name = spell_MagicMissileRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_MassCharm
[InvokeSpellOnTarget] = $VAR side;  //caster's side
-$VAR tgt;
-$VAR atk;
-$VAR name;  //target name
-$VAR clvl;  //caster level
-$VAR lvl;   //target level
-$VAR tlvl;  //temporary target level
-$VAR bclass;
-$VAR cls;
-$VAR index;
-$VAR i;
-$VAR opr;   //once per round
-$VAR rnd;
-atk = $IndexOf($AttackerContext());
-clvl = $GET_CHAR_Lvl(atk,"magicUser");
-opr = $GET_COMBATANT_SA($AttackerContext(),"CombatRoundStart");
-$IF (opr == "-?-?-"||opr == 0)
-	{
-		$SET_COMBATANT_SA($AttackerContext(),"CombatRoundStart",5);
-		$SET_COMBATANT_SA($AttackerContext(),"PointPool",clvl *# 2);
-	};
-rnd = $GET_COMBATANT_SA($AttackerContext(),"PointPool");
-$IF (rnd <# 1) {$RETURN;};
-$IF ($GET_CANBEHELDORCHARMED($TargetContext()) != 1) {$RETURN;};
-side = $GET_COMBATANT_SA($AttackerContext(), "side");
-$IF ($GET_COMBATANT_SA($TargetContext(), "side") ==# side) {$RETURN;};
-tgt = $IndexOf($TargetContext());
-name = $GET_CHAR_NAME(tgt);
-tlvl = $GET_MONSTERTYPE_SA(name,"monsterLevel");
-$IF (tlvl != "-?-?-") {lvl = tlvl;}
-$ELSE
-	{
-		lvl = 0;
-		i = 0;
-		bclass = "$fighter$cleric$ranger$paladin$magicUser$thief$druid";
-		cls = 0;
-		$WHILE (cls != "")
- 			{
-				cls = $DelimitedStringSubstring(bclass,i);
-				tlvl = $GET_CHAR_Lvl(index,cls);
-				$IF (tlvl ># lvl) {lvl = tlvl;};
-				i = i +# 1;
-			};
-	};
-$IF (lvl ># rnd) {$RETURN;}
-$ELSE
-	{
-		$SET_COMBATANT_SA($AttackerContext(),"PointPool",rnd -# lvl);
-		$IF ($GET_CHARACTER_SA($TargetContext(),"saved" )) {$RETURN;};
-		$SetFriendly(tgt,side);
-		$SET_COMBATANT_SA($TargetContext(),"IsCharmed",clvl);
-	};
\(END)

\(BEGIN)
name = spell_MindBlast
[InvokeSpellOnTarget] = $SET_COMBATANT_SA($TargetContext(),"IsStunned","Stunned");
\(END)

\(BEGIN)
name = spell_MirrorImage
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR images;
-$VAR random;
-$VAR magelvl;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-// Determine number of new images
-magelvl = $GET_CHAR_Lvl($IndexOf($Myself()),"magicUser");
-random = $RANDOM(100) +# 1 +# magelvl;
-$IF (random <=# 25){images = 1;}
-$ELSE
-  {$IF (random <=# 50)
-      {images = 2;}
-    $ELSE
-      {$IF (random <=# 75)
-          {images = 3;}
-        $ELSE
-          {images = 4;};
-      };
-  };
-// Test for existing images
-$IF ($GET_CHARACTER_SA($Myself(),"IsMirrored") == "-?-?-")
-  {$SET_CHARACTER_SA($Myself(),"IsMirrored",0);};
-// Add new images
-$SET_CHARACTER_SA($Myself(),"IsMirrored",$GET_CHARACTER_SA($Myself(),"IsMirrored") +# images);
[RemoveLinger] = $RETURN "TARGETS";
\(END)

\(BEGIN)
name = spell_MirrorImageRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_MummyRot
[InvokeSpellOnTarget] = $SET_CHARACTER_SA($TargetContext(),"IsMummyDiseased",$GET_PARTY_DAYS() +# 30);
\(END)

\(BEGIN)
name = spell_NeutralizePoison
[InvokeSpellOnTarget] = $VAR tgt;
-tgt = $IndexOf($TargetContext());
-$IF ($GET_CHARACTER_SA($TargetContext(), "IsPoisoned") == "-?-?-"){$RETURN;};
-$DELETE_CHARACTER_SA($CharacterContext(),"IsPoisoned");
-$IF ($GET_CHAR_HITPOINTS(tgt) <=# 0)
-	{
-		$SET_CHAR_HITPOINTS(tgt, "1");
-		$SET_CHAR_STATUS(tgt, "0");
-	};
\(END)

\(BEGIN)
name = spell_Paralysis
[InvokeSpellOnTarget] = $VAR name;
-name = $GET_CHAR_NAME($IndexOf($TargetContext()));
-$IF ($GET_CHARACTER_SA($TargetContext(),"IsImmuneParalysis") != "-?-?-" || $GET_MONSTERTYPE_SA(name,"monster_ImmuneParalysis") != "-?-?-" || $GET_CHARACTER_SA($TargetContext(),"saved")){$RETURN;};
-$IF ($GET_CHAR_NAME($IndexOf($AttackerContext())) == "Ghoul" && $GET_CHAR_RACE($IndexOf($TargetContext())) == "Elf"){$RETURN;};
-$SET_COMBATANT_SA($TargetContext(),"IsParalyzed","Paralyzed");
\(END)

\(BEGIN)
name = spell_Petrify
[InvokeSpellOnTarget] = $SET_CHARACTER_SA($TargetContext(),"IsPetrified","Petrified");
\(END)

\(BEGIN)
name = spell_Poison
[InvokeSpellOnTarget] = $VAR time;
-time = $GET_PARTY_TIME();
-$IF ($SA_CHARACTER_GET("IsImmunePoison") != "-?-?-"){$RETURN;};
-$IF ($SA_CHARACTER_GET("IsProtectedPoisonCaster") != "-?-?-"){$RETURN;};
-$IF ($SA_CHARACTER_GET("IsProtectedPoisonTarget") != "-?-?-"){$RETURN;};
-$SET_CHARACTER_SA($TargetContext(),"IsPoisoned",time);
-$SET_CHAR_STATUS($IndexOf($TargetContext()),2);
-$SET_CHAR_HITPOINTS($IndexOf($TargetContext()),"-11");
\(END)

\(BEGIN)
name = spell_PowerWordKill
[ComputeDamage] = $VAR targetHP;
-targetHP = $GET_CHAR_HITPOINTS($IndexOf($TargetContext()));
-$IF (targetHP <=# 60){$RETURN targetHP +# 11;};
\(END)

\(BEGIN)
name = spell_PowerWordStun
[InvokeSpellOnTarget] = $VAR expiration;
-expiration = $GET_PARTY_TIME() +# $RANDOM(4) +# $RANDOM(4) +# 2;
-$SET_COMBATANT_SA($TargetContext(),"IsStunned","expiration");
\(END)

\(BEGIN)
name = spell_Prayer
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR duration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-duration = $GET_PARTY_TIME();
-duration = duration +# $GET_CHAR_CLERICLVL($MyIndex());
-$SET_CHARACTER_SA($TargetContext(),"IsPraying", duration);
\(END)

\(BEGIN)
name = spell_PrayerPaladin
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR duration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-duration = $GET_PARTY_TIME();
-duration = duration +# ($GET_CHAR_PALADINLVL($MyIndex()) -# 8);
-$SET_CHARACTER_SA($TargetContext(),"IsPraying", duration);
[SpellCasterLevel] = $RETURN ($GET_CHAR_PALADINLVL($IndexOf($AttackerContext())) -# 8);
\(END)

name = spell_ProtectionFromAcid
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR atk;
-$VAR cls;
-$VAR lvl;
-atk = $IndexOf($AttackerContext());
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger") {lvl = lvl -# 7;};
-$IF (atk ==# $IndexOf($TargetContext()))
-	{
-		$SET_CHARACTER_SA($TargetContext(),"IsProtectedAcidCaster",$GET_PARTY_TIME() +# (lvl *# 10));
-		$SET_CHARACTER_SA($TargetContext(),"AcidPoints",lvl *# 12);
-	}
-$ELSE
-	{$SET_CHARACTER_SA($TargetContext(),"IsProtectedAcidTarget",$GET_PARTY_TIME() +# (lvl *# 10));};
[RemoveLinger] = $RETURN "TARGETS";
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger") {lvl = lvl -# 7;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_ProtectionFromEvil
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR duration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-duration = $GET_PARTY_TIME() +# $SA_PARAM_GET();
-$SET_CHARACTER_SA($TargetContext(),"IsProtectedEvil","duration");
[SpellCasterLevel] = $VAR druid;
-$VAR paladin;
-$VAR ranger;
-druid = $GET_CHAR_DRUIDLVL($IndexOf($AttackerContext()));
-paladin = $GET_CHAR_PALADINLVL($IndexOf($AttackerContext())) -# 8;
-ranger = $GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 7;
-$IF (paladin ># 0){$RETURN paladin;};
-$IF (druid ># 0){$RETURN druid;};
-$IF (ranger ># 0){$RETURN ranger;};
[SpellDuration] = $SA_PARAM_SET($GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = spell_ProtectionFromFire
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR atk;
-$VAR cls;
-$VAR lvl;
-atk = $IndexOf($AttackerContext());
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger") {lvl = lvl -# 7;};
-$IF (atk ==# $IndexOf($TargetContext()))
-	{
-		$SET_CHARACTER_SA($TargetContext(),"IsProtectedFireCaster",$GET_PARTY_TIME() +# (lvl *# 10));
-		$SET_CHARACTER_SA($TargetContext(),"FirePoints",lvl *# 12);
-	}
-$ELSE
-	{$SET_CHARACTER_SA($TargetContext(),"IsProtectedFireTarget",$GET_PARTY_TIME() +# (lvl *# 10));};
[RemoveLinger] = $RETURN "TARGETS";
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger") {lvl = lvl -# 7;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_ProtectionFromGood
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR duration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-duration = $GET_PARTY_TIME() +# $SA_PARAM_GET();
-$SET_CHARACTER_SA($TargetContext(),"IsProtectedGood","duration");
[SpellCasterLevel] = $VAR druid;
-$VAR paladin;
-$VAR ranger;
-druid = $GET_CHAR_DRUIDLVL($IndexOf($AttackerContext()));
-paladin = $GET_CHAR_PALADINLVL($IndexOf($AttackerContext())) -# 8;
-ranger = $GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 7;
-$IF (paladin ># 0){$RETURN paladin;};
-$IF (druid ># 0){$RETURN druid;};
-$IF (ranger ># 0){$RETURN ranger;};
[SpellDuration] = $SA_PARAM_SET($GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = spell_ProtectionFromLightning
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR atk;
-$VAR cls;
-$VAR lvl;
-atk = $IndexOf($AttackerContext());
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (atk ==# $IndexOf($TargetContext()))
-	{
-		$SET_CHARACTER_SA($TargetContext(),"IsProtectedLightningCaster",$GET_PARTY_TIME() +# (lvl *# 10));
-		$SET_CHARACTER_SA($TargetContext(),"ZapPoints",lvl *# 12);
-	}
-$ELSE
-	{$SET_CHARACTER_SA($TargetContext(),"IsProtectedLightningTarget",$GET_PARTY_TIME() +# (lvl *# 10));};
[RemoveLinger] = $RETURN "TARGETS";
[SpellCasterLevel] = $RETURN $GET_CHAR_Lvl($IndexOf($AttackerContext()),"druid");
\(END)

name = spell_ProtectionFromPoison
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR atk;
-$VAR cls;
-$VAR lvl;
-atk = $IndexOf($AttackerContext());
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger") {lvl = lvl -# 7;};
-$IF (atk ==# $IndexOf($TargetContext()))
-	{
-		$SET_CHARACTER_SA($TargetContext(),"IsProtectedPoisonCaster",$GET_PARTY_TIME() +# (lvl *# 10));
-		$SET_CHARACTER_SA($TargetContext(),"PoisonPoints",lvl *# 12);
-	}
-$ELSE
-	{$SET_CHARACTER_SA($TargetContext(),"IsProtectedPoisonTarget",$GET_PARTY_TIME() +# (lvl *# 10));};
[RemoveLinger] = $RETURN "TARGETS";
[SpellCasterLevel] = $VAR cls;
-$VAR lvl;
-cls = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),cls);
-$IF (cls == "ranger") {lvl = lvl -# 7;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_PurpleWormBite
[ComputeDamage] = $IF ($SA_COMBATANT_GET("purpleBite") ==# 20)
-  {
-    $SET_HOOK_PARAM(7,"Swalows it's victim whole!");
-    $RETURN "500";
-  };
[DoesAttackSucceed] = $RETURN $SET_COMBATANT_SA($TargetContext(),"purpleBite",$GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = spell_RaiseDead
[InvokeSpellOnTarget] = $VAR tgt;
-$VAR type;
-$VAR con; // Constitution
-$VAR raised;
-$VAR list;
-$VAR pct; // percent
-tgt = $IndexOf($TargetContext());
-$IF ($GET_COMBATANT_SA($AttackerContext(),"mummy") == 1)
-	{ // Mummy Swap
-		$AddCombatant("Ancient Fighter",0);
-		$TeleportCombatant($IndexOf($Name("Ancient Fighter")),$GET_HOOK_PARAM(5),$GET_HOOK_PARAM(6));
-		$DELETE_COMBATANT_SA($AttackerContext(),"mummy");
-		$RETURN;
-	};
-$IF ($GET_CHAR_STATUS(tgt) !=# 2){$RETURN;};
-con = $GET_CHAR_CON(tgt);
-raised = $GET_CHARACTER_SA($TargetContext(),"raised");
-$IF (raised == "-?-?-"){raised = con;}
-$ELSE {raised = raised -# 1;};
-$IF (raised <# 1 || $GET_CHAR_RACE(tgt) == "Elf"){$RETURN $SET_CHAR_STATUS(tgt,5);};
-$SET_CHARACTER_SA($TargetContext(),"raised",raised);
-list = "$0$30$35$40$45$50$55$60$65$70$75$80$85$90$92$94$96$98$100$100$100$100$100$100$100$100";
-pct = $DelimitedStringSubstring(list,con);
-$IF (pct <# $RANDOM(100) +# 1){$RETURN $SET_CHAR_STATUS(tgt,5);};
-$SET_CHAR_CON(tgt,con -# 1);
-$SET_CHAR_HITPOINTS(tgt,1);
-$SET_CHAR_STATUS(tgt,1);
\(END)

\(BEGIN)
name = spell_RayOfEnfeeblementRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_ReadMagic
[CanIdentify] = $IF ($GET_ITEM_SA($ItemContext(), "item_Scroll" ) != "-?-?-")
-	{
-		$RETURN "Y";
-	};
[Identify] = $SA_REMOVE();
-$RETURN "Y";
\(END)

\(BEGIN)
name = spell_Reduce
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR myself;
-$VAR target;
-$VAR duration;
-$VAR originalSize;
-$VAR originalStr;
-$VAR originalStrMod;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-target = $IndexOf($TargetContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-myself = $MyIndex();
-duration = $GET_PARTY_TIME();
-duration = duration +# $SA_PARAM_GET();
-originalSize = $GET_CHAR_SIZE(target);
-originalStr = $GET_CHAR_STR(target);
-originalStrMod = $GET_CHAR_STRMOD(target);
-$SET_COMBATANT_SA($TargetContext(),"IsReduced", duration);
-$SET_COMBATANT_SA($TargetContext(),"IsReducedSize", originalSize);
-$SET_COMBATANT_SA($TargetContext(),"IsReducedStr", originalStr);
-$SET_COMBATANT_SA($TargetContext(),"IsReducedStrMod", originalStrMod);
[RemoveLinger] = $RETURN "TARGETS";
[SpellDuration] = $SA_PARAM_SET($GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = spell_ReduceRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_RemoveBlindness
[InvokeSpellOnTarget] = $DELETE_CHARACTER_SA($CharacterContext(),"IsBlind");
\(END)

\(BEGIN)
name = spell_RemoveCurse
[InvokeSpellOnTarget] = $VAR target;
-target = $IndexOf($CharacterContext());
-$SET_CHAR_THAC0(target,$SA_CHARACTER_GET("IsCursed"));
-$SET_CHAR_SAVEVSBR(target,$SA_CHARACTER_GET("tempBR"));
-$SET_CHAR_SAVEVSPP(target,$SA_CHARACTER_GET("tempPP"));
-$SET_CHAR_SAVEVSPPDM(target,$SA_CHARACTER_GET("tempPPDM"));
-$SET_CHAR_SAVEVSRSW(target,$SA_CHARACTER_GET("tempRSW"));
-$SET_CHAR_SAVEVSSP(target,$SA_CHARACTER_GET("tempSP"));
\(END)

\(BEGIN)
name = spell_RemoveDisease
[InvokeSpellOnTarget] = $DELETE_CHARACTER_SA($TargetContext(),"IsDiseased");
\(END)

\(BEGIN)
name = spell_RemoveFeeblemind
[InvokeSpellOnTarget] = $VAR target;
-target = $IndexOf($CharacterContext());
-$DELETE_CHARACTER_SA($CharacterContext(),"IsFeebleminded");
-$SET_CHAR_INT(target,$SA_CHARACTER_GET("feebleINT"));
\(END)

\(BEGIN)
name = spell_RemovePetrified
[InvokeSpellOnTarget] = $DELETE_CHARACTER_SA($CharacterContext(),"IsPetrified");
\(END)

\(BEGIN)
name = spell_ResistColdPaladin
[SpellCasterLevel] = $RETURN ($GET_CHAR_PALADINLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_ResistFirePaladin
[SpellCasterLevel] = $RETURN ($GET_CHAR_PALADINLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_Restoration
[InvokeSpellOnTarget] = $VAR target;
-$VAR feebled;
-$VAR drained;
-$VAR head;
-$VAR class;
-$VAR level;
-$VAR hp;
-$VAR done;
-target = $IndexOf($TargetContext());
-done = 0;
-// Feeblemind
-$IF ($GET_CHARACTER_SA($TargetContext(),"IsFeebleminded") != "-?-?-")
-  {
-    feebled = $GET_CHARACTER_SA($TargetContext(),"IsFeebleminded");
-    $SET_CHAR_INT(target,$DelimitedStringSubstring(feebled,0));
-    $SET_CHAR_WIS(target,$DelimitedStringSubstring(feebled,1));
-    $DELETE_CHARACTER_SA($TargetContext(),"IsFeebleminded");
-  };
-// Level restoration
-$IF ($GET_CHARACTER_SA($TargetContext(),"IsDrained") != "-?-?-")
-  {
-    $WHILE (done <# 1)
-      {
-        drained = $GET_CHARACTER_SA($TargetContext(),"IsDrained");
-        head = $DelimitedStringHead(drained);
-        class = $DelimitedStringSubstring(head,0);
-        $IF ($GET_CHAR_Lvl(target,class) <# $DelimitedStringSubstring(head,1))
-          {
-            level = $DelimitedStringSubstring(head,1);
-            $SET_CHAR_Lvl(target,class,level);
-            $SET_CHAR_Exp(target,class,$DAT_Baseclass_Experience(class,level));
-            hp = $DelimitedStringSubstring(head,2);
-            $SET_CHAR_MAXHITPOINTS(target,$GET_CHAR_MAXHITPOINTS(target) +# hp);
-            $SET_CHAR_HITPOINTS(target,$GET_CHAR_HITPOINTS(target) +# hp); 
-            done = 2;
-          };
-        $SET_CHARACTER_SA($TargetContext(),"IsDrained",$DelimitedStringTail(drained));
-        $IF ($GET_CHARACTER_SA($TargetContext(),"IsDrained") == "$|99")
-          {
-            $DELETE_CHARACTER_SA($TargetContext(),"IsDrained");
-            done = 3;
-          };
-      };
-  };
\(END)

\(BEGIN)
name = spell_Resurrection
[InvokeSpellOnTarget] = $VAR target;
-$VAR monName;
-$VAR monLvl;
-$VAR con; // Constitution
-$VAR pct; // percent
-target = $IndexOf($TargetContext());
-$IF ($InParty($Myself())){$SET_CHAR_AGE($MyIndex(), ($GET_CHAR_AGE($MyIndex()) +# 3));};
-monName = $GET_CHAR_NAME(target);
-monLvl = $GET_MONSTERTYPE_SA(monName,"monsterLevel"); 
-$IF (monLvl != "-?-?-") 
-  {
-    $IF (monName == "Ghast"||monName == "Ghoul"||monName == "Skeleton"||monName == "Wight"||monName == "Wraith"||monName == "Zombie")
-      {
-        $SET_CHAR_STATUS(target, 2);
-        $SET_CHAR_HITPOINTS(target, "-11");
-        $RETURN;
-      };
-    $IF (monName == "Mummy")
-      {
-        $SET_CHAR_HITPOINTS(target, "-11");
-        $SET_CHAR_STATUS(target, 2);
-        $AddCombatant("Ancient Fighter", 0 );
-      };
-  };
-$IF (monLvl == "-?-?-")
-  {
-    $IF ($GET_CHAR_RACE(target) == "Elf"){$RETURN;};
-    $IF ($GET_CHAR_STATUS(target) !=# 2){$RETURN;};
-    con = $GET_CHAR_CON(target);
-    pct = 0;
-    $IF (con ==# 1 ){pct = 30 ;};
-    $IF (con ==# 2 ){pct = 35 ;};
-    $IF (con ==# 3 ){pct = 40 ;};
-    $IF (con ==# 4 ){pct = 45 ;};
-    $IF (con ==# 5 ){pct = 50 ;};
-    $IF (con ==# 6 ){pct = 55 ;};
-    $IF (con ==# 7 ){pct = 60 ;};
-    $IF (con ==# 8 ){pct = 65 ;};
-    $IF (con ==# 9 ){pct = 70 ;};
-    $IF (con ==# 10 ){pct = 75 ;};
-    $IF (con ==# 11 ){pct = 80 ;};
-    $IF (con ==# 12 ){pct = 85 ;};
-    $IF (con ==# 13 ){pct = 90 ;};
-    $IF (con ==# 14 ){pct = 92 ;};
-    $IF (con ==# 15 ){pct = 94 ;};
-    $IF (con ==# 16 ){pct = 96 ;};
-    $IF (con ==# 17 ){pct = 98 ;};
-    $IF (con >=# 18 ){pct = 100 ;};
-    $IF (pct <# ($RANDOM(100) +# 1)){$SET_CHAR_STATUS(target, 5); $RETURN;}
-    $ELSE
-      {
-        $SET_CHAR_HITPOINTS(target,$GET_CHAR_MAXHITPOINTS(target));
-        $SET_CHAR_STATUS(target, 0);
-        $RETURN;
-      };
-  };
\(END)

\(BEGIN)
name = spell_SeeInvisible
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-$SET_CHARACTER_SA($TargetContext(),"IsSeeingInvisible","");
\(END)

\(BEGIN)
name = spell_SeeInvisibilityRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_Shield
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR lvl;
-$VAR class;
-class = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),class);
-$IF (class == "ranger") {lvl = lvl -# 8;};
-$SET_CHARACTER_SA($TargetContext(),"IsShielded",$GET_PARTY_TIME() +# (lvl *# 5));
[RemoveLinger] = $RETURN "TARGETS";
[SpellCasterLevel] = $VAR lvl;
-$VAR class;
-class = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl($IndexOf($AttackerContext()),class);
-$IF (class == "ranger") {lvl = lvl -# 8;};
-$RETURN lvl;
\(END)

\(BEGIN)
name = spell_ShillelaghDruid
[SpellCasterLevel] = $RETURN $GET_CHAR_DRUIDLVL($IndexOf($AttackerContext()));
\(END)

\(BEGIN)
name = spell_ShillelaghRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 7);
\(END)

\(BEGIN)
name = spell_Silence
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR expiration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "paladin") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-expiration = $GET_PARTY_TIME();
-expiration = expiration +# $SA_PARAM_GET();
-$SET_COMBATANT_SA($TargetContext(), "IsSilenced", "expiration");
[SpellDuration] = $SA_PARAM_SET($GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = spell_SilencePaladin
[SpellCasterLevel] = $RETURN ($GET_CHAR_PALADINLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_Sleep
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR target;
-$VAR name;
-$VAR index;
-$VAR level;
-$VAR tLevel; // temporary level
-$VAR i;
-$VAR bclass;
-$VAR class;
-$VAR opr; // once per round
-$VAR round;
-$VAR pv; // point value
-$VAR atk;
-$VAR cls;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-cls = $SA_PARAM_GET();
-$IF (cls == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,cls) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,cls));};
-target = $IndexOf($TargetContext());
-$IF ($GET_CHAR_STATUS(target) != 0){$RETURN;};
-$IF ($GET_CHAR_UNDEAD(target) !=# 0){$RETURN;};
-name = $GET_CHAR_NAME(target);
-$IF ($GET_MONSTERTYPE_SA(name,"monster_ImmuneSleep") != "-?-?-") {$RETURN;};
-$IF ($GET_COMBATANT_SA($TargetContext(),"IsSleeping") != "-?-?-") {$RETURN;};
-opr = $GET_COMBATANT_SA($AttackerContext(),"CombatRoundStart");
-$IF (opr  == "-?-?-" || opr  <# 2)
-	{
-		$SET_COMBATANT_SA($AttackerContext(),"CombatRoundStart",5);
-		round = ($RANDOM(4) +# $RANDOM(4) +# $RANDOM(4) +# $RANDOM(4) +# 4);
-		$SET_COMBATANT_SA( $AttackerContext(), "PointPool", round);
-	};
-round = $GET_COMBATANT_SA($AttackerContext(), "PointPool");
-$IF (round <# 1){$RETURN;};
-tLevel = $GET_MONSTERTYPE_SA(name,"monsterLevel");
-$IF (tLevel != "-?-?-") {level = tLevel;}
-$ELSE
-	{
-		level = 0;
-		i = 0;
-		bclass = "$fighter$cleric$ranger$paladin$magicUser$thief$druid";
-		class = 0;
-		$WHILE (class != "")
-			{
-				class = $DelimitedStringSubstring(bclass,i);
-				tLevel = $GET_CHAR_Lvl(index,class);
-				$IF (tLevel ># level) {level = tLevel;};
-				$IF (level ==# 5 ) {level =# 6;};
-				i = i +# 1;
-			};
-	};
-$IF (level ># 5){pv = "";};
-$IF (level ==# 5){pv =# 10;};
-$IF (level ==# 4){pv =# 6;};
-$IF (level ==# 3){pv =# 4;};
-$IF (level ==# 2){pv =# 2;};
-$IF (level ==# 1){pv =# 1;};
-$IF (pv != "" )
-	{
-		$IF ( round >=# pv )
-			{
-				round = round -# pv;
-				$SET_COMBATANT_SA($AttackerContext(), "PointPool", round);
-				$SET_COMBATANT_SA($TargetContext(),"IsSleeping","Sleeping");
-			};
-	};
\(END)

\(BEGIN)
name = spell_SleepRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_Slow
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR expiration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-expiration = $GET_PARTY_TIME();
-expiration = expiration +# $SA_PARAM_GET();
-$SET_CHARACTER_SA($TargetContext(),"IsSlow","expiration");
[SpellDuration] = $SA_PARAM_SET($GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = spell_SlowPoison
[InvokeSpellOnTarget] = $VAR expiration;
-$VAR atk;
-$VAR class;
-$VAR lvl;
-$VAR isPsnd
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl(atk, class);
-$IF (class == "druid"){expiration = lvl;};
-$IF (class == "paladin"){expiration = lvl -# 8;};
-$IF (class == "ranger"){expiration = lvl -# 7;};
-expiration = expiration *# 60 +# $GET_PARTY_TIME();
-isPsnd = $GET_CHARACTER_SA($TargetContext(), "IsPoisoned");
-$IF (isPsnd != "-?-?-")
-	{
-		$IF (isPsnd, "IsPoisoned") <# (time +# lvl))
-			{
-				$RETURN $SET_CHARACTER_SA($TargetContext(), "IsSlowedPoisoned",expiration);
-			};
-	};
[SpellCasterLevel] = $VAR atk;
-$VAR class;
-$VAR lvl;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-lvl = $GET_CHAR_Lvl(atk, class);
-$IF (class == "druid"){$RETURN lvl;};
-$IF (class == "paladin"){$RETURN lvl -# 8;};
-$IF (class == "ranger"){$RETURN lvl -# 7;};
\(END)

\(BEGIN)
name = spell_SnakeCharm
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR expiration;
-$VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "paladin") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-expiration = $GET_PARTY_TIME();
-expiration = expiration +# $SA_param_GET();
-$IF ($SA_COMBATANT_GET("IsSnake") != "-?-?-")
-{$SET_COMBATANT_SA($CombatantContext(),"IsSnakeCharmed","expiration");};
[SpellDuration] = $SA_PARAM_SET($GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = spell_SnakeCharmPaladin
[SpellCasterLevel] = $RETURN (($GET_CHAR_PALADINLVL($IndexOf($AttackerContext())) -# 8) /# 2);
\(END)

\(BEGIN)
name = spell_SpeakWithAnimalsDruid
[SpellCasterLevel] = $RETURN $GET_CHAR_DRUIDLVL($IndexOf($AttackerContext()));
\(END)

\(BEGIN)
name = spell_SpeakWithAnimalsRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 7);
\(END)

\(BEGIN)
name = spell_SticksToSnakesDruid
[SpellCasterLevel] = $RETURN $GET_CHAR_DRUIDLVL($IndexOf($AttackerContext()));
\(END)

\(BEGIN)
name = spell_SticksToSnakesPaladin
[SpellCasterLevel] = $RETURN ($GET_CHAR_PALADINLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_StinkingCloud
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
[InvokeSpellOnTarget] = $VAR atk;
-$VAR class;
-atk = $IndexOf($AttackerContext());
-class = $SA_PARAM_GET();
-$IF (class == "ranger") {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class) -# 8);}
-$ELSE {$SET_CHARACTER_SA($TargetContext(),"DispelLevel",$GET_CHAR_Lvl(atk,class));};
-$IF (($GET_CHARACTER_SA($TargetContext(),"IsImmunePoison") != "-?-?-") || ($GET_HASPOISONIMMUNITY($TargetContext()) == 1) || ($SA_CHARACTER_GET("IsProtectedPoisonCaster") != "-?-?-") || ($SA_CHARACTER_GET("IsProtectedPoisonTarget") != "-?-?-")){$RETURN;};
-$IF ($GET_COMBATANT_SA($TargetContext(),"StinkingSave") == "-?-?-")
-  {
-   $SET_COMBATANT_SA($TargetContext(),"StinkingSave",$GET_CHAR_SAVEVSPPDM($IndexOf($TargetContext())));
-   $IF ($GET_COMBATANT_SA($TargetContext(),"StinkingSave") != 1)
-     {$SET_COMBATANT_SA($TargetContext(),"IsStinkingStuck",$GetCombatRound() +# $RANDOM(4) +# 2);};
-  };
-$IF ($GET_COMBATANT_SA($TargetContext(),"StinkingSave") == 1)
-  {$SET_CHARACTER_SA($TargetContext(),"IsStinkingCloudy",$GetCombatRound());};
[RemoveLinger] = $RETURN "AREA";
[SpellLingerBlockage] = $IF ($GET_CHARACTER_SA($CombatantContext(),"IsImmunePoison") != "-?-?-" || $GET_HASPOISONIMMUNITY($CombatantContext()) == 1 || $SA_CHARACTER_GET("IsProtectedPoisonCaster") != "-?-?-" || $SA_CHARACTER_GET("IsProtectedPoisonTarget") != "-?-?-"){$RETURN;};
-$IF ($GET_COMBATANT_SA($CombatantContext(),"StinkingSave") != "-?-?-")
-  {$RETURN "N";};
[StinkAdjust] = $SET_HOOK_PARAM(6, "N");
[StinkingCloudy] = $RETURN $SET_HOOK_PARAM(8 ,"Coughing");
[StinkingStuck] = $RETURN $SET_HOOK_PARAM(8 ,"Coughing Uncontrollably");
\(END)

\(BEGIN)
name = spell_StinkingCloudRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_StrengthRanger
[SpellCasterLevel] = $RETURN ($GET_CHAR_RANGERLVL($IndexOf($AttackerContext())) -# 8);
\(END)

\(BEGIN)
name = spell_Summon1
[CharDisplayStatus] = $SET_HOOK_PARAM(7, "");
-$SET_HOOK_PARAM(6, "");
-$RETURN "1";
[InvokeSpellOnTarget] = $VAR rndmRnd;
-rndmRnd = $RANDOM(4) +# $GetCombatRound();
-$SET_COMBATANT_SA($TargetContext(), "summoning1", rndmRnd);
\(END)

\(BEGIN)
name = spell_Summon2
[CharDisplayStatus] = $SET_HOOK_PARAM(7, "");
-$SET_HOOK_PARAM(6, "");
-$RETURN "1";
[InvokeSpellOnTarget] = $VAR rndmRnd;
-rndmRnd = $RANDOM(4) +# $GetCombatRound();
-$SET_COMBATANT_SA($TargetContext(), "summoning2", rndmRnd);
\(END)

\(BEGIN)
name = spell_Summon3
[CharDisplayStatus] = $SET_HOOK_PARAM(7, "");
-$SET_HOOK_PARAM(6, "");
-$RETURN "1";
[InvokeSpellOnTarget] = $VAR rndmRnd;
-rndmRnd = $RANDOM(4) +# $GetCombatRound();
-$SET_COMBATANT_SA($TargetContext(), "summoning3", rndmRnd);
\(END)

\(BEGIN)
name = spell_Summon4
[CharDisplayStatus] = $SET_HOOK_PARAM(7, "");
-$SET_HOOK_PARAM(6, "");
-$RETURN "1";
[InvokeSpellOnTarget] = $VAR rndmRnd;
-rndmRnd = $RANDOM(3) +# $GetCombatRound();
-$SET_COMBATANT_SA($TargetContext(), "summoning4", rndmRnd);
\(END)

\(BEGIN)
name = spell_Summon5
[CharDisplayStatus] = $SET_HOOK_PARAM(7, "");
-$SET_HOOK_PARAM(6, "");
-$RETURN "1";
[InvokeSpellOnTarget] = $VAR rndmRnd;
-rndmRnd = $RANDOM(3) +# $GetCombatRound();
-$SET_COMBATANT_SA($TargetContext(), "summoning5", rndmRnd);
\(END)

\(BEGIN)
name = spell_Summon6
[CharDisplayStatus] = $SET_HOOK_PARAM(7, "");
-$SET_HOOK_PARAM(6, "");
-$RETURN "1";
[InvokeSpellOnTarget] = $VAR rndmRnd;
-rndmRnd = $RANDOM(3) +# $GetCombatRound();
-$SET_COMBATANT_SA($TargetContext(), "summoning6", rndmRnd);
\(END)

\(BEGIN)
name = spell_Summon7
[CharDisplayStatus] = $SET_HOOK_PARAM(7, "");
-$SET_HOOK_PARAM(6, "");
-$RETURN "1";
[InvokeSpellOnTarget] = $VAR rndmRnd;
-rndmRnd = $GetCombatRound() +# 2;
-$SET_COMBATANT_SA($TargetContext(), "summoning7", rndmRnd);
\(END)

\(BEGIN)
name = spell_SummonAnimal1
[InvokeSpellOnTarget] = $VAR list;
-$VAR count;
-$VAR n;
-$VAR monster1;
-$VAR sCount;
-list = "$Wild Dog$Owl";
-count = $DelimitedStringCount(list);
-n = $RANDOM(count);
-monster1 = $DelimitedStringSubstring(list,n);
-sCount = $RANDOM(8);
-$WHILE (sCount >=# 0)
-	{
-		$AddCombatant(monster1,"1");
-		sCount = sCount -# 1;
-	};
\(END)

\(BEGIN)
name = spell_SummonAnimal2
[InvokeSpellOnTarget] = $VAR list;
-$VAR count;
-$VAR n;
-$VAR monster1;
-$VAR sCount;
-list = "$Brown Bear$Giant Badger";
-count = $DelimitedStringCount(list);
-n = $RANDOM(count);
-monster1 = $DelimitedStringSubstring(list,n);
-sCount = $RANDOM(6);
-$WHILE (sCount >=# 0)
-	{
-		$AddCombatant(monster1,"1");
-		sCount = sCount -# 1;
-	};
\(END)

\(BEGIN)
name = spell_SummonAnimal3
[InvokeSpellOnTarget] = $VAR list;
-$VAR count;
-$VAR n;
-$VAR monster1;
-$VAR sCount;
-list = "$Elephant$Rhinoceros";
-count = $DelimitedStringCount(list);
-n = $RANDOM(count);
-monster1 = $DelimitedStringSubstring(list,n);
-sCount = $RANDOM(4);
-$WHILE (sCount >=# 0)
-	{
-		$AddCombatant(monster1,"1");
-		sCount = sCount -# 1;
-	};
\(END)

\(BEGIN)
name = spell_SummonElementalAir
[InvokeSpellOnTarget] = $AddCombatant("Air Elemental","1");
\(END)

\(BEGIN)
name = spell_SummonElementalEarth
[InvokeSpellOnTarget] = $AddCombatant("Earth Elemental","1");
\(END)

\(BEGIN)
name = spell_SummonElementalFire
[InvokeSpellOnTarget] = $AddCombatant("Fire Elemental",1);
\(END)

\(BEGIN)
name = spell_SummonElementalWater
[InvokeSpellOnTarget] = $AddCombatant("Water Elemental",1);
\(END)

\(BEGIN)
name = spell_SummonInvisibleStalker
[InvokeSpellOnTarget] = $AddCombatant("Invisible Stalker","1");
\(END)

\(BEGIN)
name = StandardDisplaySpellEffect
[CharDisplayStatus] = $SET_HOOK_PARAM( 7, $SA_PARAM_GET());
-$SET_HOOK_PARAM( 6, "");
-$RETURN 1;
[Dispel] = $SA_REMOVE();
-$RUN_CHAR_SE_SCRIPTS($TargetContext(),"Dispel SE");
[Dispel SE] = $REMOVE_SPELL_EFFECT($CharacterContext(),$GET_HOOK_PARAM(5));
\(END)

\(BEGIN)
name = Summoned
[CreateMonsterCombatant] = $SET_COMBATANT_SA($CharacterContext(),"Summoned",$SA_PARAM_GET());
Dispel = $VAR tgt;
-tgt = $IndexOf($TargetContext());
-$IF ($GET_COMBATANT_SA($TargetContext(), "Summoned") != "-?-?-")
-	{
-		$SET_CHAR_STATUS(tgt, "2");
-		$SET_CHAR_HITPOINTS(tgt, "-20");
-	};
\(END)

\(BEGIN)
name = summoning1
[StartCombatRound] = $VAR list;
-$VAR count;
-$VAR n;
-$VAR monster1;
-$VAR rndmRnd;
-list = "$Goblin$Hobgoblin$Orc$Giant Rat";
-count = $DelimitedStringCount(list);
-n = $RANDOM(count);
-monster1 = $DelimitedStringSubstring(list,n);
-rndmRnd = $SA_PARAM_GET();
-$IF (rndmRnd ==# $GetCombatRound())
-	{
-		$AddCombatant(monster1,1);
-		$SA_REMOVE();
-	};
\(END)

\(BEGIN)
name = summoning2
[StartCombatRound] = $VAR list;
-$VAR count;
-$VAR n;
-$VAR monster1;
-$VAR rndmRnd;
-list = "$Gnoll$Stirge$Giant Centipede$Troglodyte";
-count = $DelimitedStringCount(list);
-n = $RANDOM(count);
-monster1 = $DelimitedStringSubstring(list,n);
-rndmRnd = $SA_PARAM_GET();
-$IF (rndmRnd ==# $GetCombatRound())
-	{
-		$AddCombatant(monster1,1);
-		$SA_REMOVE();
-	};
\(END)

\(BEGIN)
name = summoning3
[StartCombatRound] = $VAR list;
-$VAR count;
-$VAR n;
-$VAR monster1;
-$VAR rndmRnd;
-list = "$Bugbear$Gelatinous Cube$Ghoul$Ogre";
-count = $DelimitedStringCount(list);
-n = $RANDOM(count);
-monster1 = $DelimitedStringSubstring(list,n);
-rndmRnd = $SA_PARAM_GET();
-$IF (rndmRnd ==# $GetCombatRound())
-	{
-		$AddCombatant(monster1,1);
-		$SA_REMOVE();
-	};
\(END)

\(BEGIN)
name = summoning4
[StartCombatRound] = $VAR list;
-$VAR count;
-$VAR n;
-$VAR monster1;
-$VAR rndmRnd;
-list = "$Gargoyle$Hell Hound$Ghast$Werewolf";
-count = $DelimitedStringCount(list);
-n = $RANDOM(count);
-monster1 = $DelimitedStringSubstring(list,n);
-rndmRnd = $SA_PARAM_GET();
-$IF (rndmRnd ==# $GetCombatRound())
-	{
-		$AddCombatant(monster1,1);
-		$SA_REMOVE();
-	};
\(END)

\(BEGIN)
name = summoning5
[StartCombatRound] = $VAR list;
-$VAR count;
-$VAR n;
-$VAR monster1;
-$VAR rndmRnd;
-list = "$Cockatrice$Displacer Beast$Giant Snake$Giant Spider";
-count = $DelimitedStringCount(list);
-n = $RANDOM(count);
-monster1 = $DelimitedStringSubstring(list,n);
-rndmRnd = $SA_PARAM_GET();
-$IF (rndmRnd ==# $GetCombatRound())
-	{
-		$AddCombatant(monster1,1);
-		$SA_REMOVE();
-	};
\(END)

\(BEGIN)
name = summoning6
[StartCombatRound] = $VAR list;
-$VAR count;
-$VAR n;
-$VAR monster1;
-$VAR rndmRnd;
-list = "$Troll$Wight$Wraith$Wyvern";
-count = $DelimitedStringCount(list);
-n = $RANDOM(count);
-monster1 = $DelimitedStringSubstring(list,n);
-rndmRnd = $SA_PARAM_GET();
-$IF (rndmRnd ==# $GetCombatRound())
-	{
-		$AddCombatant(monster1,1);
-		$SA_REMOVE();
-	};
\(END)

\(BEGIN)
name = summoning7
[StartCombatRound] = $VAR list;
-$VAR count;
-$VAR n;
-$VAR monster1;
-$VAR rndmRnd;
-list = "$Ettin$Umber Hulk$Xorn$Neo-Otyugh";
-count = $DelimitedStringCount(list);
-n = $RANDOM(count);
-monster1 = $DelimitedStringSubstring(list,n);
-rndmRnd = $SA_PARAM_GET();
-$IF (rndmRnd ==# $GetCombatRound())
-	{
-		$AddCombatant(monster1,1);
-		$SA_REMOVE();
-	};
\(END)

\(BEGIN)
name = TeleporterDestinations
[/1/0/0] = $RETURN $GET_PARTY_ASL("spot");
\(END)

