script_enemy_main {
	#include_function ".\includeSatoriSurvivalSatori.txt"
	task TMain {
		SetDamageRate(0, 0);
		SetMovePosition03(GetCenterX, GetCenterY-100, 10, 9);
		SetInvincibility(480);
		while(OnPlayerMissed || OnBomb) { SetInvincibility(480); yield; }
		wait(360);
		wait(60);
		TCharge(GetX, GetY);
		drawblend = SUBTRACT;
		PlaySE2("weird");
		wait(60);
		//attackSuicune;
		//attackWavePart;
		attackTyphlo;
		attackGira;
		attackRing;
	}

task SpellLineSubtitle (let spellid, let frames) {
	PlaySE2("spelldeclare");
	let obj = Obj_Create(OBJ_EFFECT);
	ObjEffect_SetTexture(obj, spellback);
	ObjEffect_SetLayer(obj, 5);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetVertexUV(obj, 0, 0, 0);
	ObjEffect_SetVertexUV(obj, 1, 256, 0);
	ObjEffect_SetVertexUV(obj, 2, 256, 36);
	ObjEffect_SetVertexUV(obj, 3, 0, 36);
	ObjEffect_SetVertexXY(obj, 0, -256, -32);
	ObjEffect_SetVertexXY(obj, 1, 0, -32);
	ObjEffect_SetVertexXY(obj, 2, 0, 4);
	ObjEffect_SetVertexXY(obj, 3, -256, 4);
	let obj2 = Obj_Create(OBJ_EFFECT);
	ObjEffect_SetTexture(obj2, spellnames);
	ObjEffect_SetLayer(obj2, 5);
	ObjEffect_SetPrimitiveType(obj2, PRIMITIVE_TRIANGLEFAN);
	ObjEffect_CreateVertex(obj2, 4);
	ObjEffect_SetVertexUV(obj2, 0, 0, spellid*32);
	ObjEffect_SetVertexUV(obj2, 1, 384, spellid*32);
	ObjEffect_SetVertexUV(obj2, 2, 384, (spellid+1)*32);
	ObjEffect_SetVertexUV(obj2, 3, 0, (spellid+1)*32);
	ObjEffect_SetVertexXY(obj2, 0, -384, -32);
	ObjEffect_SetVertexXY(obj2, 1, 0, -32);
	ObjEffect_SetVertexXY(obj2, 2, 0, 0);
	ObjEffect_SetVertexXY(obj2, 3, -384, 0);
	let y = GetClipMinY+64+32;
	let h = 128;
	descent(i in 0..60) {
		Obj_SetPosition(obj, GetClipMaxX-200*(-(cos(i*90/60)-1)), y+h*2);
		Obj_SetPosition(obj2, GetClipMaxX, y+h*2);
		ObjEffect_SetScale(obj2, 1+1*(-(cos(i*90/60)-1)), 1+1*(-(cos(i*90/60)-1)));
		ascent(j in 0..4) {
			ObjEffect_SetVertexColor(obj, j, 255*cos(i*90/60), 255, 255, 255);
			ObjEffect_SetVertexColor(obj2, j, 255*cos(i*90/60), 255, 255, 255);
		}
	yield; }
	descent(i in 0..60) {
		Obj_SetPosition(obj, GetClipMaxX, y+h-h*cos(i*180/60));
		Obj_SetPosition(obj2, GetClipMaxX, y+h-h*cos(i*180/60));
	yield; }
	wait(frames);
	descent(i in 0..60) {
		Obj_SetPosition(obj, GetClipMaxX+100*(60-i)/60, y);
		Obj_SetPosition(obj2, GetClipMaxX+100*(60-i)/60, y);
		ascent(j in 0..4) {
			ObjEffect_SetVertexColor(obj, j, 255*i/60, 255, 255, 255);
			ObjEffect_SetVertexColor(obj2, j, 255*i/60, 255, 255, 255);
		}
	yield; }
	Obj_Delete(obj);
	Obj_Delete(obj2);
}
	function attackSuicune {
		SpellLineSubtitle (10, 570);
		ascent(s in 0..2) {
			let ang = rand(0,360);
			loop(30) {
				PlaySE2("tan01");
				ascent(j in 0..[2, 3, 3, 5][GetDifficulty]) { ascent(i in 0..5) {
					CreateShotA(0, GetX, GetY, 10);
					SetShotDataA(0, 0, 2+j/6, ang+i*360/5, 0, ((3/2+j/10)-(2+j/6))/45, 3/2+j/10, 38-(j%2));
					FireShot(0);
				} }
				ang+=11*((-1)^s); ang%=360;
				let d = [200, 160, 120, 100][GetDifficulty];
				let y = GetPlayerY+rand(-d, d); let a = rand(-5, 5);
				ascent(i in 0..[4, 6, 7, 9][GetDifficulty]) { CreateShot01(GetCenterX+208*((-1)^s), y, 3-i/10, 90+a+90*((-1)^s), 45, 10+i*2); }
				CreateShot01(GetCenterX+208*((-1)^s), y, 3, 90+a+90*((-1)^s), 6, 10);
				wait(9);
			}
			ExMove;
		}
		SetMovePosition03(GetCenterX, GetCenterY-100, 10, 9);
		wait(60); DeleteEnemyShotToItemInCircle(ALL, 0, 0, 10000);
	}
	function attackWavePart {
		SpellLineSubtitle (11, 340);
		loop(3) {
			descent(i in 1..25) {
				PlaySE2("lazer00");
				ascent(j in 0..2) {
					CreateLaserA(0, GetPlayerX+(50+i*6)*((-1)^j), -50, 600, 10, 225, 60);
					SetLaserDataA(0, 0, 90, 0, 0, 0, 0);
					SetShotKillTime(0, 30);
					FireShot(0);
				}
				wait(1);
			}
			PlaySE2("lazer00");
			let x = GetPlayerX;
			ascent(j in 0..2) {
				CreateLaserA(0, x+(50)*((-1)^j), -50, 600, 20, 225, 30);
				SetLaserDataA(0, 0, 90, 0, 0, 0, 0);
				SetLaserDataA(0, 40, 90, 0, 0, 6, 90-90*((-1)^j));
				SetShotKillTime(0, 150);
				FireShot(0);
			}
			wait(40);
			ascent(i in 0..40) { PlaySE2("kira00"); ascent(j in 0..2) {
				if(i%[2, 2, 1, 1][GetDifficulty] == 0) {
					CreateShot02(x+(50+i*6)*((-1)^j), rand(GetClipMinY, GetClipMaxY), 0, 90+90*((-1)^j)+rand(-5, 5), 1/25, rand(1, 2), 46, 10);
				}
				if(i%[8, 4, 4, 3][GetDifficulty] == 0) {
					CreateShot02(x+(50+i*6)*((-1)^j), GetPlayerY+rand(-100, 100), 0, 90+90*((-1)^j)+rand(-5, 5), 1/25, rand(1, 2), 46, 10);
				}
			} wait(1); }
			wait(10);
			ExMove;
		}
		SetMovePosition03(GetCenterX, GetCenterY-100, 10, 9);
		wait(60); DeleteEnemyShotToItemInCircle(ALL, 0, 0, 10000);
	}
	function attackTyphlo {
		SpellLineSubtitle (15, 420);
		let s = 1;
		loop(6) {
			let ang = GetAngleToPlayer;
			let a = ang+150; let a2 = ang-15;
			let x = GetX+150*cos(a)*s; let y = GetY+150*sin(a);
			let f = 0;
			loop(10) {
				PlaySE2("lazer00");
				ascent(i in -1..2) { ascent(j in 0..[2, 4, 5, 8][GetDifficulty]) {
					CreateShotA(0, x, y, 10);
					SetShotDataA(0, 0, (3+j), 90+(a+a2+45+f*4)*s+i*(11+j*1), -i*j/15+1*s, -(3+j)/30, 0, 24);
					SetShotDataA(0, 30+j, 0, ang+180+(a+f*20+i*(45+j*20))*s, 0, 1/30, 2, [1,8][i==0]);
					FireShot(0);
				} }
				x+=65*cos(a2)*s; y+=50-GetDifficulty*6*sin(a2); a2-=3; f-=1;
				wait(2);
			} s*=-1; ExMove; wait(60);
		} DeleteEnemyShotToItemInCircle(ALL, 0, 0, 10000);
	}
	function attackGira {
		SpellLineSubtitle (16, 330);
		let side = 1;
		let time = 8; let contract = 8;
		loop(5) {
			let x = rand(-25, 25);
			loop(2) {
			ascent(i in -10..12) {
				if(i%floor(2+contract/5) == 0) { PlaySE2("tan01"); }
				CreateShot02(GetCenterX+x+i*(28-contract)*side, GetClipMinY, 4+contract/10, 90+rand(-1,1)/3, -1/30, 1+rand(0,3)/5, 94, 30);
				wait(2-contract/10);
			}
			side*=-1;
			wait(time);
			}
			PlaySE2("lazer00");
			x = rand(-50, 50);
			SetShotColor(255, 0, 0);
			ascent(i in -4..5) {
				CreateLaserA(0, GetCenterX+x+i*60, 500, 0, 15, 225, 75);
				SetLaserDataA(0, 0, -90+rand(-5, 5), rand(-1, 1)/15, 10, rand(-3, 3)/5, 0);
				SetLaserDataA(0, 60, NULL, 0, 0, 0, 0);
				SetShotKillTime(0, 180);
				FireShot(0);
			}
			SetShotColor(255, 255, 255);
			if(time > 0) { time-=4; } else { time = 0; if(contract < 10) { contract++; } }
		}
		wait(60); DeleteEnemyShotToItemInCircle(ALL, 0, 0, 10000);
	}
	function attackRing {
		SpellLineSubtitle (17, 600);
		let s = 1;
		task Bullet1(let side, let rad) {
			let x = GetCenterX-200*side; let y = GetCenterY-25; let a = -90;
			let obj = Obj_Create(OBJ_SHOT);
			Obj_SetAutoDelete(obj, false);
			ObjShot_SetBombResist(obj, true);
			ObjShot_SetGraphic(obj, 53);
			loop(150+rad/3) {
				Obj_SetPosition(obj, x+rad*cos(a), y+rad*sin(a));
				Obj_SetAngle(obj, a+90*side);
				a+=(5/4-rad/600)*side;
				yield;
			} Obj_Delete(obj);
		}
		task attack2 {
			loop {
				loop(2) {
					let ang = rand(-5,5);
					ascent(i in -6..7) { CreateShot02(GetCenterX-200*s, GetCenterY-25, 4, 90+ang-90*s+i*13, -1/(10+rand(-2,2)), -3, 193, 10); }
					wait(85);
				}
				ExMove;
			}
		} attack2;
		task attack3 {
			loop {
				let a = GetAngleToPlayer;
				PlaySE2("lazer00");
				loop(10) {
					ascent(i in -4..5) {
						CreateShot02(GetX, GetY, 5, a+i*23+rand(-3,3), -1/10, 3/2+rand(-1,1)/4, 209, 10);
					}
					wait(3);
				}
				wait(60+rand(0,10));
			}
		} attack3;
		let r = 0;
		loop {
			loop(9) {
				PlaySE2("kira00");
				ascent(i in 0..10) {
					Bullet1(s, r+i*50);
					wait(2);
				}
				r+=31; r%=50;
			}
			wait(30);
			s*=-1;
		}
	}
}