#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["YukariS11"]
#Text["Modern Danmaku Bounded Field, Yukari's PCB Spell Card, but harder version."]
#Player["./Hecatia/Hecatia.txt"]
#System["./system/Default_System.txt"]
#Background["./BG.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"./Shot/AllStarShot_Const.dnh"
#include"./system/Default_Effect.Txt"


let objBoss;
let GCSD=GetCurrentScriptDirectory~"";
let enemy;
let bSpell=false;
let stgx=GetStgFrameWidth()/2;
let stgy=GetStgFrameHeight()/2;
let idle = true;
let atk = false;
let fog = 0;
let action = false;
let objScene=GetEnemyBossSceneObjectID();
let color = [276,277,278];
let color2 = [51,53,55];
let dcolor = [308,309,310];
@Initialize
{
SetBoss("Yukari",true);
}

@MainLoop
{
	yield;

}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(1);
	}

                case(EV_REQUEST_IS_DURABLE_SPELL)
	{
		SetScriptResult(true);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(222);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(99999999);
	}
}

//----------------------------------------------------
task mainTask{
	StartCountDown;
                    //ObjPlayer_ClearIntersection(GetPlayerObjectID);
	wait( 150 );
	YukariCircle(objBoss,1,-1);
	SetCommonData("ForceLifebar",1);
	ObjMove_SetDestAtWeight(objBoss,stgx,stgy,10,7);
	Cutin("Modern Danmaku Bounded Field",15,"SHINKI");
	ObjEnemyBossScene_StartSpell(objScene);
	Sound(GCSD ~ "Butterfly.mp3");
	wait(105);
	TShot1;
	wait(1200);
	}
//----------------------------------------------------

