#!/usr/bin/perl
# exorcist.pl
# linda blair and friends as software
# features backwards masking
# v 1.3
# 
# based on ritalinworld.pl
# Distributed under Gnu Public License http://www.gnu.org/copyleft/gpl.html
#
# ambient entertainment for satan worshippers:
# runs on Windows - using black background of DOS Shell.
# should run great in plain DOS mode too.
# sorry, it's no good on Linux for some reason - too slow, optical 
# effects don't work, even in console mode.
#
# may be projected and accompanied by bach's brandenburg concerto #3 
# or of course, mike oldfield's tubular bells.


use Time::HiRes qw(usleep);

# you may comment this next line out if you define @spewings and $seductioninterval below.
require "readme-config.txt";


# these two lines can be configured in the readme-config.txt file or you may set here by 
# uncommenting the next lines:
# my @spewings =  ('the sow is mine', 'my sweet satan', 'let jesus fuck you', '666', 'jesus drinks coke', '666');
# my $seductioninterval = 3000; # frequency of the seductive eyecandy treat. higher is less often.


my $time = time;
srand($$ * $time);

my @curses;
my ($quine, $reversequine) = love_thyself ();

# the following algorithms are largely unexplainable.
while (1) {
	my $limit = 666; 
	my $downtime = 0;
	my $string = ".";
	@curses = spewpicker(3, @spewings);
			
	for ($i=$limit;$i>1;$i--) {
		my $range = $i;
		my $spacefig;
		$downtime = ($downtime * 1.7)/2 + 4; 
		my $halflife = ($i/2);
		my $out = rand($range) + $halflife;
		if ($i > 200) {
			$spacefig = 10;
		}
		elsif ($i > 600 and $i < 1000) {
			$spacefig = 1000;
		}
		else {
			$spacefig = $downtime - 2;
		}
		if (rand($range) < ($halflife)) {
			 for ($j=1;$j<rand($downtime - $spacefig) ;$j++) {
		
				$string = $string . "\.";

				print "$curses[0] $string $curses[1] . $string . $curses[2]\n";
			}
			
			
		}
		else {
			if (int(rand($downtime * 3)) == 2) {
				sleep 1;
			}
			usleep (900 * $downtime);
		}

		if (int(rand($seductioninterval)) == 1) {  # special seductive treat from satan.
			my $treatlength = int(rand(7000)) + 6000;
			for ($j=1;$j<$treatlength ;$j++) {
				print "worship satan 666 ";
			}
			sleep 2;
		}


		if (int (rand(9999)) == 1) {
			my $treatlength = int(rand(30)) + 30;
			for ($j=1;$j<$treatlength ;$j++) {
				if (int (rand(4)) == 1) {
					print "$reversequine\n";
				}
				else {
					print "$quine\n";
				}
				
			}
			sleep 3;
		}
		
	}

}

sub spewpicker {
	my ($numspewings, @spewings) = @_;
	my $backwardsmasking;
	if (int(rand(3)) == 1) {
		$backwardsmasking = 1;
	}
	my $i;
	my @returnspewings = ();
	for ($i=1;$i<=$numspewings ;$i++) {
		my $pickme = int(rand(@spewings));
		if ($backwardsmasking) {$spewings[$pickme] = reverse $spewings[$pickme]}
		push (@returnspewings, $spewings[$pickme]);

	}

	return @returnspewings;
}

sub love_thyself {
	my @lines = ();
	my @code = ();
	open ME, "./exorcist.pl";
	while (<ME>) {
		chomp $_;
		my $pushline = $_ . " ";
		push (@lines, $pushline);
	}

	close ME;
	my $lines = "@lines";
	my @codewords = split (" ", $lines);


	foreach my $word (@codewords) {
		my $pushword = $word . " 666 ";
		push (@code, $pushword);
 	}
	my $code = "@code";
	my $reversecode = reverse $code;

	
	return ($code, $reversecode);
}