//Karaea's script (BGT/Tutu version)
IF
  Dead("agkaraea")
THEN
  RESPONSE #100
    DestroySelf()
END

IF
  Global("ag_karbg","GLOBAL",1)
  !AreaCheck("%nshk%")
  !AreaCheck("AG4815")
THEN
  RESPONSE #100
    SetGlobal("ag_karbg","GLOBAL",0)
END

IF
  Global("ag_karbg","GLOBAL",0)
  OR(2)
    AreaCheck("%nshk%")
    AreaCheck("AG4815")
THEN
  RESPONSE #100
    SetGlobal("ag_karbg","GLOBAL",1)
END

IF
  GlobalLT("endofbg1","GLOBAL",2)
  GlobalGT("Chapter","GLOBAL",%chp%)
  OR(2)
    AreaCheck("%nshk%")
    AreaCheck("AG4815")
THEN
  RESPONSE #100
    DestroySelf()
END

IF
  GlobalGT("Chapter","GLOBAL",7)
  OR(2)
    AreaCheck("AR2010")
    AreaCheck("AG2020")
THEN
  RESPONSE #100
    DestroySelf()
END

IF
  OnCreation()
  AreaCheck("%nshk%")
  OR(2)
    TimeLT(6)
    TimeGT(21)
THEN
  RESPONSE #100
    JumpToPoint([2986.2064])
    SetGlobal("agkarund","LOCALS",1)
    Deactivate(Myself)
END

IF
  OnCreation()
  AreaCheck("AR2010")
  OR(2)
    TimeLT(6)
    TimeGT(21)
THEN
  RESPONSE #100
    JumpToPoint([814.392])
    SetGlobal("agkarund","LOCALS",1)
    Deactivate(Myself)
END

IF
  OnCreation()
  AreaCheck("AG4815")
  !TimeLT(6)
  !TimeGT(21)
THEN
  RESPONSE #100
    JumpToPoint([388.248])
    SetGlobal("agkarund","LOCALS",0)
    Deactivate(Myself)
END

IF
  OnCreation()
  AreaCheck("AG2020")
  !TimeLT(6)
  !TimeGT(21)
THEN
  RESPONSE #100
    JumpToPoint([378.248])
    SetGlobal("agkarund","LOCALS",0)
    Deactivate(Myself)
END

//Nashkel: Karaea walks to market at dawn if not active
IF
  AreaCheck("%nshk%")
  Time(6)
  Global("agkarund","LOCALS",1)
THEN
  RESPONSE #100
    Activate(Myself)
    MoveToPointNoInterrupt([1550.710])
    Face(2)
    SetGlobal("agkarund","LOCALS",0)
END

//Nashkel: Karaea jumps to market after dawn if not active
IF
  AreaCheck("%nshk%")
  !TimeLT(7)
  !TimeGT(21)
  Global("agkarund","LOCALS",1)
THEN
  RESPONSE #100
    Activate(Myself)
    JumpToPoint([1550.710])
    Face(2)
    SetGlobal("agkarund","LOCALS",0)
END

//Nashkel: Karaea walks home at dusk
IF
  AreaCheck("%nshk%")
  !See(NearestEnemyOf())
  Time(22)
  Global("agkarund","LOCALS",0)
THEN
  RESPONSE #100
    MoveToPointNoInterrupt([2986.2064])
    Deactivate(Myself)
    SetGlobal("agkarund","LOCALS",1)
END

//Nashkel: Karaea jumps home after dusk
IF
  AreaCheck("%nshk%")
  OR(2)
    TimeLT(6)
    TimeGT(22)
  Global("agkarund","LOCALS",0)
THEN
  RESPONSE #100
    JumpToPoint([2986.2064])
    Deactivate(Myself)
    SetGlobal("agkarund","LOCALS",1)
END

//Below Nashkel: Karaea enters at night if not active
IF
  AreaCheck("AG4815")
  Time(22)
  Global("agkarund","LOCALS",0)
THEN
  RESPONSE #100
    Activate(Myself)
    MoveToPointNoInterrupt([302.314])
    MoveToPointNoInterrupt([184.264])
    Face(14)
    SetGlobal("agkarund","LOCALS",1)
END

//Below Nashkel: Karaea appears at night if not active
IF
  AreaCheck("AG4815")
  OR(2)
    TimeLT(6)
    TimeGT(22)
  Global("agkarund","LOCALS",0)
THEN
  RESPONSE #100
    Activate(Myself)
    JumpToPoint([184.264])
    Face(14)
    SetGlobal("agkarund","LOCALS",1)
END

//Below Nashkel: Karaea goes upstairs at dawn
IF
  AreaCheck("AG4815")
  !See(NearestEnemyOf())
  Time(6)
  Global("agkarund","LOCALS",1)
