IF
  Name("PSIDARK1",Myself)
  Global("prep","LOCALS",0)
  Detect([GOODCUTOFF])
THEN
  RESPONSE #100
    SetGlobal("prep","LOCALS",1)
    ApplySpell(Myself,WIZARD_STONE_SKIN)
    ApplySpell(Myself,WIZARD_HASTE)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_ENERGY_DRAIN)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStatLT(NearestEnemyOf(Myself),60,RESISTMAGIC)
  RandomNumLT(81,45)
  See(NearestEnemyOf(Myself))
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_ENERGY_DRAIN)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_FINGER_OF_DEATH)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(NearestEnemyOf(Myself),0,129)//BP's WIZARD_SPELL_TURNING
  CheckStatGT(NearestEnemyOf(Myself),6,SAVEVSDEATH)
  RandomNumLT(60,36)
  See(NearestEnemyOf(Myself))
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_FINGER_OF_DEATH)
END

IF
  !GlobalTimerNotExpired("OneSpell","LOCALS")
  See([GOODCUTOFF])
THEN
  RESPONSE #100
    Spell([GOODCUTOFF],WIZARD_CHAOS)
    SetGlobalTimer("OneSpell","LOCALS",TWO_ROUNDS)
  RESPONSE #100
    Spell([GOODCUTOFF],WIZARD_DOMINATION)
    SetGlobalTimer("OneSpell","LOCALS",TWO_ROUNDS)
  RESPONSE #100
    Spell([GOODCUTOFF],WIZARD_SYMBOL_FEAR)
    SetGlobalTimer("OneSpell","LOCALS",TWO_ROUNDS)
  RESPONSE #100
    Spell([GOODCUTOFF],WIZARD_FEEBLEMIND)
    SetGlobalTimer("OneSpell","LOCALS",TWO_ROUNDS)
  RESPONSE #100
    Spell(SecondNearestEnemyOf(Myself),WIZARD_CHAOS)
    SetGlobalTimer("OneSpell","LOCALS",TWO_ROUNDS)
  RESPONSE #100
    Spell(SecondNearestEnemyOf(Myself),WIZARD_DOMINATION)
    SetGlobalTimer("OneSpell","LOCALS",TWO_ROUNDS)
  RESPONSE #100
    Spell(TenthNearestEnemyOf(Myself),WIZARD_SYMBOL_FEAR)
    SetGlobalTimer("OneSpell","LOCALS",TWO_ROUNDS)
  RESPONSE #100
    Spell(TenthNearestEnemyOf(Myself),WIZARD_FEEBLEMIND)
    SetGlobalTimer("OneSpell","LOCALS",TWO_ROUNDS)
END

IF
  !GlobalTimerNotExpired("GBBusy","LOCALS")
  Detect([PC])
  Allegiance(Myself,ENEMY)
THEN
  RESPONSE #200
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell([PC],MIND_FLAYER_PSIONIC_BLAST)
  RESPONSE #200
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SecondNearest([PC]),MIND_FLAYER_PSIONIC_BLAST)
  RESPONSE #200
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(ThirdNearest([PC]),MIND_FLAYER_PSIONIC_BLAST)
  RESPONSE #200
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FourthNearest([PC]),MIND_FLAYER_PSIONIC_BLAST)
  RESPONSE #200
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FifthNearest([PC]),MIND_FLAYER_PSIONIC_BLAST)
  RESPONSE #200
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SixthNearest([PC]),MIND_FLAYER_PSIONIC_BLAST)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell([PC],MIND_FLAYER_DOMINATION)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SecondNearest([PC]),MIND_FLAYER_DOMINATION)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(ThirdNearest([PC]),MIND_FLAYER_DOMINATION)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FourthNearest([PC]),MIND_FLAYER_DOMINATION)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FifthNearest([PC]),MIND_FLAYER_DOMINATION)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SixthNearest([PC]),MIND_FLAYER_DOMINATION)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell([PC],PSIONIC_MAZE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SecondNearest([PC]),PSIONIC_MAZE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(ThirdNearest([PC]),PSIONIC_MAZE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FourthNearest([PC]),PSIONIC_MAZE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FifthNearest([PC]),PSIONIC_MAZE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SixthNearest([PC]),PSIONIC_MAZE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell([PC],PSIONIC_DISINTEGRATE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SecondNearest([PC]),PSIONIC_DISINTEGRATE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(ThirdNearest([PC]),PSIONIC_DISINTEGRATE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FourthNearest([PC]),PSIONIC_DISINTEGRATE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FifthNearest([PC]),PSIONIC_DISINTEGRATE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SixthNearest([PC]),PSIONIC_DISINTEGRATE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell([PC],PSIONIC_INFLICT_PAIN)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SecondNearest([PC]),PSIONIC_INFLICT_PAIN)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(ThirdNearest([PC]),PSIONIC_INFLICT_PAIN)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FourthNearest([PC]),PSIONIC_INFLICT_PAIN)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FifthNearest([PC]),PSIONIC_INFLICT_PAIN)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SixthNearest([PC]),PSIONIC_INFLICT_PAIN)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell([PC],PSIONIC_EMOTION_KILL)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SecondNearest([PC]),PSIONIC_EMOTION_KILL)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(ThirdNearest([PC]),PSIONIC_EMOTION_KILL)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FourthNearest([PC]),PSIONIC_EMOTION_KILL)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FifthNearest([PC]),PSIONIC_EMOTION_KILL)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SixthNearest([PC]),PSIONIC_EMOTION_KILL)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell([PC],PSIONIC_LIFE_DRAIN)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SecondNearest([PC]),PSIONIC_LIFE_DRAIN)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(ThirdNearest([PC]),PSIONIC_LIFE_DRAIN)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FourthNearest([PC]),PSIONIC_LIFE_DRAIN)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FifthNearest([PC]),PSIONIC_LIFE_DRAIN)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SixthNearest([PC]),PSIONIC_LIFE_DRAIN)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell([PC],PSIONIC_PROJECT_FORCE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SecondNearest([PC]),PSIONIC_PROJECT_FORCE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(ThirdNearest([PC]),PSIONIC_PROJECT_FORCE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FourthNearest([PC]),PSIONIC_PROJECT_FORCE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FifthNearest([PC]),PSIONIC_PROJECT_FORCE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SixthNearest([PC]),PSIONIC_PROJECT_FORCE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell([PC],PSIONIC_EGOWHIP)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SecondNearest([PC]),PSIONIC_EGOWHIP)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(ThirdNearest([PC]),PSIONIC_EGOWHIP)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FourthNearest([PC]),PSIONIC_EGOWHIP)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FifthNearest([PC]),PSIONIC_EGOWHIP)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SixthNearest([PC]),PSIONIC_EGOWHIP)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell([PC],PSIONIC_BALLISTIC)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SecondNearest([PC]),PSIONIC_BALLISTIC)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(ThirdNearest([PC]),PSIONIC_BALLISTIC)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FourthNearest([PC]),PSIONIC_BALLISTIC)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FifthNearest([PC]),PSIONIC_BALLISTIC)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SixthNearest([PC]),PSIONIC_BALLISTIC)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell([PC],PSIONIC_DETONATE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SecondNearest([PC]),PSIONIC_DETONATE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(ThirdNearest([PC]),PSIONIC_DETONATE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FourthNearest([PC]),PSIONIC_DETONATE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(FifthNearest([PC]),PSIONIC_DETONATE)
  RESPONSE #100
    SetGlobalTimer("GBBusy","LOCALS",ONE_ROUND)
    ReallyForceSpell(SixthNearest([PC]),PSIONIC_DETONATE)
END

