#TouhouDanmakufu
#Title[SakuyaN3_H]
#Text[SakuyaN3_H]
#Player[FREE]
#ScriptVersion[2]
#BGM[.\mu\bgm.mp3]

script_enemy_main {
#include_function ".\Sakuyainclude.txt";

	@Initialize{
	InitializeAction;
	LoadMusic(bgm);
	PlayMusic(bgm);
	LoadSE(shot3);
	LoadSE(time1);
	LoadSE(teleport);
	LoadGraphic(imageFile);
	LoadSE(time2);
	LoadSE(wtf);
	shotinit;
	LoadSE(charge);
	SetAction(ACT_MOVE, 120);
	LoadSE(shot);
	LoadSE(shot2);
	LoadSE(laser);
	LoadSE(familiarspawn);
	LoadGraphic(imglifebar); 
	SetLife(6000);
	LoadSE(shot2);
	SetTimer(45);
	SetInvincibility(260);
	SetDamageRate(175, 55);
	SetMovePosition03(GetCenterX, GetClipMinY + 120, 10, 2);
	LoadGraphic(SP);
	LoadGraphic(MC);
	attack1;
	MagicCircle(false);
	SetShotAutoDeleteClip(50, 30, 50, 10);
	SetEnemyMarker(true);
	SetCommonData("lastattack", false);
	}


task RandomShizzle{
	loop{
	angle = rand(50, 130);
	wait(7);
	loop(2){
	SpinnyKnife(rand(GetX+150, GetX-150), GetY-rand(30, 70), angle);
	}
	}
}


task SpinnyKnife(x, y, angle){

		let obj = Obj_Create(OBJ_SHOT);
		let f = 0;
		
		Obj_SetPosition(obj, x, y);
		Obj_SetSpeed(obj, 0);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, WHITE32);
		ObjShot_SetDelay(obj, 10);
		Obj_SetAutoDelete(obj, true);
		while(f<31){
		f++;
		Obj_SetAngle(obj, Obj_GetAngle(obj)+(f*12));
		wait(1);
		}
		if(f>30){
		Obj_SetSpeed(obj, rand(2, 4));
		Obj_SetAngle(obj, Obj_GetAngle(obj)+180);
	}
}

task attack1 {
	wait(120);
	RandomShizzle;
	loop{
	let playery = GetPlayerY;
	let playerx = GetPlayerX;
	loop(30){
	PlaySE(shot3);
	CreateShot01(GetX+20, GetY, 5, atan2(playery-GetY, playerx - (GetX+20)), 76, 20);
	CreateShot01(GetX+20, GetY, 5, atan2(playery-GetY, (playerx+60) - (GetX+20)), 76, 20);
	CreateShot01(GetX+20, GetY, 5, atan2(playery-GetY, (playerx-60) - (GetX+20)), 76, 20);
	CreateShot01(GetX-20, GetY, 5, atan2(playery-GetY, playerx - (GetX-20)), 76, 20);
	CreateShot01(GetX-20, GetY, 5, atan2(playery-GetY, (playerx+60) - (GetX-20)), 76, 20);
	CreateShot01(GetX-20, GetY, 5, atan2(playery-GetY, (playerx-60) - (GetX-20)), 76, 20);
	wait(2);
	}
	wait(10);
	ExMove;
	wait(50);
}
}


}
