Jump to content

Script Triggers and detecting invisibility (EEs and IWD2)


Recommended Posts

Posted (edited)

I noticed some inconsistent behavior with how triggers interact with invisibility, so I did some testing. This was with a party script, with the targets being PCs. I didn't do any testing with enemy scripts.


EEs: tested on BG2EE v2.6.6 and IWDEE v2.5 with EEex

Target object: [PC]
Must be visible: See(), Range(), LOS(), Exists()
Can detect if invisible: Detect()

Range(), LOS(), Exists() triggers:
Must be visible: [PC], NearestAllyOf()
Can detect if invisible: Player1, Myself, StrongestOf

Notes:
- I only checked a few identifiers, but you get the idea
- See() trigger will only see visible creatures (of the ones I tested)


IWD2

Target object: [PC]
Must be visible: See(), Range(), SetLastMarkedObject()
Can detect if invisible: Detect(), LOS(), Exists()

See(), Range(), SetLastMarkedObject() triggers:
Must be visible: [PC], NearestPC
Can detect  if invisible: Player1, Myself, StrongestOf

LastMarkedObject (see below)

 

EDIT: reworded some things and added some notes

About LastMarkedObject (IWD2)

I originally had this as must be visible for See() or Range() triggers. After further testing, these triggers can see LastMarkedObject if invisible. However, the SetLastMarkedObject trigger has the same restrictions as See() and Range(). It cannot mark a [PC] or NearestPC target that is invisible. This also applies to the SetSpellTarget() trigger.

 

Method: This is just how I tested this, in case you're wondering. I made the party invisible, then had them attack an enemy if a PC target was seen. I used blocks like this, just changing the trigger or target object for detecting PCs:

IF
	!StateCheck(Myself,STATE_INVISIBLE)
	!See([EVILCUTOFF])
THEN
	RESPONSE #100
		ApplySpell(Myself,WIZARD_INVISIBILITY)
END

IF
	ActionListEmpty()
	See([PC])
THEN
	RESPONSE #100
		AttackOneRound([EVILCUTOFF])
END

 

Edited by Dan_P
Guest morpheus562
Posted (edited)

I managed to create an incredibly robust set of scripts to detect hidden/invisible enemies. Most times, the party will identify a hidden/invisible enemy and begin counterspells before I, the player, realize it. I break down my early work on it pretty well on the first page of this thread: https://forums.beamdog.com/discussion/81257/enhanced-powergaming-scripts-v6-0/p1

Here are the scripts for regular game to detect hidden/invisible enemies:

Spoiler

IF
  !GlobalTimerNotExpired("MO_DetectEnemyIllusionTimer","LOCALS")
  Global("MO_DetectEnemyIllusion","GLOBAL",1)
  Global("MO_MyDetectEnemyIllusion","LOCALS",1)
THEN
  RESPONSE #100
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",0)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",0)
END

IF
  Global("MO_TrueSightActive","LOCALS",1)
  CheckStat(Myself,0,TRUE_SIGHT)
THEN
  RESPONSE #100
    SetGlobal("MO_TrueSightActive","LOCALS",0)
    SetGlobal("MO_PartyTrueSight","GLOBAL",0)
END

IF
  Global("MO_TrueSightActive","LOCALS",0)
  CheckStatGT(Myself,0,TRUE_SIGHT)
