"healing"
{
  symbol = "❤️"
  effect = Heal { FLESH }
  cooldown = {10 31}
  sound = "SPELL_HEALING"
}
"advanced healing"
{
  upgrade = "healing"
  symbol = "❤️"
  effect = Name "advanced healing" Heal { FLESH }
  range = 1
  targetSelf = true
  cooldown = {10 31}
  sound = "SPELL_HEALING"
}
"expert healing"
{
  upgrade = "advanced healing"
  symbol = "❤️"
  effect = Name "expert healing" Heal { FLESH }
  targetSelf = true
  range = 4
  cooldown = {10 31}
  sound = "SPELL_HEALING"
}
"group healing"
{
  symbol = "💕"
  effect = Name "group healing" Area 2 Filter Not Enemy Heal { FLESH }
  cooldown = {25 51}
  sound = "SPELL_HEALING"
}
"heal spirit"
{
  symbol = "✴"
  effect = Name "heal spirit" Heal { SPIRIT }
  range = 1
  targetSelf = true
  cooldown = {10 31}
  sound = "SPELL_HEALING"
}
"advanced heal spirit"
{
  upgrade = "heal spirit"
  symbol = "✴"
  effect = Name "advanced heal spirit" Heal { SPIRIT }
  targetSelf = true
  range = 4
  cooldown = {10 31}
  sound = "SPELL_HEALING"
}
"heal spirit group"
{
  symbol = "✴✴"
  effect = Name "heal spirit group" Area 2 Filter Not Enemy Heal { SPIRIT }
  cooldown = {25 51}
  sound = "SPELL_HEALING"
}
"cure poison"
{
  symbol = "⚕"
  effect = Name "cure poison" RemoveLasting POISON
  cooldown = {25 51}
  sound = "SPELL_CURE_POISON"
}
"advanced cure poison"
{
  upgrade = "cure poison"
  symbol = "⚕"
  effect = Name "advanced cure poison" RemoveLasting POISON
  cooldown = {25 51}
  targetSelf = true
  range = 1
  sound = "SPELL_CURE_POISON"
}
"cure blindness"
{
  symbol = "👁"
  effect = Name "cure blindness" RemoveLasting BLIND
  cooldown = {25 51}
  targetSelf = true
  range = 1
  sound = "SPELL_CURE_POISON"
}
"blindness"
{
  symbol = "🕶️"
  effect = Name "blindness" Lasting 5 BLIND
  cooldown = {10
21}
  range = 5
}
"poison resistance"
{
  symbol = "🐍"
  effect = Lasting POISON_RESISTANT
  cooldown = {50 101}
  targetSelf = true
  range = 1
  sound = "SPELL_CURE_POISON"
}
"poison breath"
{
  symbol = "☠"
  effect = Name "poison breath" Area 1 EmitGas "POISON_GAS" 0.5
  fx = {FLAMETHROWER ColorId GREEN}
  range = 4
  cooldown = {15 31}
  sound = "SPELL_BLAST"
  message = "breathe poison!" "breathes poison!"
}
"summon flies"
{
  symbol = "🐝"
  effect = Summon "FLY" {3 7} 100
  cooldown = {30 61}
  sound = "SPELL_SUMMON_INSECTS"
}

Def TryNoFriendlyFire(EffectHit, EffectPass) {
  Filter Or { Attacker Not LastingEffect NO_FRIENDLY_FIRE
      And { Enemy Attacker LastingEffect NO_FRIENDLY_FIRE }} {
    EffectHit
    # This makes the effect return true if there was any creature even if it wasn't injured.
    Filter AnyCreature() NoEffect()
  }
  ReturnFalse Filter Attacker LastingEffect NO_FRIENDLY_FIRE Filter Not Enemy
    EffectPass
}
End

Def MinDistanceFromStrongEnemy(Dist)
  AI And{Distance none Dist AIAfraidOf} 1 -1
End

Def TryMagicMissile()
  TryNoFriendlyFire(
    {
      CreatureMessage {"are hit by the missile" "is hit by the missile"}
      Damage SPELL_DAMAGE SPELL
    },
    CreatureMessage {"are spared by the missile" "is spared by the missile"}
  )
