#TouhouDanmakufu
#Title[First Nonspell (test)]
#Text[SECANTCOSINE!]
#Player[FREE]
#BGM[.\BGM.mp3]
#ScriptVersion[2]
#BackGround[User(.\BG.png, 0, 0)]


script_enemy_main {
    let ImgBoss = GetCurrentScriptDirectory~"nimono.png";
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let shot2 = GetCurrentScriptDirectory~"shot2.wav";
	let bounce = GetCurrentScriptDirectory~"bounce.wav";
	let explode = GetCurrentScriptDirectory~"explode.wav";
	let familiarspawn = GetCurrentScriptDirectory~"familiarspawn.wav";
	let tilt = 0;
	let side = 1;
	let alive = 1;
	let moo = 867;
	let xs = GetCommonData("secx");
	let ys = GetCommonData("secy");
	let xy = 0;
	let nyan = 1;
	let v = 1;
    let frame = -120;
	let frame2 = 1;
	let n = 0;
#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
    @Initialize {
	DeleteSE("se\seEnemyExplode01.wav");
        SetLife(3000);
	SetCommonData("alive", true);
        SetTimer(60);
        LoadSE(shot);
	LoadSE(bounce);
	LoadSE(shot2);
	LoadSE(familiarspawn);
	SetShotAutoDeleteClip(100, 200, 100, 100);
	shotinit;
	SetEnemyMarker(true);
	SetInvincibility(120);
	SetDamageRate(100, 40);
        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        
        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
        SetGraphicRect(1, 1, 128, 128);
    }

    @MainLoop {

	let xs = GetCommonData("secx");
	let ys = GetCommonData("secy");


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

if(frame==60){
yomo;
frame=-120;
}




yield;
        frame++;
	frame2+=0.5;
	


    }


task ExMove { 
wait(120);
		SetMovePosition03(GetClipMinX+20, GetClipMinY+120+rand(-15, 15), 30, 2);
		wait(320);
		SetMovePosition03(GetClipMaxX-20, GetClipMinY+120+rand(-15, 15), 30, 2);
		

}
	// Movement functions for the boss to move towards the player.
function wait(w) { loop(w) { yield; } }	

task LifeGet{ AddLife(1); }

task Shoot{

		loop(1){
		SetMovePosition02(GetCommonData("secx"), GetCommonData("secy"), 60);
		wait(60);
		CreateShot01(GetX, GetY, 2, rand(0, 360), RED22, 0);
}
yield;
}
task yomo{
let angle = 90; let r = -100;
			let a = 0; let b = 0; let c = 0;
			loop(25) {
				ascent(i in -7..8) {
					let v1 = 5+absolute(i)/4;
					let v2 = 5/3-absolute(i)/7;
					
					CreateShotA(0, GetX+r*cos(angle+a), GetY+r*sin(angle+a), 20);
					SetShotDataA(0, 0, 2, angle-a-b*side+i*100, 0, (v2-v1)/30, 2, YELLOW01);
					
					FireShot(0);
					CreateShotA(0, GetX+r*cos(angle-a), GetY+r*sin(angle-a), 20);
					SetShotDataA(0, 0, 2, angle+a+b*side+i*100, 0, (v2-v1)/30, 2, AQUA01);
					
					FireShot(0);
				}
				a+=27-c/2; b-=2; c+=1; r+=5;
				wait(10);
				
			}
}
    @DrawLoop {
		if(tilt == 0){
		SetGraphicAngle(0, 0, 0);
                DrawGraphic(GetX,GetY);
		}

    }
let v = 0;
    @Finalize {
        DeleteGraphic(ImgBoss);
    }
}
