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 a = [23, 60, 60, 40][GetDifficulty];
		loop {
			loop(4) {
				loop(6) {
					wait(6);
					PlaySE2("lazer00");
					let n = [4, 5, 7, 9][GetDifficulty];
					ascent(i in 0..n) {
						CreateLaser(-90-a+i*360/n);
						ascent(j in 0..2) {
							CreateShot01(GetX, GetY, 2+j*1/4, -90+a+i*360/n, 92, 10);
						}
					}
					a+=2; a%=360;
				}
				a+=[23, 17, 13, 11][GetDifficulty];
				wait(20);
			}
			SetMovePosition03(GetCenterX+rand(-15,15), GetCenterY-85+rand(-5,5), 10, 9);
		}
	}
	task attack2 {
		loop {
			let a = -90+rand(-15, 15);
			PlaySE2("tan00");
			ascent(i in -1..2) { CreateBounceShot(a+i*55); }
			wait([60, 45, 45, 35][GetDifficulty]);
		}
	}
	task CreateBounceShot (let angle) {
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, GetX, GetY);
		Obj_SetSpeed(obj, 1);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 6);
		ObjShot_SetDelay(obj, 5);
		ObjShot_SetBombResist(obj, true);
		while((|GetCenterX-Obj_GetX(obj)|) < 192+48 && (|GetCenterY-Obj_GetY(obj)|) < 224+48) {
			yield;
		}
		PlaySE2("kira00");
		Obj_SetAngle(obj, atan2(GetPlayerY-Obj_GetY(obj),GetPlayerX-Obj_GetX(obj)));
		Obj_SetSpeed(obj, 4);
	}
	task CreateLaser (let angle) {
		let obj = Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj, GetX, GetY);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 103);
		ObjShot_SetDelay(obj, 60);
		ObjLaser_SetLength(obj, 0);
		ObjLaser_SetWidth(obj, 16);
		ObjLaser_SetSource(obj, false);
		descent(i in 0..45) {
			ObjLaser_SetLength(obj, 450*cos(i*90/45));
			yield;
		}
		wait(30);
		Obj_SetCollisionToPlayer(obj, false);
		descent(i in 0..10) {
			ObjLaser_SetWidth(obj, 16*i/10);
			yield;
		}
		Obj_Delete(obj);
	}
}