#Title[従者「魂魄妖夢」]
#Text[西行寺幽々子のスペルカード]
#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let name="従者「魂魄妖夢」";
        let csd=GetCurrentScriptDirectory;
        let imgBoss=csd~"img\dot_yuyuko.png";
        let imgBoss2=csd~"img\dot_youmu.png";
        let imgEnemy=csd~"img\familiar3.png";
        let angle=0;
	let angleB=0;
	let AnimationA=0;
	let AnimationB=0;
	let AnimationC=0;
	let shotseA=csd~"se\ShotSE02.wav";
	let imgAngle=0;
	let imgALP1=255;
	let imgALP2=0;

    @Initialize {
        CutIn(YOUMU,name,0,0,0,0,0);
        SetLife(4500);
        SetTimer(75);
        SetScore(1000000);
        SetDamageRate(100,0);
        SetInvincibility(200);
        SetMovePosition02(GetCenterX(),100,50);
	LoadGraphic(imgBoss);
	LoadGraphic(imgBoss2);
	LoadGraphic(imgEnemy);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
	CreateEnemyFromScript("EnemyA",-10,-10,0,0,1);
        TAnime1;
	}

        @MainLoop
        {
	imgAngle+=0.5;
	if(imgAngle>=360){imgAngle=0;}

        if(!OnBomb){
        SetCollisionB(GetX(),GetY(),22);
	SetCollisionA(GetX(),GetY(),22);
        imgALP2=255;
        imgALP1=100;
	SetDamageRate(100,0);
        SetEnemyMarker(true);}
        else {
        imgALP2=0;
        imgALP1=255;
	SetDamageRate(0,0);
	SetEnemyMarker(false);}

	if(count>=200&&count%50==0){
        	SetShotDirectionType(PLAYER);
		PlaySE(shotseA);
		let i=0;
		while(i<20)
			{
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,0);
			SetShotDataA(shotA,0,1,i*18,0,0,1,227);
			FireShot(shotA);
			i++;
			}
		}
        count++;
        yield;

}
	@Finalize {
		if(!IsTimeOut){
			CreateItem(ITEM_BOMB,GetX,GetY);
			loop(50){
				angle=rand(0,360);
				CreateItem(ITEM_SCORE,GetX+cos(angle)*rand(35,45),GetY+sin(angle)*rand(35,45));
			}
		}
		DeleteGraphic(imgBoss);
		DeleteGraphic(imgBoss2);
		DeleteGraphic(imgEnemy);
	}

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgEnemy);
		SetGraphicRect(0,0,192,192);
		SetAlpha(imgALP1);
		SetColor(255,255,255);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,imgAngle);
		DrawGraphic(GetX(),GetY());

		SetTexture(imgBoss);
		SetAlpha(255);
		SetColor(imgALP2,imgALP2,imgALP2);
		SetGraphicAngle(0,0,0);
		SetGraphicRect(128*AnimationC,128*AnimationB,127+128*AnimationC,127+128*AnimationB);
		DrawGraphic(GetX(),GetY());
		}

    	task TAnime1{
			AnimationB=0;
			AnimationC=3;
        		loop(16){yield;}
			AnimationB=1;
        		loop(46){yield;}
			AnimationB=0;
        		loop(8){yield;}
		loop(2){
			AnimationB=0;
			AnimationC=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
			}
			AnimationB=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=0;
			AnimationC=5;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
		}
}

