script_enemy_main {
	#include_function ".\includeSatori.txt"
	task TMain {
		SetDamageRate(125, 50);
		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 {
		let side = 1;
		loop {
			PlaySE2("lazer01");
			let ang = rand(0,360);
			let num = [5, 9, 14, 18][GetDifficulty];
			ascent(i in 0..num) {
				CreateLaser(ang+i*360/num, side, i%2);
			}
			wait(60);
			ExMove; wait(60);
			TCharge(GetX, GetY);
			PlaySE2("charge");
			wait(60);
			side*=-1;
		}
	}
	task attack2 {
		loop {
			PlaySE2("tan00");
			let ang = GetAngleToPlayer;
			let num = [27, 31, 35, 45][GetDifficulty];
			ascent(i in 0..num) { ascent(j in 0..2) {
				CreateShot01(GetX, GetY, 2-j/3, ang+i*360/num, GREEN01, 10);
			} }
			wait(52);
		}
	}
	task CreateLaser (let angleaim, let side, let gr) {
		let obj = Obj_Create(OBJ_SINUATE_LASER);
		Obj_SetPosition(obj, GetX, GetY);
		Obj_SetAngle(obj, angleaim);
		Obj_SetSpeed(obj, 12);
		ObjShot_SetGraphic(obj, 161+5*gr);
		ObjSinuateLaser_SetLength(obj, 75);
		ObjSinuateLaser_SetWidth(obj, 75);
		Obj_SetCollisionToPlayer(obj, false);
		Obj_SetAlpha(obj, 100);
		let turn = rand(0, 2)*side;
		ascent(i in 0..60) { Obj_SetAngle(obj, Obj_GetAngle(obj)+turn);
			if(i%3 == 0) {
				let x = Obj_GetX(obj)+rand(-0, 0);
				let y = Obj_GetY(obj)+rand(-0, 0);
				CreateFadeShot(x, y, Obj_GetAngle(obj)+(150-i*4)*side+rand(-2, 2), gr);
			}
		yield; }
	}
	task CreateFadeShot (let x, let y, let angleaim, let gr) {
		wait(60);
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, x, y);
		Obj_SetAngle(obj, angleaim);
		Obj_SetSpeed(obj, 0);
		ObjShot_SetGraphic(obj, 73+5*gr);
		Obj_SetCollisionToPlayer(obj, false);
		Obj_SetAlpha(obj, 0);
		descent(i in 0..45) { Obj_SetAlpha(obj, 255*cos(i*90/45)); yield; }
		Obj_SetCollisionToPlayer(obj, true);
		let v = 2+rand(-1,1)/4;
		descent(i in 0..75) { Obj_SetSpeed(obj, v*cos(i*90/75)); yield; }
	}
}