script_enemy_main {
    let time = -120;
    let phase = 1;
    let rate = 20;
    let kaku = 40;
    let lv = 0;
    let score = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let mapx = GetX();
    let mapy = GetY();
    let imgEnemy = GetCurrentScriptDirectory~"img\st1semiboss.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se7 = GetCurrentScriptDirectory~"wav\se7.wav";
    let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
    let seshot1 = GetCurrentScriptDirectory~"wav\shot1.wav";
    let seshot2 = GetCurrentScriptDirectory~"wav\shot2.wav";
    SetCommonData("haya",0);
    @Initialize(){
		SetLife( 1400 );
		SetInvincibility( 120 );
		LoadGraphic( imgEnemy );
		LoadUserShotData( tama );
		Tmove;
		Tgazou(1,1,320,320);
		layer = 1;
		bairitu = 1;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           score = 30000;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, 224, 240, 500);}
           Tdeath(14,64,2,0);
           Tbaku;Toti;
           SetCommonData("haya",1);
        }
        if(time>2000){VanishEnemy;}
        if(phase>=1){
           SetCollisionA(GetX(), GetY(), 100);
           SetCollisionA(GetX()+100, GetY(), 40);
           SetCollisionA(GetX()-100, GetY(), 40);
           SetCollisionB(GetX, GetY, 55);
           SetCollisionB(GetX+80, GetY, 25);
           SetCollisionB(GetX-80, GetY, 25);
        }
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}


        time++;
        yield;
    }
    @Finalize() {
       SetCommonData("haya",1);
    }
    @DrawLoop {
    }

	task Tshot1{
		wait(60);
		loop{
		let p=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()+60));
		let b=0;
		loop(20){
		   if(phase<=0){return;}
		   SetShotDirectionType(ABSOLUTE);
		   let c=-2-ex*2;
		   loop(5+ex*4){
		   CreateShotFromScript( "shot1",GetX()+60, GetY(), 2.8+b*0.3, genteikaku(p,32)+c*2.2, 0, 06);
		      c++;
		   }
		   PlaySE(seshot1);
		   wait(3);
		   b++;
		}
		wait(35-lv*35);
		let p=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()-60));
		let b=0;
		loop(20){
		   if(phase<=0){return;}
		   SetShotDirectionType(ABSOLUTE);
		   let c=-2-ex*2;
		   loop(5+ex*4){
		      CreateShotFromScript( "shot1",GetX()-60, GetY(), 2.8+b*0.3, genteikaku(p,32)+c*2.2, 0, 06);
		      c++;
		   }
		   PlaySE(seshot1);
		   wait(3);
		   b++;
		}
		wait(35-lv*35);
		let p=atan2( GetPlayerY()-(GetY()+30), GetPlayerX()-(GetX()));
		let b=0;
		loop(30){
		   if(phase<=0){return;}
		   SetShotDirectionType(ABSOLUTE);
		   let c=-2-ex*2;
		   loop(5+ex*4){
		   CreateShotFromScript( "shot1",GetX(), GetY()+30, 2.8+b*0.3, genteikaku(p,32)+c*2.2, 0, 06);
		      c++;
		   }
		   PlaySE(seshot1);
		   wait(3);
		   b++;
		}
		wait(35-lv*35);
		}
	}
	
	task Tshot2{
		let a=0;
		let b=0;
		let kakudo=0;
		loop{
		   if(phase<=0){return;}
		   SetShotDirectionType(ABSOLUTE);
		   if(b<=3){kakudo=-2+b;}
		   if(b>3){kakudo=6-b;}
		   let c=0;
		   loop(3+ex*2){
		      let d=-2;
		      loop(5){
		         CreateShotFromScript( "shot1",GetX()+60, GetY()-20, 2.7+c*0.17+ex, 90+kakudo*35+d*22, 0, 13);
		         CreateShotFromScript( "shot1",GetX()-60, GetY()-20, 2.7+c*0.17+ex, 90+kakudo*35+d*22, 0, 13);
		         d++;
		      }
		      c++;
		   }
		   PlaySE(seshot2);
		   a+=15-lv*7;
		   wait(15-lv*7);
		   b++;
		   b=b%8;
		}
	}
	
	task Tmove {
		SetMovePosition02(224, 140, 120);
		wait(120);
		Tshot1;Tshot2;
		loop(10){
			SetMovePosition02(224+rand(40,-40), 140+rand(20,-20), 80);
			wait(80);
			if(phase<=0){return;}
		}
		SetMovePosition02(224, -100, 120);
		phase=0;
		wait(120);
		VanishEnemy();
    }
   task setmove(a,t) {
      loop(t) {
         mapx+=cos(a)*0.8;mapy-=sin(a)*0.8;
         yield;
      }
   }
   task Toti{
      layer=1;
      SetMovePosition02(224, 260, 80);
      let a=0;
      loop(80){
        if(a%10==0){PlaySE(se3);}
        bairitu=1-a/80*0.3;
        a++;
        yield;
      }
      Explosion01(GetX,GetY,5,0.4,50);
      PlaySE(se7);
      VanishEnemy();
   }


    #include_function".\efanction.txt"
    #include_function".\effobj.txt"
}

#include_script".\escript.txt"