script_enemy EnemyA
{//
        let csd     = GetCurrentScriptDirectory;
        let imgBoss2 =csd~"img\dot_youmu.png";
	let imgALP3=255;
	let AnimationB=0;
	let AnimationC=0;
        let count=0;
	let shotseB=csd~"se\ShotSE05.wav";
	let shotseC=csd~"se\ShotSE04.wav";
	let shotseD=csd~"se\Powar.wav";

    @Initialize {
	SetLife(1);
	SetInvincibility(0);
	SetMovePosition02(224,150,50);
        TAnime1;
	}

	@MainLoop{
		if(!OnBomb){
			SetCollisionB(GetX(),GetY(),18);
			SetCollisionA(GetX(),GetY(),18);
			SetDamageRateEx(0,0,75,0);
			imgALP3=255;
		} else {
			imgALP3=100;
		}

		if(count>=150&&count%400==150){
			PlaySE(shotseD);
			Concentration01(50);
			}
		if(count>=200&&count%400==200){
			PlaySE(shotseB);
			SetMovePosition02(GetX,460,20);
			TAnime2;
			}
		if(count>=250&&count%400==250){
			PlaySE(shotseC);
			SetMovePosition03(55,GetPlayerY,10,15);
        		SetShotDirectionType(PLAYER);
			let i=5;
			while(i<11){
				let l=0;
				while(l<20){
					let id=0;
					CreateShotA(id,GetX,GetY,0);
					SetShotDataA(id,0,i,137.5+l*175,0,0,0,224);
					FireShot(id);
					l++;
					}
				i++;
				}
			}
		if(count>=300&&count%400==300){
			PlaySE(shotseC);
			SetMovePosition03(GetPlayerX,44,10,15);
        		SetShotDirectionType(PLAYER);
			let i=5;
			while(i<11){
				let l=0;
				while(l<20){
					let id=0;
					CreateShotA(id,GetX,GetY,0);
					SetShotDataA(id,0,i,137.5+l*175,0,0,0,224);
					FireShot(id);
					l++;
					}
				i++;
				}
			}
		if(count>=200&&count%400==350){
			PlaySE(shotseD);
			Concentration01(50);
			}
		if(count>=400&&count%400==0){
			PlaySE(shotseB);
			SetMovePosition02(GetX,460,20);
			TAnime2;
			}
		if(count>=450&&count%400==50){
			PlaySE(shotseC);
			SetMovePosition03(393,GetPlayerY,10,15);
        		SetShotDirectionType(PLAYER);
			let i=5;
			while(i<11){
				let l=0;
				while(l<20){
					let id=0;
					CreateShotA(id,GetX,GetY,0);
					SetShotDataA(id,0,i,137.5+l*175,0,0,0,224);
					FireShot(id);
					l++;
					}
				i++;
				}
			}
		if(count>=500&&count%400==100){
			PlaySE(shotseC);
			SetMovePosition03(GetPlayerX,44,10,15);
        		SetShotDirectionType(PLAYER);
			let i=5;
			while(i<11){
				let l=0;
				while(l<20){
					let id=0;
					CreateShotA(id,GetX,GetY,0);
					SetShotDataA(id,0,i,137.5+l*175,0,0,0,224);
					FireShot(id);
					l++;
					}
				i++;
				}
			}
		count++;
		yield;
	if(BeParentVanished==false){
		SetCommonData("YouX",GetX);
		SetCommonData("YouY",GetY);
		} else {
		if(IsTimeOut==true){
			SetCommonData("YouX",GetX);
			SetCommonData("YouY",GetY);
			}
		}
	}

	@DrawLoop{
		SetTexture(imgBoss2);
		SetAlpha(imgALP3);
		SetColor(imgALP3,imgALP3,imgALP3);
		SetGraphicAngle(0,0,0);
		SetGraphicRect(128*AnimationC,128*AnimationB,127+128*AnimationC,127+128*AnimationB);
		DrawGraphic(GetX(),GetY());
	}

        @Finalize
        {
        }


    	task TAnime1{
			AnimationB=3;
			AnimationC=2;
        		loop(40){yield;}
			AnimationB=2;
        		loop(10){yield;}
		loop(3){
			AnimationB=0;
			AnimationC=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
			}
			AnimationB=0;
        		loop(10){yield;}
		loop{
			AnimationC=4;
			AnimationB=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(30){yield;}
			AnimationB=2;
        		loop(10){yield;}
			AnimationB=3;
        		loop(10){yield;}
			AnimationB=2;
			AnimationC=5;
        		loop(10){yield;}
			AnimationB=3;
        		loop(30){yield;}
			AnimationB=0;
			AnimationC=2;
        		loop(10){yield;}
			AnimationB=1;
        		loop(30){yield;}
			AnimationB=0;
        		loop(10){yield;}
			AnimationB=2;
			AnimationC=2;
        		loop(10){yield;}
			AnimationB=3;
        		loop(30){yield;}
			AnimationB=2;
        		loop(10){yield;}
			AnimationC=4;
			AnimationB=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(30){yield;}
			AnimationB=2;
        		loop(10){yield;}
			AnimationB=3;
        		loop(10){yield;}
			AnimationB=2;
			AnimationC=5;
        		loop(10){yield;}
			AnimationB=3;
        		loop(30){yield;}
			AnimationB=2;
			AnimationC=2;
        		loop(10){yield;}
			AnimationB=3;
        		loop(30){yield;}
			AnimationB=2;
        		loop(10){yield;}
			AnimationB=0;
			AnimationC=2;
        		loop(10){yield;}
			AnimationB=1;
        		loop(30){yield;}
			AnimationB=0;
        		loop(10){yield;}
        		}
		}

    	task TAnime2{
		loop(20){
        		SetShotDirectionType(PLAYER);
			let i=1.5;
			while(i<11)
			{
				let shotA=0;
				CreateShotA(shotA,GetX,GetY,10);
				SetShotDataA(shotA,0,0,0,0,0.05*i,i/2,214);
				FireShot(shotA);
				CreateShotA(shotA,GetX,GetY,10);
				SetShotDataA(shotA,0,0,180,0,0.05*i,i/2,214);
				FireShot(shotA);
				CreateShotA(shotA,GetX,GetY,10);
				SetShotDataA(shotA,0,0,90,0,0.15*i,i,215);
				FireShot(shotA);
				CreateShotA(shotA,GetX,GetY,10);
				SetShotDataA(shotA,0,0,270,0,0.1*i,i,215);
				FireShot(shotA);
				i++;
				}
        		loop(1){yield;}
        		}
		}
}