#TouhouDanmakufu
#Title[Shinki's 3nd Nonspell -Normal-]
#Text[Devil's Recitation!]
#Player[FREE]
#BGM[.\infinity.mp3]
#ScriptVersion[2]
#BackGround[User(.\stgbg.png, 0, 0)]


script_enemy_main {
	let one = 1;
	let frame = 0;
	let frame2 = 0;
	let frame3 = 0;
	let angle = 0;
	let angle2 = 0;
	let angle3 = 0;
	let shot = GetCurrentScriptDirectory~"shot.wav";
	let shot2 = GetCurrentScriptDirectory~"shot2.wav";
	let shot3 = GetCurrentScriptDirectory~"shot3.wav";
	let bounce = GetCurrentScriptDirectory~"bounce.wav";
	let explode = GetCurrentScriptDirectory~"explode.wav";
	let familiarspawn = GetCurrentScriptDirectory~"familiarspawn.wav";
	let time1 = GetCurrentScriptDirectory~"time1.wav";
	let time2 = GetCurrentScriptDirectory~"time2.wav";
	let frame = -120;
	let timer = GetTimer;
#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
#include_function ".\shinkianimationyay.txt"
    @Initialize {
	
	DeleteSE("se\seEnemyExplode01.wav");
	DeleteSE("se\seUseSpellCard.wav");
        SetLife(6000);
        SetTimer(41);
        LoadSE(shot);
	LoadSE(bounce);
	LoadSE(time1);
	LoadSE(time2);
	LoadSE(shot2);
	LoadSE(shot3);
	LoadSE(familiarspawn);
	SetShotAutoDeleteClip(100, 200, 100, 100);
	shotinit;
	SetEnemyMarker(true);
	SetInvincibility(120);
	SetDamageRate(200, 50);
        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        
       
    }

task GenericNonspell{
	let randnum1 = rand(-50, 50);
	let randnum2 = rand(-30, 30);
	one=one*-1;
	let num = 12;
	ascent(i in 2..16){
		PlaySE(shot3);
		loop(num){
		CreateShot01(GetX, GetY, i/3.5, 90+angle+angle2, WHITE04, 2+i);
		angle+=360/num;
		}
		angle2+=2*one;
		
		}
	ExMove;
	wait(60);
	ascent(i in 0..20){
	let randnum1 = rand(-300, 300);
	let randnum2 = rand(-50, 20);
	PlaySE(shot);
	
	loop(8){
		CreateShot01(GetX+randnum1, GetY+randnum2, rand(2, 3), angle3+angle-180, BLUE56, 20);
		
		angle+=360/8;
	}
	angle3+=360/16;
		
		wait(4);
		}
	}


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

sub ExMove { ExMove_(GetCenterY-80, 10, rand(30, 60)); }
function ExMove_(height, ud, length) {
	
	if(GetPlayerX < GetX) {
		if(GetX - length <= GetClipMinX) {
			SetMovePosition03(GetX + length, rand(height+20 - ud, height + ud), 5, 1);
		} else {
			SetMovePosition03(GetX - length, rand(height - ud, height + ud), 5, 1);
		}
	} else {
		if(GetX + length >= GetClipMaxX) {
			SetMovePosition03(GetX - length, rand(height - ud, height + ud), 5, 1);
		} else {
			SetMovePosition03(GetX + length, rand(height - ud, height + ud), 5, 1);
		}
	}
}
    @MainLoop {

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


if(frame==60){
GenericNonspell;
frame=-100;
}


frame++;
yield;
}    



    @DrawLoop {
		animm;
    }




    @Finalize {
	

    }
}
