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


script_enemy_main {
	let y = 0;
	let one = 1;
	let frame = 0;
	let shinkicut = GetCurrentScriptDirectory~"shinkicut.png";
	let frame2 = 0;
	let frame3 = 0;
	let background = GetCurrentScriptDirectory~"spellbg.png";
	let angle = 0;
	let angle2 = 0;
	let cardcall = GetCurrentScriptDirectory~"cardcall.wav";
	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 {
	LoadGraphic(shinkicut);
	LoadSE(cardcall);
	PlaySE(cardcall);
	CutIn(YOUMU, "God Art "\""Red Sea of Makai"\", shinkicut, 0, 0, 180, 256);
	DeleteSE("se\seEnemyExplode01.wav");
	DeleteSE("se\seUseSpellCard.wav");
        SetLife(1000);
	SetScore(200000);
        SetTimer(45);
        LoadSE(shot);
	LoadSE(bounce);
	LoadSE(time1);
	LoadSE(time2);
	LoadSE(shot2);
	LoadGraphic(background);
	LoadSE(shot3);
	LoadSE(familiarspawn);
	SetShotAutoDeleteClip(30, 30, 30, 30);
	shotinit;
	SetEnemyMarker(true);
	SetInvincibility(240);
	SetDamageRate(30, 20);
        SetMovePosition02(GetCenterX, GetClipMinY + 120, 120);
        
       
    }

task GenericSpell{
	angle = 0;
	let oldangle = GetAngleToPlayer+2.75;
	one = one*-1;
	let num = 20;
	
	ascent(i in 2..45){
		PlaySE(shot2);
		loop(num-5){
		CreateShot01(GetX, GetY, i/6, oldangle+angle+angle2, RED04, 2);
		angle+=360/(num-5);
		}
		angle2+=6*one;
		wait(1);
		}
	ExMove;
	wait(60);
	ascent(i in 0..16){
	let randnum = rand(10, 20);
	PlaySE(shot3);
	loop(3){
	CreateShot01(GetX, GetY, 2, angle2+angle, RED03, 0);
	CreateShot01(GetX, GetY, 2.5, angle2+angle, RED03, 0);
	angle+=360/3;
	angle2+=21*one;

	}
	wait(10);
	}
}


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

sub ExMove { ExMove_(GetCenterY-100, 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){
GenericSpell;
frame=-250;
}


frame++;
yield;
}    



    @DrawLoop {
		animm;
    }

@BackGround{
   SetTexture(background);
   SetGraphicRect(0, 0 - y, 256, 256 - y);
   SetGraphicScale(2, 2);
   DrawGraphic(GetCenterX, GetCenterY);
   y+=1;
}


    @Finalize {
	

    }
}
