count = 0;
hard = 0;
result = nil;

if GetGameVar("C3M3_HEROIC") == "1" then
	hard = 1;
	print("hard battle");
end;

if GetHeroName(GetAttackerHero()) == "Nadaur" or GetHeroName(GetDefenderHero()) == "Nadaur" then
	nadaur = not nil;
	EnableDynamicBattleMode(1);
	print("fight with Nadaur");
	else nadaur  = nil;
end;

if GetHeroName(GetAttackerHero()) == "Razzak" or GetHeroName(GetDefenderHero()) == "Razzak" then
	razzak = not nil;
	print("fight with Razzak");
	else razzak  = nil;
end;

if GetHeroName(GetAttackerHero()) == "Maahir" or GetHeroName(GetDefenderHero()) == "Maahir" then
	maahir = not nil;
	print("fight with Maahir");
	else maahir  = nil;
end;

function DefenderHeroMove(hero)
	result = nil;
	if hard == 1 and IsHuman(ATTACKER) then
		count = count + 1;
		if nadaur then
			result = elf_move(hero);
		end;
		if razzak then
			result = razzak_move(hero);
		end;
		if maahir then
			result = maahir_move(hero);
		end;
		return result;
	end;
	return nil;
end;

function AttackerHeroMove(hero)
	result = nil;
	if hard == 1 and IsHuman(DEFENDER) then
		count = count + 1;
		if nadaur then
			result = elf_move(hero);
		end;
		if razzak then
			result = razzak_move(hero);
		end;
		if maahir then
			result = maahir_move(hero);
		end;
		return result;
	end;
	return nil;
end;

function elf_move(hero)
	if GetUnitManaPoints(hero) > 30 then
		if count == 1 then
			UnitCastGlobalSpell(hero, 219);
			return not nil;
		end;
		if count == 2 then
			UnitCastGlobalSpell(hero, 221);
			return not nil;
		end;
		if count == 3 then
			UnitCastGlobalSpell(hero, 220);
			return not nil;
		end;
		else return nil;
	end;
	return nil;
end;

function razzak_move(hero)
	if GetUnitManaPoints(hero) > 30 then
		if count == 1 then
			UnitCastGlobalSpell(hero, 218);
			return not nil;
		end;
		if count == 2 then
			UnitCastGlobalSpell(hero, 219);
			return not nil;
		end;
		if count == 3 then
			UnitCastGlobalSpell(hero, 216);
			return not nil;
		end;
		else return nil;
	end;
	return nil;
end;

function maahir_move(hero)
	if GetUnitManaPoints(hero) > 30 then
		if count == 1 then
			UnitCastGlobalSpell(hero, 212);
			return not nil;
		end;
		if count == 2 then
			UnitCastGlobalSpell(hero, 221);
			return not nil;
		end;
		if count == 3 then
			UnitCastGlobalSpell(hero, 210);
			return not nil;
		end;
		if count == 4 then
			UnitCastGlobalSpell(hero, 220);
			return not nil;
		end;
		if count == 5 then
			UnitCastGlobalSpell(hero, 219);
			return not nil;
		end;
		if count == 6 then
			UnitCastGlobalSpell(hero, 215);
			return not nil;
		end;
		if count == 7 then
			UnitCastGlobalSpell(hero, 216);
			return not nil;
		end;
		if count == 8 then
			UnitCastGlobalSpell(hero, 218);
			return not nil;
		end;
		else return nil;
	end;
	return nil;
end;