
#Title[nonspell1]
#Text[nonspell1]
#Image[.\img\spellcard0103.jpg]
#PlayLevel[Hard]
#ScriptVersion[2]

script_enemy_main
{
#include_function ".\system\Effects.txt";
#include_function ".\cutin.txt";
#include_function ".\drawall.txt";
#include_function ".\maple.txt" 
#include_function ".\hitbox.txt";
#include_function".\SnowFunc.txt";
let ImgBoss = GetCurrentScriptDirectory~"system\enm5m.png";
let imgExRumiaBack=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
let CSD = GetCurrentScriptDirectory;
let ci = CSD ~ "system\NMM.png";
let bg1 = CSD ~ "system\bg8.png";
let bg2 = CSD ~ "system\bg3.png";
let cx=GetCenterX();
let frame = 0;
let framedelay = 0;
let gp;
let x;
let switch = 1;
let Cut = GetCurrentScriptDirectory~"img\daiyousei11.png";
let ThisShot = GetCurrentScriptDirectory~"ZUN's shotdata.txt";
let l = CSD ~ "system\extras.png";
let test2 = CSD ~ "system\NMM.png";

@Initialize
{
drawcircle(GetX,GetY+120,0,0);
CreateHitbox;
SetLife(2000);
SetDamageRate(50,50);
SetTimer(60);
mainTask;
LoadGraphic(test2);
SetInvincibility(120);
SetMovePosition03(GetCenterX, GetCenterY-120, 5, 4);
PlayMusic(CSD~"music\thC08.mp3");
LoadGraphic(ImgBoss);
LoadUserShotData(ThisShot);	
LoadGraphic(Cut);
LoadGraphic(ci);
LoadGraphic(bg1);
LoadGraphic(bg2);
LoadGraphic(l);
SetTexture(ImgBoss);
SetGraphicRect(0, 0, 64, 64);
MagicCircle(true);
Aura;

}

//---------------------------------------------------------------

@MainLoop 
{

SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 16);


frame++;

// Start Attack

yield;

// End Attack


// Start Boss Move


// End Boss Move



}

//---------------------------------------------------------------

@DrawLoop
{
SetTexture(ImgBoss);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicScale(1.1, 1.1);
DrawHitbox;
drawboss;

}
//---------------------------------------------------------------

@BackGround
{
	
}	

//---------------------------------------------------------------

@Finalize
{
DeleteGraphic(ImgBoss);
}

// main task
task mainTask{
	wait(120);
	fire;
	yield;
}

task fire{
	LocateEnemy;
	StartMapleConcentrate;
	SetMovePositionRandom01(rand(20,50),0,2,GetClipMinX+100,rand(150,160),GetClipMaxX-100,rand(100,150));
	PlayDelaySE(CSD~"sound\charge2.wav",0);
	wait(60);
	gp = GetAngleToPlayer;
	ascent(n in 0..12){
	PlaySE(CSD~"sound\shot1.wav");
	PlayDelaySE(CSD~"sound\Bulletwave.wav",30);
	ascent(a in 0..7){
	ascent(i in 0..2){
	CreateShotA(0,GetX+60*cos(gp+n*16*switch+180),GetY+60*sin(gp+n*16*switch+180),25);
	SetShotDataA(0,0,-1-a/2,gp+n*16*switch,0,0,0,11);
	FireShot(0);
	switch = -switch;
	}
	}
	ascent(a in 0..2){
	ascent(i in 0..2){
	CreateShotA(0,GetX-10+a*20,GetY-14,10);
	SetShotDataA(0,0,4,gp+n*8*switch,0,0,0,89);
	SetShotKillTime(0,31);
	ascent(j in 0..2){
	CreateShotA(1,0,0,5);
	SetShotDataA(1,0,1.7+a*1,j*180+n*8*switch+a*45,0,0,0,93+a);
	AddShot(30,0,1,0);
	CreateShotA(1,0,0,5);
	SetShotDataA(1,0,1.3+a*1,j*180+n*8*switch+a*45,0,0,0,93+a);
	AddShot(30,0,1,0);
	}
	switch = -switch;
	FireShot(0);
	}
	}
	wait(3);
	}
	wait(60);
	SetMovePositionRandom01(rand(20,50),0,2,GetClipMinX+100,rand(150,160),GetClipMaxX-100,rand(100,150));
	wait(90);
	fire2;
	}
