
#Title[nonspell4]
#Text[nonspell4]
#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 dis = 0;
let angle = 0;
let switch = 1;
let Cut = GetCurrentScriptDirectory~"img\daiyousei11.png";
let ThisShot = GetCurrentScriptDirectory~"system\supershot.txt";
let l = CSD ~ "system\extras.png";

@Initialize
{
drawcircle(GetX,GetY+120,0,0);
CreateHitbox;
SetLife(2200);
SetDamageRate(50,50);
SetTimer(60);
mainTask;

SetInvincibility(180);
SetMovePosition03(GetCenterX, GetCenterY-120, 5, 3);
//ConcentrationEx0(120,255,0,0,true);
//PlaySE(GetCurrentScriptDirectory~"stE4Boss2.wav");
//PlayMusic(CSD~"music\thC08.mp3");
LoadGraphic(ImgBoss);
LoadUserShotData(ThisShot);
LoadGraphic(Cut);
LoadGraphic(ci);
LoadGraphic(bg1);
LoadGraphic(bg2);
LoadGraphic(l);
//SetScore(500000);
//cutin("NAZRIN", "Taboo 'Forbidden Girl'", Cut, 0, 0, 325, 488);
SetTexture(ImgBoss);
SetGraphicRect(0, 0, 64, 64);
MagicCircle(true);
Aura;
//Border2(255,0,0);

}

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

@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);
drawboss;
DrawHitbox;


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

@BackGround
{
	//drawbg;
}	

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

@Finalize
{
DeleteGraphic(ImgBoss);
}

task mainTask{
	wait(90);
	firefam;
	wait(240);
	fire;
	yield;
}

task fire{
	PlaySE(CSD~"sound\laser3.wav");
	ascent(i in 0..5){
	lightlaser(GetX, GetY, 0, i*72+angle,0,50, 3, 50,0);
	}
	wait(100);
	fire2;
	}

task fire2{
	ascent(a in 0..35){
	PlayDelaySE(CSD~"sound\shot1.wav",a*1);
	ascent(i in 0..5){
	CreateShotA(0,GetX+a*15*cos(i*72+angle),GetY+a*15*sin(i*72+angle),a*1);
	SetShotDataA(0,0,1.5,i*72+a*11+angle,0,0,0,72);
	FireShot(0);
	CreateShotA(0,GetX+a*15*cos(i*72+angle),GetY+a*15*sin(i*72+angle),a*1);
	SetShotDataA(0,0,1.5,i*72-a*11+angle,0,0,0,72);
	FireShot(0);
	}
	}
	angle +=rand_int(27,37);
	wait(60);
	SetMovePositionRandom01(rand(20,50),0,2,GetClipMinX+100,rand(150,160),GetClipMaxX-100,rand(100,150));
	wait(60);
	fire;
	}

task firefam{
	PlaySE(CSD~"sound\fam.wav");
	CreateEnemyFromScript("starFam",GetX,GetY,0,0,0);
	CreateEnemyFromScript("starFam",GetX,GetY,0,0,1);
	}

	   task lightlaser(x, y, v, dir,l,w, graphic, delay,check) {
	   let obj = Obj_Create(OBJ_LASER);
 	   let c = 0;
 	   Obj_SetPosition   (obj, x, y);
  	  Obj_SetSpeed      (obj, v);
 	   ObjShot_SetGraphic(obj, graphic);
  	  ObjShot_SetDelay  (obj, delay);
 	   Obj_SetAngle      (obj, dir);
 	   ObjLaser_SetLength(obj,l);
    	ObjLaser_SetWidth (obj,w);
    	ObjLaser_SetSource(obj,false);
  	  while(! Obj_BeDeleted(obj)) {
	    c++;
	    if(c<20){
	    ObjLaser_SetLength (obj,c*22);
	    }	
		if(c>70){ObjShot_FadeDelete(obj);}
   	     yield;
	    }
	}

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, Obj_GetAngleToPlayer(obj));
    	 ObjShot_SetGraphic(obj, graphic);
    	 ObjShot_SetDelay  (obj, delay);
		 while(! Obj_BeDeleted(obj)) 
		{
		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;}
			}

}