THEN
  RESPONSE #100
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  OR(6)
    SpellCast([EVILCUTOFF],WIZARD_PROJECT_IMAGE)  // SPWI703.SPL (Project Image)
    SpellCast([EVILCUTOFF],WIZARD_SIMULACRUM)  // SPWI804.SPL (Simulacrum)
    SpellCast([EVILCUTOFF],WIZARD_MISLEAD)  // SPWI607.SPL (Mislead)
    SpellCast([EVILCUTOFF],WIZARD_SHADOW_DOOR)  // SPWI505.SPL (Shadow Door)
    SpellCast([EVILCUTOFF],WIZARD_IMPROVED_INVISIBILITY)  // SPWI405.SPL (Improved Invisibility)
    SpellCast([EVILCUTOFF],WIZARD_INVISIBILITY)  // SPWI206.SPL (Invisibility)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  Detect([EVILCUTOFF])
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(NearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(SecondNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(ThirdNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(FourthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(FifthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(SixthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  OR(6)
    SpellCast([EVILCUTOFF],WIZARD_PROJECT_IMAGE)  // SPWI703.SPL (Project Image)
    SpellCast([EVILCUTOFF],WIZARD_SIMULACRUM)  // SPWI804.SPL (Simulacrum)
    SpellCast([EVILCUTOFF],WIZARD_MISLEAD)  // SPWI607.SPL (Mislead)
    SpellCast([EVILCUTOFF],WIZARD_SHADOW_DOOR)  // SPWI505.SPL (Shadow Door)
    SpellCast([EVILCUTOFF],WIZARD_IMPROVED_INVISIBILITY)  // SPWI405.SPL (Improved Invisibility)
    SpellCast([EVILCUTOFF],WIZARD_INVISIBILITY)  // SPWI206.SPL (Invisibility)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  Detect([EVILCUTOFF])
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(NearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(SecondNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(ThirdNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(FourthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(FifthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(SixthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  Global("MO_PartyTrueSight","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
  OR(6)
    SpellCast([EVILCUTOFF],WIZARD_PROJECT_IMAGE)  // SPWI703.SPL (Project Image)
    SpellCast([EVILCUTOFF],WIZARD_SIMULACRUM)  // SPWI804.SPL (Simulacrum)
    SpellCast([EVILCUTOFF],WIZARD_MISLEAD)  // SPWI607.SPL (Mislead)
    SpellCast([EVILCUTOFF],WIZARD_SHADOW_DOOR)  // SPWI505.SPL (Shadow Door)
    SpellCast([EVILCUTOFF],WIZARD_IMPROVED_INVISIBILITY)  // SPWI405.SPL (Improved Invisibility)
    SpellCast([EVILCUTOFF],WIZARD_INVISIBILITY)  // SPWI206.SPL (Invisibility)
  !CheckStat([EVILCUTOFF],3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
  Detect([EVILCUTOFF])
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
  See(NearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
  See(SecondNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
  See(ThirdNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
  See(FourthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
  See(FifthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
  See(SixthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Sight)
    SetInterrupt(TRUE)
END

// 5e Spellcasting Wizard True Sight

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
  OR(6)
    SpellCast([EVILCUTOFF],WIZARD_PROJECT_IMAGE)  // SPWI703.SPL (Project Image)
    SpellCast([EVILCUTOFF],WIZARD_SIMULACRUM)  // SPWI804.SPL (Simulacrum)
    SpellCast([EVILCUTOFF],WIZARD_MISLEAD)  // SPWI607.SPL (Mislead)
    SpellCast([EVILCUTOFF],WIZARD_SHADOW_DOOR)  // SPWI505.SPL (Shadow Door)
    SpellCast([EVILCUTOFF],WIZARD_IMPROVED_INVISIBILITY)  // SPWI405.SPL (Improved Invisibility)
    SpellCast([EVILCUTOFF],WIZARD_INVISIBILITY)  // SPWI206.SPL (Invisibility)
  !CheckStat([EVILCUTOFF],3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
  Detect([EVILCUTOFF])
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
  See(NearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
  See(SecondNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
  See(ThirdNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
  See(FourthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
  See(FifthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
  See(SixthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    SetInterrupt(TRUE)
END

// 5e Spellcasting Cleric True Seeing

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  OR(6)
    SpellCast([EVILCUTOFF],WIZARD_PROJECT_IMAGE)  // SPWI703.SPL (Project Image)
    SpellCast([EVILCUTOFF],WIZARD_SIMULACRUM)  // SPWI804.SPL (Simulacrum)
    SpellCast([EVILCUTOFF],WIZARD_MISLEAD)  // SPWI607.SPL (Mislead)
    SpellCast([EVILCUTOFF],WIZARD_SHADOW_DOOR)  // SPWI505.SPL (Shadow Door)
    SpellCast([EVILCUTOFF],WIZARD_IMPROVED_INVISIBILITY)  // SPWI405.SPL (Improved Invisibility)
    SpellCast([EVILCUTOFF],WIZARD_INVISIBILITY)  // SPWI206.SPL (Invisibility)
  !CheckStat([EVILCUTOFF],3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  Detect([EVILCUTOFF])
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  See(NearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  See(SecondNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  See(ThirdNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  See(FourthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  See(FifthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  See(SixthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobal("MO_TrueSightActive","LOCALS",1)
    SetGlobal("MO_PartyTrueSight","GLOBAL",1)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

// 5e Spellcasting Cleric Invisibility Purge

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  Detect([EVILCUTOFF])
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  See(NearestEnemyOf(Myself))
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  See(SecondNearestEnemyOf(Myself))
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  See(ThirdNearestEnemyOf(Myself))
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  See(FourthNearestEnemyOf(Myself))
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  See(FifthNearestEnemyOf(Myself))
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  See(SixthNearestEnemyOf(Myself))
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

// 5e Spellcasting Wizard Detect Invisibility

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  Detect([EVILCUTOFF])
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN // Detect Invisibility
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  See(NearestEnemyOf(Myself))
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN // Detect Invisibility
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  See(SecondNearestEnemyOf(Myself))
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN // Detect Invisibility
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  See(ThirdNearestEnemyOf(Myself))
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN // Detect Invisibility
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  See(FourthNearestEnemyOf(Myself))
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN // Detect Invisibility
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  See(FifthNearestEnemyOf(Myself))
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN // Detect Invisibility
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  See(SixthNearestEnemyOf(Myself))
  OR(2)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  !CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
  Global("MO_PartyTrueSight","GLOBAL",0)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN // Detect Invisibility
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

Here they are for Spell Revisions:

Spoiler

IF
  !GlobalTimerNotExpired("MO_DetectEnemyIllusionTimer","LOCALS")
  Global("MO_DetectEnemyIllusion","GLOBAL",1)
  Global("MO_MyDetectEnemyIllusion","LOCALS",1)
THEN
  RESPONSE #100
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",0)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",0)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  OR(6)
    SpellCast([EVILCUTOFF],WIZARD_PROJECT_IMAGE)  // SPWI703.SPL (Project Image)
    SpellCast([EVILCUTOFF],WIZARD_SIMULACRUM)  // SPWI804.SPL (Simulacrum)
    SpellCast([EVILCUTOFF],WIZARD_MISLEAD)  // SPWI607.SPL (Mislead)
    SpellCast([EVILCUTOFF],WIZARD_SHADOW_DOOR)  // SPWI505.SPL (Shadow Door)
    SpellCast([EVILCUTOFF],WIZARD_IMPROVED_INVISIBILITY)  // SPWI405.SPL (Improved Invisibility)
    SpellCast([EVILCUTOFF],WIZARD_INVISIBILITY)  // SPWI206.SPL (Invisibility)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  Detect([EVILCUTOFF])
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(NearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(SecondNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(ThirdNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(FourthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(FifthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  !ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(SixthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
    FindTraps()
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  OR(6)
    SpellCast([EVILCUTOFF],WIZARD_PROJECT_IMAGE)  // SPWI703.SPL (Project Image)
    SpellCast([EVILCUTOFF],WIZARD_SIMULACRUM)  // SPWI804.SPL (Simulacrum)
    SpellCast([EVILCUTOFF],WIZARD_MISLEAD)  // SPWI607.SPL (Mislead)
    SpellCast([EVILCUTOFF],WIZARD_SHADOW_DOOR)  // SPWI505.SPL (Shadow Door)
    SpellCast([EVILCUTOFF],WIZARD_IMPROVED_INVISIBILITY)  // SPWI405.SPL (Improved Invisibility)
    SpellCast([EVILCUTOFF],WIZARD_INVISIBILITY)  // SPWI206.SPL (Invisibility)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  Detect([EVILCUTOFF])
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(NearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(SecondNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(ThirdNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(FourthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(FifthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  ModalState(DETECTTRAPS)
  CheckStatGT(Myself,80,DETECTILLUSIONS)
  See(SixthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetGlobalTimer("MO_DetectEnemyIllusionTimer","LOCALS",6)
    SetGlobal("MO_DetectEnemyIllusion","GLOBAL",1)
    SetGlobal("MO_MyDetectEnemyIllusion","LOCALS",1)
    DisplayStringHead(Myself,@5014)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
  OR(6)
    SpellCast([EVILCUTOFF],WIZARD_PROJECT_IMAGE)  // SPWI703.SPL (Project Image)
    SpellCast([EVILCUTOFF],WIZARD_SIMULACRUM)  // SPWI804.SPL (Simulacrum)
    SpellCast([EVILCUTOFF],WIZARD_MISLEAD)  // SPWI607.SPL (Mislead)
    SpellCast([EVILCUTOFF],WIZARD_SHADOW_DOOR)  // SPWI505.SPL (Shadow Door)
    SpellCast([EVILCUTOFF],WIZARD_IMPROVED_INVISIBILITY)  // SPWI405.SPL (Improved Invisibility)
    SpellCast([EVILCUTOFF],WIZARD_INVISIBILITY)  // SPWI206.SPL (Invisibility)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
  Detect([EVILCUTOFF])
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
  See(NearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
  See(SecondNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
  See(ThirdNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
  See(FourthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
  See(FifthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
  See(SixthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,INQUIS_TRUE_SIGHT)  // SPCL232.SPL (True Seeing)
    SetInterrupt(TRUE)
END

// 5e Spellcasting Wizard True Sight

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
  OR(6)
    SpellCast([EVILCUTOFF],WIZARD_PROJECT_IMAGE)  // SPWI703.SPL (Project Image)
    SpellCast([EVILCUTOFF],WIZARD_SIMULACRUM)  // SPWI804.SPL (Simulacrum)
    SpellCast([EVILCUTOFF],WIZARD_MISLEAD)  // SPWI607.SPL (Mislead)
    SpellCast([EVILCUTOFF],WIZARD_SHADOW_DOOR)  // SPWI505.SPL (Shadow Door)
    SpellCast([EVILCUTOFF],WIZARD_IMPROVED_INVISIBILITY)  // SPWI405.SPL (Improved Invisibility)
    SpellCast([EVILCUTOFF],WIZARD_INVISIBILITY)  // SPWI206.SPL (Invisibility)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
  Detect([EVILCUTOFF])
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
  See(NearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
  See(SecondNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
  See(ThirdNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
  See(FourthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
  See(FifthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
  See(SixthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Seeing)
    SetInterrupt(TRUE)
END

// 5e Spellcasting Cleric True Sight

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  OR(6)
    SpellCast([EVILCUTOFF],WIZARD_PROJECT_IMAGE)  // SPWI703.SPL (Project Image)
    SpellCast([EVILCUTOFF],WIZARD_SIMULACRUM)  // SPWI804.SPL (Simulacrum)
    SpellCast([EVILCUTOFF],WIZARD_MISLEAD)  // SPWI607.SPL (Mislead)
    SpellCast([EVILCUTOFF],WIZARD_SHADOW_DOOR)  // SPWI505.SPL (Shadow Door)
    SpellCast([EVILCUTOFF],WIZARD_IMPROVED_INVISIBILITY)  // SPWI405.SPL (Improved Invisibility)
    SpellCast([EVILCUTOFF],WIZARD_INVISIBILITY)  // SPWI206.SPL (Invisibility)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  Detect([EVILCUTOFF])
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  See(NearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  See(SecondNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  See(ThirdNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  See(FourthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  See(FifthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
  See(SixthNearestEnemyOf(Myself))
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    Gender(LastSeenBy(Myself),ILLUSIONARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_TRUE_SIGHT)  // SPPR505.SPL (True Seeing)
    SetInterrupt(TRUE)
END

// 5e Spellcasting Wizard Detect Invisibility

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  Detect([EVILCUTOFF])
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  See(NearestEnemyOf(Myself))
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  See(SecondNearestEnemyOf(Myself))
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  See(ThirdNearestEnemyOf(Myself))
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  See(FourthNearestEnemyOf(Myself))
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  See(FifthNearestEnemyOf(Myself))
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
  See(SixthNearestEnemyOf(Myself))
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  Global("MO_CastAthkatla","LOCALS",1)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    SetInterrupt(TRUE)
END

// 5e Spellcasting Cleric Invisibility Purge

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  Detect([EVILCUTOFF])
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  See(NearestEnemyOf(Myself))
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  See(SecondNearestEnemyOf(Myself))
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  See(ThirdNearestEnemyOf(Myself))
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  See(FourthNearestEnemyOf(Myself))
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  See(FifthNearestEnemyOf(Myself))
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

IF
  !GlobalTimerNotExpired("MO_SpellCast","LOCALS")
  HaveSpell(CLERIC_INVISIBILITY_PURGE)  // SPPR309.SPL (Invisibility Purge)
  See(SixthNearestEnemyOf(Myself))
  OR(3)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  OR(4)
    CheckSpellState(LastSeenBy(Myself),PROTECTION_FROM_MAGICAL_WEAPONS)
    CheckSpellState(LastSeenBy(Myself),ABSOLUTE_IMMUNITY)
    CheckSpellState(LastSeenBy(Myself),MANTLE)
    CheckSpellState(LastSeenBy(Myself),IMPROVED_MANTLE)
  !StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
  CheckStatLT(Myself,1,TRUE_SIGHT)
  Global("MO_DetectEnemyIllusion","GLOBAL",0)
  CheckStatLT(Myself,20,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
  !CheckSpellState(Myself,WILD_MAGIC_AREA)
  !CheckSpellState(Myself,DEAD_MAGIC_AREA)
THEN
  RESPONSE #100
    SetGlobalTimer("MO_SpellCast","LOCALS",6)
    SetInterrupt(FALSE)
    DisplayStringHead(Myself,@5014)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE) // SPPR309.SPL (Invisibility Purge)
    SetInterrupt(TRUE)
END

// 5e Spellcasting - Wizard Invisibility Purge

// Wizard Invisibility Purge

It should be noted that Spell Revisions drastically changes how detecting invisibile/hidden enemies occurs, so there is a bit of nuance involved.

Edited by morpheus562

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...