[unit]
	id=Elder Mage
	name= _ "Elder Mage"
	race=human
	image="units/elder-mage.png"
	{DEFENSE_ANIM "units/elder-mage-defend.png" "units/elder-mage.png" {SOUND_LIST:HUMAN_OLD_HIT} }
	profile=portraits/delfador.png
	hitpoints=55
	movement_type=smallfoot
	[resistance]
		fire=80
	[/resistance]
	movement=6
	experience=100
	level=5
	alignment=neutral
	advanceto=null
	{AMLA_TOUGH 3}
	cost=65
	usage=mixed fighter
	die_sound={SOUND_LIST:HUMAN_OLD_DIE}
	unit_description= _ "Once great, Elder Magi have seen their power a little diminished from wearying years of battle. Nevertheless they remain feared on the battlefield on account of their powerful lightning bolts."
	[attack]
		name=staff
		icon=attacks/staff-magic.png
		type=impact
		range=melee
		damage=8
		number=2
		[animation]
			[frame]
				begin=-250
				end=-200
				image="units/elder-mage.png"
			[/frame]
			[frame]
				begin=-200
				end=-100
				image="units/elder-mage-melee1.png"
			[/frame]
			[if]
				hits=yes
				[frame]
					begin=-100
					end=100
					image="units/elder-mage-melee2.png"
					sound=staff.wav
				[/frame]
			[/if]
			[else]
				hits=no
				[frame]
					begin=-100
					end=100
					image="units/elder-mage-melee2.png"
					sound={SOUND_LIST:MISS}
				[/frame]
			[/else]
			[frame]
				begin=100
				end=150
				image="units/elder-mage-ranged2.png"
			[/frame]
			[frame]
				begin=150
				end=200
				image="units/elder-mage.png"
			[/frame]
		[/animation]
	[/attack]
	
	[attack]
		name=lightning
		icon=attacks/lightning.png
		type=fire
		range=ranged
		[specials]
			{WEAPON_SPECIAL_MAGICAL}
		[/specials]
		damage=14
		number=4
# The lightning bolt animation is a little complex; the bolt itself is
# done as an animated halo, and so it needs to have different halo_x and
# halo_y coordinates for all six directions. For this reason I wrote
# this macro, which is also used to create the bolt variations.
#define ELDER_MAGE_LIGHTNING_BOLTS VARIATION DIR HALO_X HALO_Y
		[animation]
			hits=no
			direction={DIR}
			[frame]
				begin=-300
				end=-200
				image="units/elder-mage-ranged1.png"
				halo=halo/lightning-bolt-{VARIATION}-1.png:100
				halo_x,halo_y={HALO_X},{HALO_Y}
				sound=lightning-miss.ogg
			[/frame]
			[frame]
				begin=-200
				end=-100
				image="units/elder-mage-ranged2.png"
				halo=halo/lightning-bolt-{VARIATION}-2.png
				halo_x,halo_y={HALO_X},{HALO_Y}
			[/frame]
			[frame]
				begin=-100
				end=0
				image="units/elder-mage-ranged1.png"
				halo=halo/lightning-bolt-{VARIATION}-4.png
				halo_x,halo_y={HALO_X},{HALO_Y}
			[/frame]
			[frame]
				begin=0
				end=100
				image="units/elder-mage.png"
				halo=misc/blank-hex.png
				halo_x,halo_y={HALO_X},{HALO_Y}
			[/frame]
		[/animation]
		[animation]
			hits=yes
			direction={DIR}
			[frame]
				begin=-300
				end=-200
				image="units/elder-mage-ranged1.png"
				halo=halo/lightning-bolt-{VARIATION}-1.png:100
				halo_x,halo_y={HALO_X},{HALO_Y}
				sound=lightning.ogg
			[/frame]
			[frame]
				begin=-200
				end=-100
				image="units/elder-mage-ranged2.png"
				halo=halo/lightning-bolt-{VARIATION}-2.png
				halo_x,halo_y={HALO_X},{HALO_Y}
			[/frame]
			[frame]
				begin=-100
				end=100
				image="units/elder-mage-ranged3.png"
				halo=halo/lightning-bolt-{VARIATION}-3.png
				halo_x,halo_y={HALO_X},{HALO_Y}
			[/frame]
			[frame]
				begin=100
				end=200
				image="units/elder-mage-ranged2.png"
				halo=halo/lightning-bolt-{VARIATION}-4.png
				halo_x,halo_y={HALO_X},{HALO_Y}
			[/frame]
			[frame]
				begin=200
				end=250
				image="units/elder-mage-ranged1.png"
				halo=misc/blank-hex.png
				halo_x,halo_y={HALO_X},{HALO_Y}
			[/frame]
		[/animation]
#enddef
# The three variations for the north direction:
		{ELDER_MAGE_LIGHTNING_BOLTS 1 n 0 -210}
		{ELDER_MAGE_LIGHTNING_BOLTS 2 n 0 -210}
		{ELDER_MAGE_LIGHTNING_BOLTS 3 n 0 -210}
# The three variations for the south direction:
		{ELDER_MAGE_LIGHTNING_BOLTS 1 s 0 -72}
		{ELDER_MAGE_LIGHTNING_BOLTS 2 s 0 -72}
		{ELDER_MAGE_LIGHTNING_BOLTS 3 s 0 -72}
# And so on...
		{ELDER_MAGE_LIGHTNING_BOLTS 1 se,sw 54 -104}
		{ELDER_MAGE_LIGHTNING_BOLTS 2 se,sw 54 -104}
		{ELDER_MAGE_LIGHTNING_BOLTS 3 se,sw 54 -104}
		{ELDER_MAGE_LIGHTNING_BOLTS 1 ne,nw 54 -176}
		{ELDER_MAGE_LIGHTNING_BOLTS 2 ne,nw 54 -176}
		{ELDER_MAGE_LIGHTNING_BOLTS 3 ne,nw 54 -176}
	[/attack]
[/unit]