script_enemy starFam{
	#include_function ".\maple.txt"
	let ThisShot = GetCurrentScriptDirectory~"system\supershot.txt";
	let CSD = GetCurrentScriptDirectory;
	let imgFam = CSD ~ "system\purple.png";
	let s = 0;
	let switch = 1;
	let r = 0;
	let famangle = GetArgument;
	let spin = 0;
@Initialize{
	LoadUserShotData(ThisShot);
	SetLife(1000);
	LoadGraphic(imgFam);
	maintask;
}

@MainLoop{

//SetCollisionA(GetX, GetY, 24);
SetCollisionB(GetX, GetY, 18);

yield;


}
	
@DrawLoop{
	SetTexture(imgFam);
	SetRenderState(ADD);
	if(s<=1){s+= 0.015;}	
	SetGraphicScale(s/5.5,s/5.5);
	SetGraphicAngle(0,0,spin);
	SetGraphicRect(0,0,400,400);
	DrawGraphic(GetX,GetY);
	////////////////////////////
	SetTexture(imgFam);
	SetRenderState(ADD);
	if(s<=1){s+= 0.015;}	
	SetGraphicScale(s/5.5,s/5.5);
	SetGraphicAngle(0,0,spin);
	SetGraphicRect(0,0,400,400);
	DrawGraphic(GetX,GetY);
	spin -= 1;

}

@Finalize{

	//DeleteGraphic(imgFam);

}

task maintask{
	Concentration01(60);
	movement;
	wait(60);
	PlaySE(CSD~"sound\charge2.wav");
	LocateEnemy;
	if(famangle==0){
	StartMapleConcentrate;
	}
	wait(60);
	if(famangle==0){
	loop(70){
	MapleExplode(8, -0.04);
	}
	}
	PlayDelaySE(CSD~"sound\stars.wav",5);
	wait(5);
	fire;
	wait(120);
	PlaySE(CSD~"sound\charge2.wav");
	LocateEnemy;
	if(famangle==0){
	StartMapleConcentrate;
	}
	wait(60);
	if(famangle==0){
	loop(70){
	MapleExplode(8, -0.04);
	}
	}
	PlayDelaySE(CSD~"sound\stars.wav",5);
	laser;
	yield;
	}

task fire{
	let angle = 0;
	loop{
	if(famangle==0){PlaySE(CSD~"sound\shot5.wav");}
	ascent(i in 0..4){
	CreateShotA(0,GetX,GetY,0);
	if(famangle==0){
	SetShotDataA(0,0,5,i*90+12*sin(angle),0,0,0,248);
	}
	else if(famangle==1){
	SetShotDataA(0,0,5,i*90+12*sin(-angle),0,0,0,248);
	}
	FireShot(0);
	}
	angle += 8;
	wait(3);
	}
	}

task laser{
	let angle2 = 0;
	loop{
	PlayDelaySE(CSD~"sound\laser4.wav",10);
	ascent(i in 0..10){
	CreateLaser01(GetX,GetY,3,i*36+angle2,130,10,3,20);
	}
	angle2 += 15;
	wait(120);
	}
	}

task movement{
	if(famangle==0){
	SetMovePosition03(GetCenterX-150, GetCenterY-105, 10, 3+famangle/5);
	}
	else if(famangle==1){
	SetMovePosition03(GetCenterX+150, GetCenterY-105, 10, 3+famangle/5);
	}
	wait(200);
	loop{
		if(famangle==0){
		SetMovePosition03(GetCenterX-140-15*sin(r+90), GetCenterY-105, 10, 3+famangle/5);
		}
		else if(famangle==1){
		SetMovePosition03(GetCenterX+140+15*sin(r+90), GetCenterY-105, 10, 3+famangle/5);
		}
		r++;
		yield;
	}
	}

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

}