task TShot1
{
	if( ObjEnemy_GetInfo( objBoss, INFO_LIFE ) == 1 ){ DeleteShotAll( TYPE_ALL, TYPE_IMMEDIATE ); }
	attack(223*60);
	let r = 70;
	let angle = rand(0,80);
	let dir = 0;
	let s = 1;
	wait( 50 );
	maple;
	wait( 80 );
	ascent( i in 0..60 ){
	ObjRender_SetAlpha( objBoss, 255 - i );
	wait( 1 );
	}
	wait( 60 );
	
	PatternBorder1;
	wait( 1500 );
	PatternBorder2;
	wait( 1500 );
	PatternBorder3;
	wait( 1500 );
	PatternBorder4;
	wait( 1560 );
	PatternBorder5;
	wait( 1740 );
	PatternBorder6;
	wait( 1800 );
	DeleteShotAll(TYPE_ALL,TYPE_ITEM);
	wait( 1 );
	PatternBorder7;
	wait( 1900 );
	DeleteShotAll(TYPE_ALL,TYPE_ITEM);
	wait( 1 );
	PatternBorder8;

}

	task PatternBorder8{
	PatternPurple;
	wait( 400 );		
	PatternPurple1;
	}

	task PatternBorder4{
	PatternBorder41;
	PatternBorder42;
	PatternBlue1;
	}


	task PatternBorder7{
	PatternBorder71;
	PatternBorder72;
	PatternYellow1;
	}

              task PatternBorder1{ 
              loop( 1 ){

              			let angle = rand( 0, 360 );
	                                let way = 2;
                                                let shote = 856;
			let delay = 20;
			let speed = 0;
			let sht1;
			let r = -1;
			let s = 230;

			loop( way ){

                      	                let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjShot_SetSpellResist( sht1, true );
				ObjShot_SetAutoDelete( sht1, false );

				PatternRed( sht1 );

				ObjectRotation( sht1, objBoss, 500, s, angle, r, 1.82 , 0, 0 );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			}

			PlaySound("Boon1",92,0);
                       		if( wait( 1 ) ){ return; }


	}

   }


              task PatternBorder2{ 
              loop( 1 ){

              			let angle = rand( 0, 360 );
	                                let way = 2;
                                                let shote = [861, 862];
			let delay = 20;
			let speed = 0;
			let sht1;
			let sht2;

			loop( way ){

                      	                let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote[1], delay );
				sht2 = TShotA2( sx, sy, speed, angle, 0, speed, shote[0], delay );

				ObjShot_SetSpellResist( sht1, true );
				ObjShot_SetAutoDelete( sht1, false );
				ObjShot_SetSpellResist( sht2, true );
				ObjShot_SetAutoDelete( sht2, false );

				PatternOrange( sht1 );
				PatternOrange1( sht2 );

				ObjectRotation( sht1, objBoss, 500, 250, angle, -1, 2, 0, 0 );
				ObjectRotation( sht2, objBoss, 500, 200, angle, -1, -1.3, 0, 0 );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			}

			PlaySound("Boon1",92,0);
                       		if( wait( 1 ) ){ return; }


	}

   }

              task PatternBorder3{ 
              loop( 1 ){

              			let angle = rand( 0, 360 );
	                                let way = 2;
                                                let shote = 855;
			let delay = 20;
			let speed = 0;
			let sht1;
			let sht2;

			loop( way ){

                      	                let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );

				ObjShot_SetSpellResist( sht1, true );
				ObjShot_SetAutoDelete( sht1, false );

				PatternWhite( sht1 );
				PatternWhite1( sht1 );

				ObjectRotation( sht1, objBoss, 500, 250, angle, -1, -2.5, 0, 0 );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			}

			PlaySound("Boon1",92,0);
                       		if( wait( 1 ) ){ return; }


	}

   }

              task PatternBorder41{ 
              loop( 1 ){

              			let angle = rand( 0, 360 );
	                                let way = 3;
                                                let shote = 858;
			let delay = 20;
			let speed = 0;
			let sht1;
			let sht2;

			loop( way ){

                      	                let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );

				ObjShot_SetSpellResist( sht1, true );
				ObjShot_SetAutoDelete( sht1, false );

				PatternBlue( sht1 );

				ObjectRotation( sht1, objBoss, 500, 230, angle, -1, 2.3, 0, 0 );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			}

			PlaySound("Boon1",92,0);
                       		if( wait( 1 ) ){ return; }


	}

   }
              task PatternBorder42{ 
              loop( 1 ){

              			let angle = rand( 0, 360 );
	                                let way = 3;
                                                let shote = 858;
			let delay = 20;
			let speed = 0;
			let sht1;
			let sht2;

			loop( way ){

                      	                let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );

				ObjShot_SetSpellResist( sht1, true );
				ObjShot_SetAutoDelete( sht1, false );

				ObjectRotation( sht1, objBoss, 500, 20, angle, -0.9, -1.5, 0, 0 );

				DelayDeletes( sht1, 540 );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			}

			PlaySound("Boon1",92,0);
                       		if( wait( 1 ) ){ return; }


	}

   }

              task PatternBorder5{ 
              loop( 1 ){

              			let angle = rand( 0, 360 );
	                                let way = 3;
                                                let shote = 860;
			let delay = 20;
			let speed = 0;
			let sht1;

			loop( way ){

                      	                let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );

				ObjShot_SetSpellResist( sht1, true );
				ObjShot_SetAutoDelete( sht1, false );

				PatternGreen( sht1 );

				ObjectRotation( sht1, objBoss, 500, 200, angle, -1, 2, 0, 0 );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			}

			PlaySound("Boon1",92,0);
                       		if( wait( 1 ) ){ return; }


	}

   }

              task PatternBorder6{ 
              loop( 1 ){

              			let angle = rand( 0, 360 );
	                                let way = 2;
                                                let shote = 859;
			let delay = 20;
			let speed = 0;
			let sht1;
			let sht2;

			loop( way ){

                      	                let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				sht2 = TShotA2( sx, sy, speed, angle + 90, 0, speed, shote, delay );

				ObjShot_SetSpellResist( sht1, true );
				ObjShot_SetAutoDelete( sht1, false );
				ObjShot_SetSpellResist( sht2, true );
				ObjShot_SetAutoDelete( sht2, false );

				ObjectRotation( sht1, objBoss, 500, 200, angle, -1, -2, 0, 0 );
				ObjectRotation( sht2, objBoss, 500, 200, angle, -1, 2, 0, 0 );

				PatternAqua1( sht1 );
				PatternAqua2( sht2 );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			}
			PlaySound("Boon1",92,0);
                       		if( wait( 1 ) ){ return; }


	}

   }

              task PatternBorder71{ 
              loop( 1 ){

              			let angle = rand( 0, 360 );
	                                let way = 2;
                                                let shote = 861;
			let delay = 20;
			let speed = 0;
			let sht1;

			loop( way ){

                      	                let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );

				ObjShot_SetSpellResist( sht1, true );
				ObjShot_SetAutoDelete( sht1, false );

				PatternYellow( sht1 );

				ObjectRotation( sht1, objBoss, 500, 250, angle, -1, 2.5, 0, 0 );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			}

			PlaySound("Boon1",92,0);
                       		if( wait( 1 ) ){ return; }


	}

   }

              task PatternBorder72{ 
              loop( 1 ){

              			let angle = rand( 0, 360 );
	                                let way = 3;
                                                let shote = 861;
			let delay = 20;
			let speed = 0;
			let sht1;
			let sht2;

			loop( way ){

                      	                let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );

				ObjShot_SetSpellResist( sht1, true );
				ObjShot_SetAutoDelete( sht1, false );

				ObjectRotation( sht1, objBoss, 500, 20, angle, -0.9, 1.5, 0, 0 );

				DelayDeletes( sht1, 545 );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			}

			PlaySound("Boon1",92,0);
                       		if( wait( 1 ) ){ return; }


	}

   }

              task PatternRed( sht3 ){
              let x = ObjMove_GetX( objBoss );
              let y = ObjMove_GetY( objBoss );
              let Rangle = 0;
              wait( 300 );
              let R = 10;
              let r = 0;
              let c = 0;
              let shote = [ 2, 3 ];
              loop( 32 ){
              let speed = 2;
              loop( 6 ){
              			let angle = GetDotAngle(x,y,ObjMove_GetX( sht3 ),ObjMove_GetY( sht3 )) + Rangle;
	                                let way = 2;
			let delay = 20;

			loop( way ){

                      	                let sx = ObjMove_GetX( sht3 );
                        		let sy = ObjMove_GetY( sht3 );
				
				let sht11 = TShotA2( sx, sy, speed, angle, 0, speed, shote[ c%length( shote )], delay );
				ObjMove_AddPatternA2( sht11, R, 0, NO_CHANGE, 0, 0, 0 );
				ObjMove_AddPatternA2( sht11, 1000 - r, 0, NO_CHANGE, 0.02, 0, 1.4 );

				ObjShot_SetSpellResist( sht11, true );

				NotifyEventAll( EV_USER + 40, [ sht11, delay ] );

				angle += 360 / way;
			}
			speed += 0.02;
			PlaySound("LenenShot1",92,0);
                       		if( wait( 2 ) ){ return; }

	}
	        c++;
	        Rangle += 0.6;
	        R += 6;
	        r += 20;
                        if( wait( 12 ) ){ return; }

	}

	        Obj_Delete( sht3 );

   }

              task PatternOrange( sht3 ){ 
              wait( 300 );
              let R = 30;
              let Rangle = 30;
              let r = 0;
              let angle = GetDotAngle(ObjMove_GetX( objBoss ),ObjMove_GetY( objBoss ),ObjMove_GetX( sht3 ),ObjMove_GetY( sht3 )) + Rangle;
              loop( 25 ){
              loop( 5 ){
              let speed = 1.5;
	                                let way = 3;
                                                let shote = 15;
			let delay = 20;

			loop( way ){

                      	                let sx = ObjMove_GetX( sht3 );
                        		let sy = ObjMove_GetY( sht3 );
				
				let sht11 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjMove_AddPatternA2( sht11, R, 0, NO_CHANGE, 0, 0, 0 );
				ObjMove_AddPatternA2( sht11, 900 - r, 0, NO_CHANGE, 0.02, 0, 1.2 );

				ObjShot_SetSpellResist( sht11, true );

				NotifyEventAll( EV_USER + 40, [ sht11, delay ] );

				angle += 360 / way;
			}
			angle -= 1;
			PlaySound("LenenShot1",92,0);
                       		if( wait( 1 ) ){ return; }

	}
	        Rangle += 30;
	        R += 5;
	        r += 19;
	        angle += 192;
                        if( wait( 17 ) ){ return; }

	}

	Obj_Delete( sht3 );

   }

              task PatternOrange1( sht3 ){ 
              wait( 300 );
              let R = 30;
              let Rangle = 30;
              let r = 0;
              let angle = GetDotAngle(ObjMove_GetX( objBoss ),ObjMove_GetY( objBoss ),ObjMove_GetX( sht3 ),ObjMove_GetY( sht3 )) + Rangle;
              loop( 25 ){
              loop( 5 ){
              let speed = 1.5;
	                                let way = 3;
                                                let shote = 13;
			let delay = 20;

			loop( way ){

                      	                let sx = ObjMove_GetX( sht3 );
                        		let sy = ObjMove_GetY( sht3 );
				
				let sht11 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjMove_AddPatternA2( sht11, R, 0, NO_CHANGE, 0, 0, 0 );
				ObjMove_AddPatternA2( sht11, 900 - r, 0, NO_CHANGE, 0.02, 0, 1.2 );

				ObjShot_SetSpellResist( sht11, true );

				NotifyEventAll( EV_USER + 40, [ sht11, delay ] );

				angle += 360 / way;
			}
			angle -= 1;
			
			PlaySound("LenenShot1",92,0);
                       		if( wait( 1 ) ){ return; }

	}
	        Rangle -= 30;
	        R += 5;
	        r += 19;
	        angle -= 195;
                        if( wait( 17 ) ){ return; }

	}

	Obj_Delete( sht3 );

   }

              task PatternWhite( sht3 ){              
              wait( 300 );
              let Rangle = 0;
              let x = ObjMove_GetX( objBoss );
              let y = ObjMove_GetY( objBoss );
              let R = 0;
              let r = 0;
              loop( 900 ){

              			let angle = GetDotAngle( x, y ,ObjMove_GetX( sht3 ),ObjMove_GetY( sht3 )) + Rangle; 
              			let speed = 3;
	                                let way = 1;
                                                let shote = 16;
			let delay = 20;

			loop( way ){

                      	                let sx = ObjMove_GetX( sht3 );
                        		let sy = ObjMove_GetY( sht3 );
				
				let sht11 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjMove_AddPatternA2( sht11, R, 0, NO_CHANGE, 0, 0, 0 );
				ObjMove_AddPatternA2( sht11, 1000 - r, 0, NO_CHANGE, 0.03, 0, 3 );

				ObjShot_SetSpellResist( sht11, true );

				NotifyEventAll( EV_USER + 40, [ sht11, delay ] );

				angle += 360 / way;
			}	
			PlaySound("LenenShot1",92,0);
	        		Rangle -= 0.05;
	        		R += 0.5;
	        		r += 1;
                        		if( wait( 1 ) ){ return; }

	}

			Obj_Delete( sht3 );

   }


              task PatternWhite1( sht3 ){              
              wait( 420 );
              let Rangle = 0;
              let x = ObjMove_GetX( objBoss );
              let y = ObjMove_GetY( objBoss );
              loop( 145 ){

              			let angle = GetDotAngle( x, y ,ObjMove_GetX( sht3 ),ObjMove_GetY( sht3 )) + Rangle; 
              			let speed = 0.6;
	                                let way = 1;
                                                let shote = 1;
			let delay = 20;

			loop( way ){

                      	                let sx = ObjMove_GetX( sht3 );
                        		let sy = ObjMove_GetY( sht3 );
				
				let sht11 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjMove_AddPatternA2( sht11, 100, NO_CHANGE, NO_CHANGE, 0.025, 0, 3 );

				ObjShot_SetSpellResist( sht11, true );

				NotifyEventAll( EV_USER + 40, [ sht11, delay ] );

				angle += 360 / way;
			}	
			PlaySound("LenenShot1",92,0);
	        		Rangle -= 0;
                        		if( wait( 5 ) ){ return; }

	}

   }

              task PatternBlue( sht3 ){              
              wait( 300 );
              let R = 0;
              let Rangle = -80;
              let r = 0;
              let shote = [ 6, 7 ];
              let c = 0;
              loop( 163 ){
              let x = ObjMove_GetX( objBoss );
              let y = ObjMove_GetY( objBoss );
              loop( 3 ){

              			let angle = GetDotAngle( x, y ,ObjMove_GetX( sht3 ),ObjMove_GetY( sht3 )) + Rangle; 
              			let speed = 2.4;
	                                let way = 2;
			let delay = 20;

			loop( way ){

                      	                let sx = ObjMove_GetX( sht3 );
                        		let sy = ObjMove_GetY( sht3 );
				
				let sht11 = TShotA2( sx, sy, speed, angle, 0, speed, shote[c%length( shote )], delay );
				ObjMove_AddPatternA2( sht11, R, 0, NO_CHANGE, 0, 0, 0 );
				ObjMove_AddPatternA2( sht11, 1100 - r, 0, NO_CHANGE, 0.03, 0, 1.8 );

				ObjShot_SetSpellResist( sht11, true );

				NotifyEventAll( EV_USER + 40, [ sht11, delay ] );

				angle += 360 / way;
			}	
			angle += 10;
			PlaySound("LenenShot1",92,0);
                        		if( wait( 1 ) ){ return; }

	}
			c++;
	        		R += 3;
	        		r += 4;
	        		Rangle += 120;
                        		if( wait( 2 ) ){ return; }

	}

			Obj_Delete( sht3 );

   }

              task PatternBlue1{ 
              wait( 540 );
              loop( 1 ){

              			let speed = 0.09;
	                                let way = 65;
                                                let shote = 810;
              			let angle = rand( 0, 360 );
			let delay = 30;

			loop( way ){

                      	                let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjMove_AddPatternA2( sht1, 900, NO_CHANGE, angle + 180, 0.025, 0, 1.5 );

				ObjShot_SetSpellResist( sht1, true );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			}
			PlaySound("LenenShot1",92,0);
                        		if( wait( 1 ) ){ return; }

	}

   }


              task PatternGreen( sht3 ){              
              wait( 300 );
              loop( 2 ){

              			let angle = rand( 0, 360 ); 
	                                let way = 8;
                                                let shote = 1011;
			let delay = 150;
			let length = 800;
			let width = 20;
			let duration = 600;
			let sht11;

			loop( way ){
			let r = -30;
                      	                let sx = ObjMove_GetX( sht3 ) + r*cos( angle );
                        		let sy = ObjMove_GetY( sht3 ) + r*sin( angle );
				
				sht11 = CreateStraightLaserA1( sx, sy, angle, 0, width, duration, shote, delay );
				ObjRender_SetBlendType( sht11, BLEND_ADD_RGB );
				BeginCurtain( sht11, 0, length );
				OpeningCurtain( sht11, delay, width );
				ClosingCurtain( sht11, duration - width, width );

				PatternGreen1( sht11 );

				NotifyEventAll( EV_USER + 40, [ sht11, delay ] );

				angle += 360 / way;
			}	
			PlaySound("Laser2",92,0);
                        		if( wait( 500 ) ){ return; }

	}

			Obj_Delete( sht3 );

   }


              task PatternGreen1( sht11 ){ 
              loop( 1 ){

              			let speed = 3;
	                                let way = 1;
                                                let shote = 1;
              			let angle = ObjStLaser_GetAngle( sht11 );
			let delay = 30;
			let sht1;

			loop( way ){
			let r = 30;
                      	                let sx = ObjMove_GetX( sht11 ) + r*cos( angle );
                        		let sy = ObjMove_GetY( sht11 ) + r*sin( angle );
				
				sht1 = TShotA2( sx, sy, 0, angle, 0, 0, shote, delay );
				ObjMove_AddPatternA2( sht1, 230, speed, angle, 0, 0, 1.5 );

				ObjRender_SetAlpha( sht1, 0 );
				ObjShot_SetSpellResist( sht1, true );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			}
			PatternGreen2( sht1 );
                        		if( wait( 1 ) ){ return; }

	}

   }

              task PatternGreen2( sht1 ){ 
              wait( 260 );
              let R = 0;
              let shote = [ 10, 11 ];
              let c = 0;
              while( !Obj_IsDeleted( sht1 )){
              let angle = rand( 0, 360 );
              loop( 6 ){

              			let speed = 1;
	                                	let way = 1;
			let delay = 20;

			if( Obj_IsDeleted( sht1 )){ break; }

			loop( way ){

                      	                	let sx = ObjMove_GetX( sht1 );
                        		let sy = ObjMove_GetY( sht1 );
				
				let sht2 = TShotA2( sx, sy, 0, angle, 0, 0, shote[c%length( shote )], delay );
				ObjMove_AddPatternA2( sht2, 500 - R, 0, NO_CHANGE, 0.01, 0, speed );

				ObjShot_SetSpellResist( sht2, true );

				NotifyEventAll( EV_USER + 40, [ sht2, delay ] );

				angle += 360 / way;

			}
			PlaySound("LenenShot1",92,0);
                        		if( wait( 2 ) ){ return; }

	}		
			c++;
			R += 11;
                        		if( wait( 6 ) ){ return; }

	}

   }


              task PatternAqua1( sht3 ){              
              wait( 300 );
              let Rangle = 200;
              let x = ObjMove_GetX( objBoss );
              let y = ObjMove_GetY( objBoss );
              let R = 0;
              let r = 0;
              let c = 0;
              loop( 400 ){

              			let speed = 1.875;
			let speedadd = [ 0.2, 0.4 ];
              			let angle = GetDotAngle( x, y ,ObjMove_GetX( sht3 ),ObjMove_GetY( sht3 )) + Rangle; 
	                                	let way = 2;
                                                	let shote = 9;
			let delay = 10;

			loop( way ){

                      	                	let sx = ObjMove_GetX( sht3 );
                        		let sy = ObjMove_GetY( sht3 );

				let sht12 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjMove_AddPatternA2( sht12, R, 0, NO_CHANGE, 0, 0, 0 );
				ObjMove_AddPatternA2( sht12, 600 - r, 0, angle, 0.005, 0, speedadd[ c%length( speedadd ) ] );

				ObjShot_SetSpellResist( sht12, true );

				NotifyEventAll( EV_USER + 40, [ sht12, delay ] );

				angle += 180 / way;
			}
			c++;	
			PlaySound("LenenShot1",92,0);
	        		Rangle -= 1;
	        		R += 0.5;
	        		r += 1;
                        		if( wait( 1 ) ){ return; }

	}

			Obj_Delete( sht3 );

   }

              task PatternAqua2( sht3 ){              
              wait( 300 );
              let Rangle = -200;
              let x = ObjMove_GetX( objBoss );
              let y = ObjMove_GetY( objBoss );
              let R = 0;
              let r = 0;
              let c = 0;
              loop( 400 ){

              			let speed = 1.875;
			let speedadd = [ 0.2, 0.4 ];
              			let angle = GetDotAngle( x, y ,ObjMove_GetX( sht3 ),ObjMove_GetY( sht3 )) + Rangle; 
	                                	let way = 2;
                                                	let shote = 8;
			let delay = 10;

			loop( way ){

                      	                	let sx = ObjMove_GetX( sht3 );
                        		let sy = ObjMove_GetY( sht3 );

				let sht12 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjMove_AddPatternA2( sht12, R, 0, NO_CHANGE, 0, 0, 0 );
				ObjMove_AddPatternA2( sht12, 600 - r, 0, angle, 0.005, 0, speedadd[ c%length( speedadd ) ] );

				ObjShot_SetSpellResist( sht12, true );

				NotifyEventAll( EV_USER + 40, [ sht12, delay ] );

				angle += 180 / way;
			}
			c++;	
			PlaySound("LenenShot1",92,0);
	        		Rangle += 1;
	        		R += 0.5;
	        		r += 1;
                        		if( wait( 1 ) ){ return; }

	}

			Obj_Delete( sht3 );

   }

              task PatternYellow( sht1 ){ 
              wait( 300 );
              let R = 0;
              let r = 0;
              let c = 0;
              let s = 0;
              let shote = [ 13, 14 ];
              loop( 80 ){
              let x = ObjMove_GetX( objBoss );
              let y = ObjMove_GetY( objBoss );
              let speedarray = [ 0.3, 0.4, 0.5 ];
              let z = speedarray[ c%length( speedarray) ];
              loop( 6 ){

              			let speed = 1;
	                                	let way = 2;
              			let angle = GetDotAngle( x, y ,ObjMove_GetX( sht1 ),ObjMove_GetY( sht1 )); 
			let delay = 30;

			loop( way ){

                      	               	let sx = ObjMove_GetX( sht1 );
                        		let sy = ObjMove_GetY( sht1 );
				
				let sht11 = TShotA2( sx, sy, speed, angle, 0, speed, shote[c%length( shote )], delay );
				ObjMove_AddPatternA2( sht11, R, 0, NO_CHANGE, 0, 0, 0 );
				ObjMove_AddPatternA2( sht11, 800 - r, NO_CHANGE, angle, 0.01, 0, z );
				ObjMove_AddPatternA2( sht11, 1200 - s, NO_CHANGE, NO_CHANGE, 0.03, 0, 2.5 + z );

				ObjShot_SetSpellResist( sht11, true );

				NotifyEventAll( EV_USER + 40, [ sht11, delay ] );

				angle += 360 / way;

			}
			PlaySound("LenenShot1",92,0);
                        		if( wait( 1 )){ return; }

	}		
			c++;
			r += 6;
			s += 8;
                        		if( wait( 4 )){ return; }

	}

	Obj_Delete( sht1 );

   }

              task PatternYellow1{ 
              wait( 540 );
              let R = 0;
              let r = 0;
              let angle = rand( 0, 360 );
              loop( 120 ){

              			let speed = 2.2;
	                                	let way = 6;
                                                	let shote = 514;
			let delay = 30;

			loop( way ){

                      	                	let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjMove_AddPatternA2( sht1, R, 0, NO_CHANGE, 0, 0, 0 );
				ObjMove_AddPatternA2( sht1, 600 - r, NO_CHANGE, angle, 0.01, 0, 2.5 );

				ObjShot_SetSpellResist( sht1, true );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			}
			angle -= 7.6;
			R += 1;	
			r += 3;
			PlaySound("LenenShot1",92,0);
                        		if( wait( 3 ) ){ return; }

	}

   }

              task PatternPurple{ 
              let angle = rand( 0, 360 );
              loop( 20000 ){

              			let speed = 2.4;
	                                	let way = 5;
                                               	let shote = 5;
			let delay = 60;

			loop( way ){
			let r = 300;
                      	                	let sx = ObjMove_GetX( objBoss ) + r*cos( angle );
                        		let sy = ObjMove_GetY( objBoss ) + r*sin( angle );
			let anglepoint = GetDotAngle( ObjMove_GetX( objBoss ), ObjMove_GetY( objBoss ), sx, sy );
				
				let sht1 = TShotA2( sx, sy, 0, anglepoint, 0.005, speed, shote, delay );

				ObjShot_SetSpellResist( sht1, true );
				ObjShot_SetAutoDelete( sht1, false );

				DelayDeletes( sht1, 405 );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			
			}	
			angle += 2.9;
			PlaySound("LenenShot1",92,0);
                        		if( wait( 2 ) ){ return; }

	}

   }

              task PatternPurple1{ 
              loop( 5 ){

              			let angle = rand( 0, 360 );
              			let speed = 0.15;
	                                	let way = 100;
                                                	let shote = 856;
			let delay = 60;

			loop( way ){
                      	                	let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );

				
				let sht1 = TShotA2( sx, sy, 0, angle, 0.001, speed, shote, delay );

				ObjShot_SetSpellResist( sht1, true );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			
			}	
			PlaySound("LenenShot1",92,0);
                        		if( wait( 400 ) ){ return; }

	}

   }


              task PatternOuterBorder( t, sht, cent ){ 
              wait( t );
              while( !Obj_IsDeleted( cent )){

              			let speed = 0.5;
	                                	let way = 1;
                                                	let shote = sht;
              			let angle = GetDotAngle( ObjMove_GetX( cent ), ObjMove_GetY( cent ), ObjMove_GetX( objBoss ), ObjMove_GetY( objBoss ) );
			let delay = 0;

			loop( way ){

                      	                	let sx = ObjMove_GetX( cent );
                        		let sy = ObjMove_GetY( cent );
				
				let sht1 = TShotA2( sx, sy, speed, angle + rand( -15, 15 ), 0, speed, shote, delay );

				ObjShot_SetSpellResist( sht1, true );

				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle += 360 / way;

			}
			PlaySound("LenenShot1",92,0);
                        		if( wait( 1 ) ){ return; }

	}

   }

	task StartCountDown
	{
		wait((222*60) - (10*60));
		loop(5)
		{
			PlaySound("time1",100,0);
			wait(60);
		}
		loop(5)
		{
			PlaySound("time2",100,0);
			wait(60);
		}
	}

