let Cut = GetCurrentScriptDirectory~"sprites\CutP.png";
let imageFile = GetCurrentScriptDirectory~"sprites\patchy.png";
let variation = 1;
let variable = 1;
let futo = GetCurrentScriptDirectory~"sprites\futo.png";
let shooting = false;
let frame2 = -60;
let frame3 = -60;
let boom = GetCurrentScriptDirectory~"sfx\se_enep01.wav";
let border = GetCurrentScriptDirectory~"sfx\border.wav";
let orb = GetCurrentScriptDirectory~"sfx\orb.wav";
let shot3 = GetCurrentScriptDirectory~"sfx\shot2.wav";
let shot2 = GetCurrentScriptDirectory~"sfx\shot2.wav";
let shot = GetCurrentScriptDirectory~"sfx\shot.wav";
let charge = GetCurrentScriptDirectory~"sfx\Charge.wav";
let wtf = GetCurrentScriptDirectory~"sfx\kira00.wav";
let ping = GetCurrentScriptDirectory~"sfx\ping.wav";
let b = 0;
let hitbox = true;
let collision = true;
let timer = GetTimer;
let time1 = GetCurrentScriptDirectory~"sfx\time1.wav";
let time2 = GetCurrentScriptDirectory~"sfx\time2.wav";
let warp = GetCurrentScriptDirectory~"sfx\warp.wav";
let caution = GetCurrentScriptDirectory~"sfx\caution.wav";
let laser2 = GetCurrentScriptDirectory~"sfx\laser2.wav";
let acc1 = 0;
let acc2 = 0;
let acc3 = 0;
let acc5 = 0;
let ang = 0;
let anim1 = 0;
let c = 0;
let angle = 0;
let anim2 = 0;
let anim3 = 0;
let radius = 0;
let angle = 0;
let CBG1 = GetCurrentScriptDirectory~"sprites\CBG1.png";
let CBG2 = GetCurrentScriptDirectory~"sprites\CBG2.png";
let CBG3 = GetCurrentScriptDirectory~"sprites\CBG3.png";
let CBG4 = GetCurrentScriptDirectory~"sprites\CBG4.png";
let CBG5 = GetCurrentScriptDirectory~"sprites\CBG5.png";
let ang = 0;
let shot3 = GetCurrentScriptDirectory~"sfx\shot3.wav";
let shot4 = GetCurrentScriptDirectory~"sfx\shot4.wav";
let shot4q = GetCurrentScriptDirectory~"sfx\shot4q.wav";
let objbullets = [];
let objgrowers = [];
let variation = 0;
let restangle = 0;
let imglifebar = GetCurrentScriptDirectory~"lifebar_thWW.png";
let familiarspawn = GetCurrentScriptDirectory~"sfx\Shadow.wav";
let bgm = GetCurrentScriptDirectory~"mu\bgm.mp3";
let SP = GetCurrentScriptDirectory~"sprites\futo.png";
let laser = GetCurrentScriptDirectory~"sfx\laser.wav";
let MC = GetCurrentScriptDirectory~"sprites\NMC.png";
let eirinx = 0;
let eiriny = 0;
	#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
	#include_function ".\cutin.dnh"
	#include_function ".\DATA\lib_anime_Patchouli.dnh"
	@MainLoop{
	
	SetCommonData("patchyx", GetX);
	SetCommonData("patchyy", GetY);


	eirinx = GetCommonDataDefault("BossX", 0);
	eiriny = GetCommonDataDefault("BossY", 0);

	restangle = atan2(GetPlayerY - eiriny, GetPlayerX - eirinx)-180;
	
	if(hitbox==true){
	SetCollisionA(GetX, GetY, 22);
	}
	if(collision==true){
	SetCollisionB(GetX, GetY, 16);
	}
	yield;


	
	}

function wait(w){ loop(w){ yield;} }



sub ExMove { ExMove_(GetClipMinY+120, 10, rand(15, 30)); }
function ExMove_(height, ud, length) {
	SetAction(ACT_MOVE, 60);
	if(GetPlayerX < GetX) {
		if(GetX - length <= GetClipMinX) {
			SetMovePosition03(GetX + length+20, rand(height+4 - ud, height + ud), 20, 2);
		} else {
			SetMovePosition03(GetX - length-20, rand(height - ud, height + ud), 20, 2);
		}
	} else {
		if(GetX + length >= GetClipMaxX) {
			SetMovePosition03(GetX - length-20, rand(height - ud, height + ud), 20, 2);
		} else {
			SetMovePosition03(GetX + length+20, rand(height - ud, height + ud), 20, 2);
		}
	}
}

sub ExMoveFar { ExMove_2(GetClipMinY+60, 20, rand(30, 70)); }
function ExMove_2(height, ud, length) {
	SetAction(ACT_MOVE, 90);
	if(GetPlayerX < GetX) {
		if(GetX - length <= GetClipMinX) {
			SetMovePosition03(GetX + length+20, rand(height+4 - ud, height + ud), 5, 1);
		} else {
			SetMovePosition03(GetX - length-20, rand(height - ud, height + ud), 5, 1);
		}
	} else {
		if(GetX + length >= GetClipMaxX) {
			SetMovePosition03(GetX - length-20, rand(height - ud, height + ud), 5, 1);
		} else {
			SetMovePosition03(GetX + length+20, rand(height - ud, height + ud), 5, 1);
		}
	}
}


task SpellDeclare {
SetAction(ACT_SPELL, 90);
wait(90);
SetAction(ACT_MOVE, 10000);
}


function GetDistance(x1,y1,x2,y2){
return(((x2-x1)^2+(y2-y1)^2)^(1/2))
} 


 @DrawLoop {

DrawBoss(imageFile);
}