THEN
  RESPONSE #100
    MoveToPointNoInterrupt([302.314])
    MoveToPointNoInterrupt([388.248])
    SetGlobal("agkarund","LOCALS",0)
    Deactivate(Myself)
END

//Below Nashkel: Karaea jumps upstairs after dawn
IF
  AreaCheck("AG4815")
  !TimeLT(7)
  !TimeGT(21)
  Global("agkarund","LOCALS",1)
THEN
  RESPONSE #100
    JumpToPoint([388.248])
    SetGlobal("agkarund","LOCALS",0)
    Deactivate(Myself)
END

//Trademeet: Karaea walks to market at dawn if not active
IF
  AreaCheck("AR2010")
  Time(6)
  Global("agkarund","LOCALS",1)
THEN
  RESPONSE #100
    Activate(Myself)
    MoveToPointNoInterrupt([410.704])
    Face(0)
    SetGlobal("agkarund","LOCALS",0)
END

//Trademeet: Karaea jumps to market after dawn if not active
IF
  AreaCheck("AR2010")
  !TimeLT(7)
  !TimeGT(21)
  Global("agkarund","LOCALS",1)
THEN
  RESPONSE #100
    Activate(Myself)
    JumpToPoint([410.704])
    Face(0)
    SetGlobal("agkarund","LOCALS",0)
END

//Trademeet: Karaea walks home at dusk
IF
  AreaCheck("AR2010")
  !See(NearestEnemyOf())
  Time(22)
  Global("agkarund","LOCALS",0)
THEN
  RESPONSE #100
    MoveToPointNoInterrupt([814.392])
    SetGlobal("agkarund","LOCALS",1)
    Deactivate(Myself)
END

//Trademeet: Karaea jumps home after dusk
IF
  AreaCheck("AR2010")
  OR(2)
    TimeLT(6)
    TimeGT(22)
  Global("agkarund","LOCALS",0)
THEN
  RESPONSE #100
    JumpToPoint([814.392])
    SetGlobal("agkarund","LOCALS",1)
    Deactivate(Myself)
END

//Below Trademeet: Karaea enters at night if not active
IF
  AreaCheck("AG2020")
  Time(22)
  Global("agkarund","LOCALS",0)
THEN
  RESPONSE #100
    Activate(Myself)
    MoveToPointNoInterrupt([292.314])
    MoveToPointNoInterrupt([170.266])
    Face(14)
    SetGlobal("agkarund","LOCALS",1)
END

//Below Trademeet: Karaea appears at night if not active
IF
  AreaCheck("AG2020")
  OR(2)
    TimeLT(6)
    TimeGT(22)
  Global("agkarund","LOCALS",0)
THEN
  RESPONSE #100
    Activate(Myself)
    JumpToPoint([170.266])
    Face(14)
    SetGlobal("agkarund","LOCALS",1)
END

//Below Trademeet: Karaea goes upstairs at dawn
IF
  AreaCheck("AG2020")
  !See(NearestEnemyOf())
  Time(6)
  Global("agkarund","LOCALS",1)
THEN
  RESPONSE #100
    MoveToPointNoInterrupt([292.314])
    MoveToPointNoInterrupt([378.248])
    SetGlobal("agkarund","LOCALS",0)
    Deactivate(Myself)
END

//Below Trademeet: Karaea jumps upstairs after dawn
IF
  AreaCheck("AG2020")
  !TimeLT(7)
  !TimeGT(21)
  Global("agkarund","LOCALS",1)
THEN
  RESPONSE #100
    JumpToPoint([378.248])
    SetGlobal("agkarund","LOCALS",0)
    Deactivate(Myself)
END

//Karaea announces her shop at first sighting
IF
  Global("ag_karawalk","GLOBAL",0)
  !See(NearestEnemyOf())
  See([GOODCUTOFF])
  IsActive(Myself)
THEN
  RESPONSE #100
    Wait(2)
    SetGlobal("ag_karawalk","GLOBAL",1)
    DisplayString(Myself,@273)
END

//Add journal entries
IF
  Global("ag_goosehunt","GLOBAL",1)
  Global("ag_karanoloop","GLOBAL",0)
THEN
  RESPONSE #100
    SetGlobal("ag_karanoloop","GLOBAL",1)
    AddJournalEntry(@149,QUEST)
END

IF
  GlobalGT("ag_goosehunt","GLOBAL",11)
  Global("ag_karanoloop","GLOBAL",1)
THEN
  RESPONSE #100
    SetGlobal("ag_karanoloop","GLOBAL",2)
    EraseJournalEntry(@149)
    AddJournalEntry(@150,QUEST_DONE)
