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

script_enemy_main {
#include_function ".\Yuyukoinclude.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(laser);
	LoadSE(familiarspawn);
	LoadGraphic(imglifebar); 
	SetLife(6000);
	LoadSE(shot2);
	SetTimer(45);
	SetInvincibility(260);
	SetDamageRate(150, 55);
	SetMovePosition03(GetCenterX, GetClipMinY + 120, 10, 2);
	LoadGraphic(SP);
	LoadGraphic(MC);
	attack1;
	MagicCircle(false);
	SetShotAutoDeleteClip(10, 10, 10, 10);
	SetEnemyMarker(true);
	SetCommonData("lastattack", false);
	}



 task CreateShotReflect(x, y, v, ang, graphic, graphic2, delay, offset) {
		let obj_id = Obj_Create(OBJ_SHOT); let border = 10; let  counter = 0;
		Obj_SetPosition(obj_id, x, y);
		ObjShot_SetGraphic(obj_id, graphic);
		Obj_SetSpeed(obj_id, v); Obj_SetAngle(obj_id, ang); ObjShot_SetDelay(obj_id, delay);
		while(!Obj_BeDeleted(obj_id)) {
			if(counter <= 1) {
			
				if(Obj_GetX(obj_id) > GetClipMaxX+border) {  Obj_SetX(obj_id, 2*(GetClipMaxX+border)-Obj_GetX(obj_id)); Obj_SetAngle(obj_id, 180-Obj_GetAngle(obj_id)+rand(-offset, offset));  wait(rand_int(5, 35)); CreateShot01(Obj_GetX(obj_id), Obj_GetY(obj_id), v-0.5, Obj_GetAngle(obj_id), graphic2, 5); Obj_Delete(obj_id); counter+=2; }
				else if(Obj_GetX(obj_id) < GetClipMinX-border) { Obj_SetX(obj_id, 2*(GetClipMinX-border)-Obj_GetX(obj_id)); Obj_SetAngle(obj_id, 180-Obj_GetAngle(obj_id)+rand(-offset, offset)); wait(rand_int(5, 35)); CreateShot01(Obj_GetX(obj_id), Obj_GetY(obj_id), v-0.5, Obj_GetAngle(obj_id), graphic2, 5); Obj_Delete(obj_id); counter+=2; }
				if(Obj_GetY(obj_id) < GetClipMinY-border) {  Obj_SetY(obj_id, 2*(GetClipMinY-border)-Obj_GetY(obj_id));Obj_SetAngle(obj_id, -Obj_GetAngle(obj_id)+rand(-offset, offset)); wait(rand_int(5, 35)); CreateShot01(Obj_GetX(obj_id), Obj_GetY(obj_id), v-0.5, Obj_GetAngle(obj_id), graphic2, 5); Obj_Delete(obj_id);  counter+=1; }
				
			}
			yield;
		}
	}

task attack1 {
wait(60);
loop{
SetAction(ACT_SHOT_A, 180);
wait(20);
loop(5){
PlaySE(shot);
	loop(18){
		CreateShotReflect(GetX+25, GetY-10, 1.5, angle, PURPLE21, PURPLE22, 10, 7);
		angle+=360/18;
		}
angle+=360/14/2+rand(-10, 10);
wait(30);
}
ExMove;
wait(60);

}
}



}