End

"magic missile"
{
  symbol = "⥇"
  effect = MinDistanceFromStrongEnemy(2) Name "magic missile" Description "Shoots a magic missile"
      TryMagicMissile()
  fx = {MAGIC_MISSILE}
  range = 4
  cooldown = {5 21}
  sound = "SPELL_BLAST"
}
"advanced magic missile"
{
  upgrade = "magic missile"
  symbol = "⥇"
  effect = MinDistanceFromStrongEnemy(2) Name "advanced magic missile" Description "Shoots a magic missile"
      TryMagicMissile()
  fx = {MAGIC_MISSILE}
  range = 8
  cooldown = {5 21}
  sound = "SPELL_BLAST"
}
"expert magic missile"
{
  upgrade = "advanced magic missile"
  symbol = "⥇"
  effect = MinDistanceFromStrongEnemy(2) Name "expert magic missile" Description "Shoots a magic missile"
      TryMagicMissile()
  fx = {MAGIC_MISSILE}
  range = 12
  cooldown = {5 21}
  sound = "SPELL_BLAST"
}
"deception"
{
  symbol = "🎭"
  effect = Deception
  cooldown = {30 61}
  sound = "SPELL_DECEPTION"
}
"fog cloud"
{
  symbol = "🌫"
  effect = Name "fog" Description "Creates a fog cloud." Area 4 Filter DistanceD none 3.2 EmitGas "FOG" 1
  cooldown = {30 61}
}
"invisibility"
{
  symbol = "🕵️"
  effect = Lasting INVISIBLE
  cooldown = {100 301}
  sound = "SPELL_INVISIBILITY"
}
"advanced invisibility"
{
  upgrade = "invisibility"
  symbol = "🕵️"
  effect = Name "advanced invisibility" Lasting INVISIBLE
  cooldown = {100 301}
  sound = "SPELL_INVISIBILITY"
}
"automaton invisibility"
{
  symbol = "🕵️"
  effect = Name "invisibility" Lasting 10 INVISIBLE
  cooldown = 20
  sound = "SPELL_INVISIBILITY"
}
"escape"
{
  symbol = "✈️"
  effect = Escape {}
  cooldown = {50 101}
  sound = "SPELL_TELEPORT"
}
"blink"
{
  symbol = "👁️"
  effect = Name "blink" Escape { 2 }
  cooldown = 1
  sound = "SPELL_TELEPORT"
}
"teleport"
{
  symbol = "🌀"
  effect = Teleport
  range = 3
  cooldown = {50 201}
  endOnly = true
  sound = "SPELL_TELEPORT"
}
"advanced teleport"
{
  upgrade = "teleport"
  symbol = "🌀"
  effect = Name "advanced teleport" Teleport
  range = 8
  cooldown = {50 201}
  endOnly = true
  sound = "SPELL_TELEPORT"
}
"automaton teleport"
{
  symbol = "🌀"
  effect = Teleport
  range = 3
  cooldown = 10
  endOnly = true
  sound = "SPELL_TELEPORT"
}
"jump"
{
  symbol = "👟"
  effect = Jump
  range = 3
  cooldown = 10
  message = "jump" "jumps"
  type = ABILITY
}
"panic"
{
  symbol = "😱"
  effect = Lasting PANIC
  range = 5
  cooldown = {25 51}
  sound = "SPELL_STR_BONUS"
}
"pacify"
{
  symbol = "☮"
  effect = Name "pacify" Lasting PEACEFULNESS
  range = 2
  cooldown = {20 61}
  endOnly = true
  sound = "SPELL_STR_BONUS"
}
"haste"
{
  symbol = "🏃"
  effect = Lasting SPEED
  cooldown = {30 61}
  sound = "SPELL_SPEED_SELF"
}
"advanced haste"
{
  upgrade = "haste"
  symbol = "🏃"
  effect = Name "advanced haste" Lasting SPEED
  targetSelf = true
  range = 1
  cooldown = {30 61}
  sound = "SPELL_SPEED_SELF"
}
"warhorse_haste"
{
  symbol = "🐎"
  effect = Name "gallop" ApplyToSteed Lasting SPEED
  cooldown = 50
  sound = "HORSE_GALLOP"
  message = "gallop" "gallops"
}
"slow"
{
  symbol = "🐢"
  effect = Lasting SLOWED
  range = 3
  cooldown = {30 61}
  sound = "SPELL_SPEED_SELF"
}
"magic cancellation"
{
  symbol = "🔮"
  effect = Lasting MAGIC_CANCELLATION
  range = 2
  cooldown = {50 151}
  sound = "SPELL_STR_BONUS"
}
"directed blast"
{
  symbol = "💨"
  effect = Blast
  range = 4
  endOnly = true
  cooldown = {5 21}
  sound = "SPELL_BLAST"
}
"pull"
{
  symbol = "⮄"
  effect = Pull
  range = 6
#    endOnly = true
  cooldown = {5 21}
  sound = "SPELL_BLAST"
}
"circular blast"
{
  symbol = "💥"
  effect = CircularBlast
  cooldown = {5 21}
  sound = "SPELL_AIR_BLAST"
  message = "create an air blast!" "creates an air blast!"
}
"defense bonus"
{
  symbol = "🛡"
  effect = Name "defense bonus" Lasting 40 DEF_BONUS
  cooldown = {30 81}
  sound = "SPELL_DEX_BONUS"
}
"advanced defense bonus"
{
  upgrade = "defense bonus"
  symbol = "🛡"
  effect = Name "advanced defense bonus" Lasting 40 DEF_BONUS
  targetSelf = true
  range = 1
  cooldown = {30 81}
  sound = "SPELL_DEX_BONUS"
}
"mass defense bonus"
{
  upgrade = "advanced defense bonus"
  symbol = "🛡"
  effect = Name "mass defense bonus" Area 10 Filter Not Enemy Lasting 40 DEF_BONUS
  cooldown = {30 81}
  sound = "SPELL_DEX_BONUS"
}
"damage bonus"
{
  symbol = "💪"
  effect = Name "damage bonus" Lasting 40 DAM_BONUS
  cooldown = {30 81}
  sound = "SPELL_STR_BONUS"
}
"advanced damage bonus"
{
  upgrade = "damage bonus"
  symbol = "💪"
  effect = Name "advanced damage bonus" Lasting 40 DAM_BONUS
  targetSelf = true
  range = 1
  cooldown = {30 81}
  sound = "SPELL_STR_BONUS"
}
"mass damage bonus"
{
  upgrade = "advanced damage bonus"
  symbol = "💪"
  effect = Name "mass damage bonus" Area 10 Filter Not Enemy Lasting 40 DAM_BONUS
  cooldown = {30 81}
  sound = "SPELL_STR_BONUS"
}
"bolster"
{
  symbol = "🛡"
  effect = Name "bolster" Area 1 Filter Not Enemy Lasting 40 DEF_BONUS 
  cooldown = {30 81}
  sound = "SPELL_DEX_BONUS"
}
"rally"
{
  symbol = "💪"
  effect = Name "rally" Area 1 Filter Not Enemy Lasting 40 DAM_BONUS 
  cooldown = {30 81}
  sound = "SPELL_DEX_BONUS"
}
"summon element"
{
  symbol = "👾"
  effect = SummonElement
  cooldown = {30 81}
  sound = "SPELL_SUMMON_SPIRIT"
}
"meteor shower"
{
  symbol = "☄"
  effect = Name "meteor shower" PlaceFurniture "METEOR_SHOWER"
  cooldown = {30 81}
  sound = "SPELL_METEOR_SHOWER"
}
"fire elemental"
{
  symbol = "👾"
  effect = Name "fire elemental" Summon "FIRE_ELEMENTAL" { 1 2 } 100
  cooldown = {30 81}
  sound = "SPELL_FIRE_SPHERE_PET"
}
"advanced fire elemental"
{
  upgrade = "fire elemental"
  symbol = "👾"
  effect = Name "advanced fire elemental" Summon "FIRE_ELEMENTAL" { 2 4 } 100
  cooldown = {30 81}
  sound = "SPELL_FIRE_SPHERE_PET"
}
"fire breath"
{
  symbol = "🐲"
  effect = Name "fire breath" Fire
{}
  fx = {FLAMETHROWER ColorId LIGHT_RED}
  range = 4
  cooldown = {15 31}
  sound = "SPELL_BLAST"
  message = "breathe fire!" "breathes fire!"
}
"oil breath"
{
  symbol = "🛢"
  effect = Name "oil breath" Lasting OIL
  fx = {FLAMETHROWER ColorId BLACK}
  range = 4
  cooldown = {15 31}
  sound = "SPELL_BLAST"
  message = "spit oil!" "spits oil!"
}
"firewall"
{
  symbol = "𝍔"
  effect =  Name "firewall" CustomArea PlaceFurniture "FIRE_WALL" { {0 -2} {0 -1} {0 0} {0 1} {0 2} }
  endOnly = true
  range = 2
  cooldown = {15 31}
  sound = "SPELL_BLAST"
}
"fire trap"
{
  symbol = "◌"
  effect =  Name "fire trap" AI Enemy 0 1 AI Not Enemy 1 0 CustomArea PlaceFurniture "FIRE_WALL"
      { {0 -2} {1 -2} {2 -1} {2 0} {2 1} {1 2} {0 2} {-1 2} {-2 1} {-2 0} {-2 -1} {-1 -2} }
  endOnly = true
  range = 8
  cooldown = {15 31}
  sound = "SPELL_BLAST"
}
"fireball"
{
  symbol = "🔥"
  effect = Name "fireball" Fire {}
  fx = {FIREBALL}
  range = 4
  cooldown = {15 31}
  sound = "SPELL_FIRE_SPHERE_PET"
}
"earth elemental"
{
  symbol = "👾"
  effect = Name "earth elemental" Summon "EARTH_ELEMENTAL" 1 100
  cooldown = {30 81}
  sound = "SPELL_FIRE_SPHERE_PET"
}
"advanced earth elemental"
{
  upgrade = "earth elemental"
  symbol = "👾"
  effect = Name "advanced earth elemental" Summon "EARTH_ELEMENTAL" { 2 4 } 100
  cooldown = {30 81}
  sound = "SPELL_FIRE_SPHERE_PET"
}
"ice cone"
{
  symbol = "❄"
  effect = Name "ice cone" Ice
{}
  fx = {FLAMETHROWER ColorId LIGHT_BLUE}
  range = 4
  cooldown = {15 31}
  #sound = "SPELL_FIRE_SPHERE_PET"
}
"acid stream"
{
  symbol = "🜅"
  effect = Name "acid stream" Acid
{}
  fx = {FLAMETHROWER ColorId YELLOW}
  range = 4
  cooldown = {15 31}
  message = "spit acid!" "spits acid!"
}
"black smoke breath"
{
  symbol = "🚬"
  effect = Name "black smoke" Area 1 EmitGas "BLACK_SMOKE" 1
  fx = {FLAMETHROWER ColorId BLACK}
  range = 4
  cooldown = {15 31}
  message = "breathe black smoke!" "breathes black smoke!"
}
"shove"
{
  symbol = "👉"
  effect = Shove
  range = 1
  cooldown = {15 31}
  message = "use an ability" "uses an ability"
  type = ABILITY
}
"swap positions"
{
  symbol = "⇅"
  effect = SwapPosition
  range = 1
  cooldown = {15 31}
  message = "use an ability" "uses an ability"
}
"black dragon blindness"
{
  symbol = "🙈"
  effect = Name "black dragon blindness" Area 30 Filter Enemy Lasting BLIND
  cooldown = 3
}
"dragon greeting"
{
  symbol = "🏠"
  range = 10
  effect = Name "invisible visitor greeting" Description "Special greeting for invisible visitors"
    Filter And { Attacker InTerritory LastingEffect INVISIBLE } AI And{} 0 1 {
      PlayerMessage CRITICAL "Well thief! I smell you and I feel your air. I hear your breath. Come along!"
      Analytics "milestone" "dragonGreeting"
    }
  cooldown = 100000
  message = "" ""
}
"grant wish"
{
  symbol = "$"
  effect = Name "grant wish" { Wish Caster Suicide TURN_INVISIBLE }
  range = 1
  targetSelf = false
  cooldown = 150
}
"double trouble"
{
  symbol = "👤👤"
  effect = DoubleTrouble
  cooldown = {300 1001}
}
"animate weapons"
{
  symbol = "⚔️"
  effect = Name "animate weapons" AnimateItems 5 5 {30 50} WEAPON
  cooldown = {50 201}
}
"animate corpses"
{
  symbol = "👤"
  effect = Name "animate corpses" AnimateItems 3 5 {10 20} CORPSE
  cooldown = {50 201}
}
"advanced animate corpses"
{
  upgrade = "animate corpses"
  symbol = "👤"
  effect = Name "advanced animate corpses" AnimateItems 6 5 {30 50} CORPSE
  cooldown = {50 201}
}
"adoxie right hand"
{
  symbol = "-."
  effect = Name "adoxie right hand" Summon "ADOXIE_HAND_RIGHT" { 1 } 50
  cooldown = 50
  sound = "SPELL_SUMMON_SPIRIT"
}
"adoxie left hand"
{
  symbol = ".-"
  effect = Name "adoxie left hand" Summon "ADOXIE_LEFT_HAND" { 1 } 50
  cooldown = 50
  sound = "SPELL_SUMMON_SPIRIT"
}
"adoxie left foot"
{
  symbol = "_|"
  effect = Name "adoxie left foot" Summon "ADOXIE_FOOT_LEFT" { 1 } 50
  cooldown = 50
  sound = "SPELL_SUMMON_SPIRIT"
}
"adoxie right foot"
{
  symbol = "|_"
  effect = Name "adoxie right foot" Summon "ADOXIE_FOOT_RIGHT" { 1 } 50
  cooldown = 50
  sound = "SPELL_SUMMON_SPIRIT"
}
"dig"
{
  symbol = "X"
  effect = Name "dig" DestroyWalls DIG
  range = 7
  cooldown = 10
  blockedByWall = false
}