END

//If the PC has been really rude to Karaea
IF
  GlobalGT("ag_karrude","GLOBAL",9)
THEN
  RESPONSE #100
    StartDialogueNoSet(Player1)
END

//Combat
IF
  HPPercentLT(Myself,15)
  !HasItem("agjam04",Myself)
THEN
  RESPONSE #100
    EscapeArea()
END

IF
  HPPercentLT(Myself,25)
  !HasItem("agjam04",Myself)
  Detect(NearestEnemyOf())
THEN
  RESPONSE #100
    RunAwayFromNoInterrupt(NearestEnemyOf(),45)
    Hide()
END

IF
  HPPercentLT(Myself,50)
  !GlobalTimerNotExpired("agk","LOCALS")
  HasItem("agjam04",Myself)
THEN
  RESPONSE #100
    UseItem("agjam04",Myself)
    SetGlobalTimer("agk","LOCALS",6)
END

IF
  StateCheck(Myself,STATE_POISONED)
  !GlobalTimerNotExpired("agk","LOCALS")
  HasItem("agjam02",Myself)
THEN
  RESPONSE #100
    UseItem("agjam02",Myself)
    SetGlobalTimer("agk","LOCALS",6)
END

IF
  HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
  !GlobalTimerNotExpired("agk","LOCALS")
  HPPercentLT(Myself,75)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(Myself,CLERIC_CURE_LIGHT_WOUNDS)
END

IF
  AttackedBy([GOODCUTOFF],DEFAULT)
  !Allegiance(Myself,ENEMY)
THEN
  RESPONSE #100
    Shout(99)
    Shout(124)
    Enemy()
END

IF
  StealFailed([0])
  !Allegiance(Myself,ENEMY)
THEN
  RESPONSE #100
    StartDialogOverride("agsteal1",LastTrigger)
END

IF
  OR(4)
    !Allegiance(Myself,ENEMY)
    !IsActive(Myself)
    StateCheck(Myself,STATE_INVISIBLE)
    StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
THEN
  RESPONSE #100
    NoAction()
END

IF
  HasItem("%tsu%potn14",Myself)
  !GlobalTimerNotExpired("agk","LOCALS")
THEN
  RESPONSE #100
    UseItem("%tsu%potn14",Myself)
    SetGlobalTimer("agk","LOCALS",6)
END

IF
  HaveSpell(CLERIC_INVISIBILITY_PURGE)
  !GlobalTimerNotExpired("agk","LOCALS")
  Detect([GOODCUTOFF])
  !See(LastSeenBy())
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE)
END

IF
  HaveSpell(WIZARD_MIRROR_IMAGE)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(Myself,STATE_MIRRORIMAGE)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(Myself,WIZARD_MIRROR_IMAGE)
END

IF
  HaveSpell(WIZARD_BLUR)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(Myself,STATE_BLUR)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(Myself,WIZARD_BLUR)
END

IF
  !See([GOODCUTOFF.0.0.MAGE_ALL])
  !See([GOODCUTOFF.0.0.CLERIC_ALL])
  !See([GOODCUTOFF.0.0.DRUID_ALL])
  !See([GOODCUTOFF.0.0.BARD_ALL])
  !See([GOODCUTOFF])
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  HaveSpell(WIZARD_FIREBALL)
  !GlobalTimerNotExpired("agk","LOCALS")
  !Range(LastSeenBy(),10)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
  !HasBounceEffects(LastSeenBy())
  CheckStatLT(LastSeenBy(),50,RESISTMAGICFIRE)
  CheckStatLT(LastSeenBy(),50,RESISTMAGIC)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),WIZARD_FIREBALL)
END

IF
  HaveSpell(WIZARD_SPIDER_SPAWN)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),WIZARD_SPIDER_SPAWN)
END

IF
  HaveSpell(WIZARD_STONE_SKIN)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(Myself,WIZARD_STONE_SKIN)
END

IF
  HaveSpell(CLERIC_MENTAL_DOMINATION)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(LastSeenBy(),STATE_SLEEPING)
  !StateCheck(LastSeenBy(),STATE_HELPLESS)
  !StateCheck(LastSeenBy(),STATE_CONFUSED)
  !StateCheck(LastSeenBy(),STATE_PANIC)
  !HasBounceEffects(LastSeenBy())
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),CLERIC_MENTAL_DOMINATION)
END

IF
  HaveSpell(CLERIC_ANIMAL_SUMMONING_1)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),CLERIC_ANIMAL_SUMMONING_1)
END

IF
  HaveSpell(CLERIC_ARMOR_OF_FAITH)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(Myself,CLERIC_ARMOR_OF_FAITH)
END

