#TouhouDanmakufu
#Title[Familiar]
#Text[Moo]
#Player[FREE]
#ScriptVersion[2]
#BackGround[User(.\moon.png, 0, 0)]

script_enemy_main {
    let ImgBosss = GetCurrentScriptDirectory~"fairies.png";
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let shot2 = GetCurrentScriptDirectory~"shot2.wav";
	let bounce = GetCurrentScriptDirectory~"bounce.wav";
	let spark = GetCurrentScriptDirectory~"spark.wav";
	let laser = GetCurrentScriptDirectory~"laser.wav";
	let angle = 1;
	let explode = GetCurrentScriptDirectory~"explode.wav";
	let t = 0;
	let a = 0;
	let b = 0;
	let w = rand(0.1, 2);
	let v = 1;
	let angle = 1;
	let radius = 50;
	let z = 0;
    let frame = 0;
	
	let frame2 = 1;
	let n = 0;
#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
    @Initialize {
        SetLife(100);
        SetTimer(9999);
	shoot;
        LoadSE(shot);
	LoadSE(bounce);
	LoadSE(shot2);
	SetShotAutoDeleteClip(200, 200, 200, 40);
	shotinit;
	SetEnemyMarker(true);
	SetInvincibility(10);
	SetDamageRate(100, 100);
        
        LoadGraphic(ImgBosss);
        SetTexture(ImgBosss);
        SetGraphicRect(0, 290, 30, 318);
	
    }

    @MainLoop {
	
	if(frame<60 && frame>0 || frame>420){
SetMovePosition03(GetPlayerX+radius*cos(angle), GetPlayerY+radius*sin(angle), w, w);
	yield;
}

	

	if(frame == 60){
		SetMovePosition02(GetX, GetY, 1);

	
            CreateLaserA(1, GetX, GetY, 4, 45, YELLOW60, 120);
	    SetLaserDataA(1, 0, GetAngleToPlayer, 0, 8, 0, 0); 
	    SetShotKillTime(1, 320);
	    FireShot(1);
            PlaySE(laser);
      
	
	
    }
if(frame == 180){
	PlaySE(spark);
	}
	if(frame == 660){
	frame=0;
	}

	angle++;
        frame++;
	v+=0.02;
	b+=1;
	
    }

function Wait(w){loop(w){yield;}}


task shoot{
	loop{
	Wait(10);
	PlaySE(shot);
	CreateShot01(GetX, GetY, 1.5, GetAngleToPlayer, GREEN58, 10);
}
}

    @DrawLoop {
		SetGraphicAngle(0,0,b);
                DrawGraphic(GetX,GetY);
    }
let v = 0;
    @Finalize {
        DeleteGraphic(ImgBosss);
    }
}