task ClosingCurtain( obj, t, width ){
wait( t );
descent(i in 0..width){
ObjLaser_SetRenderWidth( obj, i );
ObjLaser_SetIntersectionWidth( obj, i );
ObjShot_SetIntersectionEnable( obj, false );
yield;
}
}

task BeginCurtain( obj, t, length ){
wait( t );
ascent(i in 0..length){
ObjLaser_SetLength( obj, i*3 );
ObjLaser_SetIntersectionWidth( obj, 0 );
yield;
}
}

task OpeningCurtain( obj, t, width ){
wait( t );
ascent(i in 0..width){
ObjLaser_SetRenderWidth( obj, i );
ObjLaser_SetIntersectionWidth( obj, i );
yield;
}
}
	task DelayDeletes( obj, t ){
	wait( t );
	Obj_Delete( obj );
	}

	function GetDotAngle(x1,y1,x2,y2){
	let angle=atan2(y1-y2,x1-x2);
	return angle;
	}

task ObjectRotation( obj, target, rstart, rmax, angle, ad, av, aad, aav ){

   let ox;
   let oy;
   let r = rstart;
   while(!Obj_IsDeleted(obj)){

      ox = ObjMove_GetX( target ) + r*cos( angle );
      oy = ObjMove_GetY( target ) + r*sin( angle );

      ObjMove_SetPosition(obj,ox,oy);
      ObjStLaser_SetAngle(obj,angle);

      if(r < rmax){
      r += ad;
      ad += aad; }

      if(r > rmax){
      r += ad;
      ad += aad; }

      angle += av;
      av += aav;

      yield;
   }
}


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

task TEnd{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
		EndBoss(1);
		yield;
		CloseScript(GetOwnScriptID());
	}