task fire2{	
	descent(n in 0..12){
	PlaySE(CSD~"sound\shot1.wav");
	PlayDelaySE(CSD~"sound\Bulletwave.wav",30);
	ascent(a in 0..7){
	ascent(i in 0..2){
	CreateShotA(0,GetX+60*cos(gp+n*16*switch+0),GetY+60*sin(gp+n*16*switch+0),25);
	SetShotDataA(0,0,-1-a/2,gp+n*16*switch,0,0,0,11);
	FireShot(0);
	switch = -switch;
	}
	}
	ascent(a in 0..2){
	ascent(i in 0..2){
	CreateShotA(0,GetX-10+a*20,GetY-14,10);
	SetShotDataA(0,0,1+n/4,gp+n*8*switch,0,0,0,89);
	SetShotKillTime(0,31);
	ascent(j in 0..2){
	CreateShotA(1,0,0,5);
	SetShotDataA(1,0,1.7+a*1,j*180+n*8*switch+a*45,0,0,0,93+a);
	AddShot(30,0,1,0);
	CreateShotA(1,0,0,5);
	SetShotDataA(1,0,1.3+a*1,j*180+n*8*switch+a*45,0,0,0,93+a);
	AddShot(30,0,1,0);
	}
	switch = -switch;
	FireShot(0);
	}
	}
	wait(3);
	}
	wait(50);
	SetMovePositionRandom01(rand(20,50),0,2,GetClipMinX+100,rand(150,160),GetClipMaxX-100,rand(100,150));
	wait(50);
	fire3;
	}

task fire3{
	gp = GetAngleToPlayer;
	fire4;
	ascent(n in 0..30){
	PlaySE(CSD~"sound\shot1.wav");
	PlayDelaySE(CSD~"sound\Bulletwave.wav",60);
	ascent(i in 0..2){
	Bullet(GetX, GetY, 2, -gp+n*4*switch, 90, 5,n*switch);
	switch = -switch;
	}
	wait(5);
	}
	}

task fire4{
	wait(30);
	ascent(n in 0..9){
	ascent(i in 0..18){
	CreateShotA(0,GetX+40*cos(i*20+n*10),GetY+40*sin(i*20+n*10),10);
	SetShotDataA(0,0,3,i*20+n*10,0,0,0,12);
	FireShot(0);
	}
	wait(20);
	}
	wait(60);
	fireend;
	}

task fireend{
	ascent(n in 0..150){
	if(n%2==0){
	PlaySE(CSD~"sound\shot1.wav");
	PlayDelaySE(CSD~"sound\Bulletwave.wav",60);
	}
	ascent(i in 0..3){
	CreateShotA(0,GetX+(120-n/2)*cos(n*6*switch),GetY+(120-n/2)*sin(n*6*switch),15);
	SetShotDataA(0,0,4,n*27+i*120,0,-0.2,0,71);
	SetShotDataA(0,60,2.5,NULL,0,0,0,71);
	FireShot(0);
	CreateShotA(0,GetX+(120-n/2)*cos(n*6*switch),GetY+(120-n/2)*sin(n*6*switch),15);
	SetShotDataA(0,0,4,n*27+i*120,0,-0.2,0,71);
	SetShotDataA(0,60,2,NULL,0,0,0,71);
	FireShot(0);
	}
	wait(1);
	}
	SetMovePositionRandom01(rand(20,50),0,2,GetClipMinX+100,rand(150,160),GetClipMaxX-100,rand(100,150));
	ascent(i in 0..15){
	CreateShotA(0,GetX,GetY,0);
	SetShotDataA(0,0,4.5,i*24,0,-0.1,0.5,28);
	SetShotDataA(0,100,NULL,NULL,0,0.015,4,28);
	FireShot(0);
	CreateShotA(0,GetX,GetY,0);
	SetShotDataA(0,0,2,i*24+12,0,-0.1,0.5,28);
	SetShotDataA(0,100,NULL,NULL,0,0.01,4,28);
	FireShot(0);
	}
	PlayDelaySE(CSD~"sound\Bulletwave.wav",100);
	wait(240);
	switch = -switch;
	fire;
	}

task Bullet(x, y, v, dir, graphic, delay,check) 
	{
    	 let obj = Obj_Create(OBJ_SHOT);
	 let c = 0;
    	 Obj_SetPosition   (obj, x, y);
    	 Obj_SetSpeed      (obj, v);
    	 Obj_SetAngle      (obj, dir);
    	 ObjShot_SetGraphic(obj, graphic);
    	 ObjShot_SetDelay  (obj, delay);
	 ObjShot_SetBombResist(obj, true);
		 while(! Obj_BeDeleted(obj)) 
		{
		c++;
		if(c==60){
		Obj_SetSpeed(obj,4);
		Obj_SetAngle(obj,Obj_GetAngleToPlayer(obj)+check*0.5);
		}
		 yield;
		}
	}

	function Obj_GetAngleToPlayer(obj) {
	return atan2(GetPlayerY - Obj_GetY(obj), GetPlayerX - Obj_GetX(obj));
	}

task PlayDelaySE(se,delay){
        loop(delay){yield;}
        PlaySE(se);
}
	function wait(w){
		loop(w){yield;}
			}
}