script_enemy_main {
	#include_function ".\includeKoishi.txt"
	task TMain {
		SetDamageRate(125, 30);
		SetMovePosition03(GetCenterX, GetCenterY-85, 10, 9);
		SetInvincibility(180);
		while(OnPlayerMissed || OnBomb) { SetInvincibility(180); yield; }
		wait(120);
		TCharge(GetX, GetY);
		PlaySE2("charge");
		wait(60);
		attack1;
		attack2;
	}
	task attack1 {
		loop(3) {
			wait(140);
			let a = GetAngleToPlayer;
			loop(10) {
				PlaySE2("tan01");
				CreateShot02(GetX, GetY, 1, a, 1/30, 5, 78, 15);
				wait(6);
			}
		}
		loop {
			ExMove;
			wait(30);
			let a = GetAngleToPlayer;
			loop(10) {
				PlaySE2("tan01");
				CreateShot02(GetX, GetY, 1, a, 1/30, 5, 78, 15);
				wait(6);
			}
			ExMove;
			wait(90);
		}
	}
	task attack2 {
		PlaySE2("tan01");
		CreateBounceShot(51);
		wait(150);
		PlaySE2("tan01");
		CreateBounceShot(180-51);
		wait(150);
		PlaySE2("tan01");
		CreateBounceShot(270-32);
		wait(150);
		PlaySE2("tan01");
		CreateBounceShot(270+32);
		wait(150);
	}
	task CreateBounceShot (let angle) {
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, GetX, GetY);
		Obj_SetSpeed(obj, 3);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 73);
		ObjShot_SetDelay(obj, 15);
		ObjShot_SetBombResist(obj, true);
		task shoot {
			wait(15);
			loop {
				PlaySE2("tan00");
				ascent(i in 0..2) { ascent(j in 0..[1, 2, 2, 3][GetDifficulty]) {
					CreateShot02(Obj_GetX(obj), Obj_GetY(obj), 0, Obj_GetAngle(obj)+180+(20+j*4)*((-1)^i), 1/30, pi/2, 134, 0);
				} }
				wait([24, 20, 12, 14][GetDifficulty]);
			}
		} shoot;
		loop {
			if(Obj_GetX(obj) > GetClipMaxX) {
				Obj_SetAngle(obj, 180-Obj_GetAngle(obj));
				Obj_SetX(obj, GetClipMaxX*2-Obj_GetX(obj));
				PlaySE2("kira00");
			}
			if(Obj_GetX(obj) < GetClipMinX) {
				Obj_SetAngle(obj, 180-Obj_GetAngle(obj));
				Obj_SetX(obj, GetClipMinX*2-Obj_GetX(obj));
				PlaySE2("kira00");
			}
			if(Obj_GetY(obj) < GetClipMinY) {
				Obj_SetAngle(obj, -Obj_GetAngle(obj));
				Obj_SetY(obj, GetClipMinY*2-Obj_GetY(obj));
				PlaySE2("kira00");
			}
			if(Obj_GetY(obj) > GetClipMaxY) {
				Obj_SetAngle(obj, -Obj_GetAngle(obj));
				Obj_SetY(obj, GetClipMaxY*2-Obj_GetY(obj));
				PlaySE2("kira00");
			}
			yield;
		}
		PlaySE2("kira00");
	}
}