Def OneTimeAbility(SpellName, SpellDesc, SpellEffect, SpellSymbol)
SpellName
{
  effect = AI And{} 0 1 Name SpellName Description SpellDesc {
    SpellEffect
    RemoveAbility SpellName
  }
  symbol = SpellSymbol
  cooldown = 1
}
End

OneTimeAbility("ennoblement", "Reaches the status of a vampire lord.", { SetViewId {"vampire_lord"} SetCreatureName "vampire lord" }, "🧛")
OneTimeAbility("bypass allies", "All ranged attacks will bypass allies.", Permanent NO_FRIENDLY_FIRE, "🎯")


Def AnyCreature() Health 0 1 End
Def NoEffect() Unlock "nothing" End

"shoot arrow"
{
  symbol = "↣"
  effect = MinDistanceFromStrongEnemy(4) Name "shoot arrow" Description "Shoots an arrow"
      TryNoFriendlyFire(
        {
          CreatureMessage { "are hit by the arrow" "is hit by the arrow"}
          Damage RANGED_DAMAGE SHOOT
        },
        CreatureMessage { "are spared by the arrow" "is spared by the arrow"}
      )
  range = 7
  cooldown = 1
  maxHits = 1
  projectileViewId = {"arrow"}
  message = "shoot an arrow" "shoots an arrow"
  type = ABILITY
}
"shoot bolt"
{
  symbol = "⇾"
  effect = MinDistanceFromStrongEnemy(4) Name "shoot bolt" Description "Shoots a bolt"
      TryNoFriendlyFire(
        {
          CreatureMessage { "are hit by the bolt" "is hit by the bolt"}
          Damage RANGED_DAMAGE SHOOT
        },
        CreatureMessage { "are spared by the bolt" "is spared by the bolt"}
      )
  range = 14
  cooldown = 3
  maxHits = 1
  projectileViewId = {"arrow"}
  message = "shoot a bolt" "shoots a bolt"
  type = ABILITY
}
"audience"
{
  symbol = "👑"
  effect = Audience none
  cooldown = {50 101}
}
"repair automaton"
{
  symbol = "🔧"
  effect = Name "repair automaton" Description "Repairs broken automaton parts" Filter Automaton RegrowBodyPart 10
  range = 1
  targetSelf = true
  cooldown = 15
  sound = "TRAP_ARMING"
  message = "repair the automaton" "repairs the automaton"
  type = ABILITY
}
"chicken"
{
  symbol = "🐔"
  effect = Name "chicken" Description "Turn an enemy into a chicken!"
      Filter Not CreatureId "CHICKEN" AI Enemy -1 1 {
    Polymorph "CHICKEN" 30
    Permanent INVULNERABLE
  }
  range = 5
  endOnly = true
  targetSelf = true
  cooldown = {30 61}
  message = "play a trick!" "plays a trick!"
}
"shapeshift"
{
  symbol = "⇝"
  effect = Name "shapeshift" Description "Change into a random monster" AI And {} 0 1 {
    Polymorph none 100
    SetCreatureName "shapeshifter"
  }
  message = "" ""
  cooldown = 1
}
"berserker"
{
  symbol = "🐻"
  effect = Name "berskerker" Description "Change into a bear!" AI Health 0.6 1.0 1 -2 {
    Polymorph "CAVE_BEAR" 30
    IncreaseAttr DAMAGE 20
  }
  message = "" ""
  cooldown = 100
}
"summon chicken"
{
  symbol = "🐤"
  effect = Summon "CHICKEN" 1 15
  message = "cluck" "clucks"
  cooldown = 5
  type = ABILITY
}
"summon more chickens"
{
  upgrade = "summon chicken"
  symbol = "🐤🐤"
  effect = Name "summon more chickens" Summon "CHICKEN" {3 5} 15
  message = "cluck" "clucks"
  cooldown = {3 10}
  type = ABILITY
}
"chickenmorph"
{
  symbol = "🐣"
  effect = Name "chickenmorph" Description "Turn yourself or someone into a chicken temporarily!" AI Health 0 0.4 0 1 {
    Polymorph "CHICKEN" 10
    Permanent INVULNERABLE
  }
  cooldown = {30 101}
  message = "cluck" "clucks"
  type = ABILITY
}
"advanced chickenmorph"
{
  upgrade = "chickenmorph"
  symbol = "🐣"
  effect = Name "advanced chickenmorph" Description "Turn yourself or someone into a chicken temporarily!"
      AI And { Health 0.25 1 Not Enemy } 1 -1 AI And { Not CreatureId "CHICKEN" Enemy } -1 1 {
    Polymorph "CHICKEN" 10
    Permanent INVULNERABLE
  }
  targetSelf = true
  endOnly = true
  range = 5
  cooldown = {30 101}
  message = "cluck" "clucks"
  type = ABILITY
}
"chickengeddon"
{
  symbol = "🐓"
  effect = Name "chickengeddon" Description "Turn everyone in the vicinity into a chicken temporarily!"
    Area 20 {
      Polymorph "CHICKEN" 10
      AI And {} 1 -1 Permanent INVULNERABLE
    }
  cooldown = {150 301}
  message = "cluck" "clucks"
  type = ABILITY
}
"balrogs whip"
{
  symbol = "ℒ"
  effect = Name "fiery whip" Description "Causes magical and fire damage" { Fire{} Damage SPELL_DAMAGE SPELL }
  fx = {BALROGS_WHIP ColorId LIGHT_RED}
  range = 4
  cooldown = 2
  endOnly = true
  message = "lash your whip!" "lashes his whip!"
}

"kings charge"
{
  symbol = "👑"
  effect = Name "king's charge" Description "All allies within the radius of 10 receive a +15 damage buff. Can only be used by a tribe leader." {
    Filter Attacker CreatureStatus LEADER Area 10 Filter And{ Not Enemy Distance 1 none } Lasting 40 KINGS_CHARGE
    Filter Not Attacker CreatureStatus LEADER CreatureMessage { "are not worthy!" "is not worthy!" }
  }
  cooldown = 300
  sound = "SPELL_STR_BONUS"
}