IF
  HaveSpell(CLERIC_DISPEL_MAGIC)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(LastSeenBy(),STATE_SLEEPING)
  !StateCheck(LastSeenBy(),STATE_HELPLESS)
  !StateCheck(LastSeenBy(),STATE_CONFUSED)
  !StateCheck(LastSeenBy(),STATE_PANIC)
  !HasBounceEffects(LastSeenBy())
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),CLERIC_DISPEL_MAGIC)
END

IF
  HaveSpell(WIZARD_CONFUSION)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(LastSeenBy(),STATE_SLEEPING)
  !StateCheck(LastSeenBy(),STATE_HELPLESS)
  !StateCheck(LastSeenBy(),STATE_CONFUSED)
  !StateCheck(LastSeenBy(),STATE_PANIC)
  !HasBounceEffects(LastSeenBy())
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),WIZARD_CONFUSION)
END

IF
  HaveSpell(WIZARD_MONSTER_SUMMONING_1)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),WIZARD_MONSTER_SUMMONING_1)
END

IF
  HaveSpell(WIZARD_MELF_METEOR)
  !GlobalTimerNotExpired("agk","LOCALS")
  !HasItem("melfmet",Myself)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(Myself(),WIZARD_MELF_METEOR)
END

IF
  HaveSpell(CLERIC_SUMMON_INSECTS)
  !GlobalTimerNotExpired("agk","LOCALS")
  !HasBounceEffects(LastSeenBy())
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),CLERIC_SUMMON_INSECTS)
END

IF
  HaveSpell(CLERIC_HOLD_PERSON)
  !GlobalTimerNotExpired("agk","LOCALS")
  !HasBounceEffects(LastSeenBy())
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),CLERIC_HOLD_PERSON)
END

IF
  HaveSpell(WIZARD_MELF_ACID_ARROW)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
  !HasBounceEffects(LastSeenBy())
  CheckStatLT(LastSeenBy(),50,RESISTACID)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),WIZARD_MELF_ACID_ARROW)
END

IF
  HaveSpell(WIZARD_AGANNAZAR_SCORCHER)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
  !HasBounceEffects(LastSeenBy())
  CheckStatLT(LastSeenBy(),50,RESISTFIRE)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),WIZARD_AGANNAZAR_SCORCHER)
END

IF
  HaveSpell(WIZARD_CHARM_PERSON)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(LastSeenBy(),STATE_SLEEPING)
  !StateCheck(LastSeenBy(),STATE_HELPLESS)
  !HasBounceEffects(LastSeenBy())
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),WIZARD_CHARM_PERSON)
END

IF
  HaveSpell(WIZARD_SLEEP)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(LastSeenBy(),STATE_SLEEPING)
  !StateCheck(LastSeenBy(),STATE_HELPLESS)
  !HasBounceEffects(LastSeenBy())
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),WIZARD_SLEEP)
END

IF
  HaveSpell(CLERIC_COMMAND)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(LastSeenBy(),STATE_SLEEPING)
  !StateCheck(LastSeenBy(),STATE_HELPLESS)
  !StateCheck(LastSeenBy(),STATE_CONFUSED)
  !StateCheck(LastSeenBy(),STATE_PANIC)
  !HasBounceEffects(LastSeenBy())
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),CLERIC_COMMAND)
END

IF
  HaveSpell(WIZARD_CHROMATIC_ORB)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
  !HasBounceEffects(LastSeenBy())
  CheckStatLT(LastSeenBy(),50,RESISTMAGIC)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),WIZARD_CHROMATIC_ORB)
END

IF
  HaveSpell(WIZARD_BLINDNESS)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
  !HasBounceEffects(LastSeenBy())
  CheckStatLT(LastSeenBy(),50,RESISTMAGIC)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),WIZARD_BLINDNESS)
END

IF
  HaveSpell(WIZARD_MAGIC_MISSILE)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
  !HasBounceEffects(LastSeenBy())
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),WIZARD_MAGIC_MISSILE)
END

IF
  HaveSpell(CLERIC_DOOM)
  !GlobalTimerNotExpired("agk","LOCALS")
  !StateCheck(LastSeenBy(),STATE_SLEEPING)
  !StateCheck(LastSeenBy(),STATE_HELPLESS)
  !HasBounceEffects(LastSeenBy())
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("agk","LOCALS",6)
    Spell(LastSeenBy(),CLERIC_DOOM)
END

IF
  GlobalTimerNotExpired("agk","LOCALS")
THEN
  RESPONSE #100
    AttackOneRound(LastSeenBy())
END

IF
  !GlobalTimerNotExpired("agk","LOCALS")
THEN
  RESPONSE #100
    Attack(LastSeenBy())
END
