
#Title[EirinS5_H]
#Text[Nanites are a type of nanobot that may eventually be used in the medical field. Eirin looks to a future where medicine has advanced.]
#Player[FREE]
#ScriptVersion[2]
#BGM[.\mu\bgm.mp3]

script_enemy_main {
let c = 0;
let p = 0;
let lastspell = GetCurrentScriptDirectory ~ "sfx\lastspell.wav";
let anglea = 0;
let life = 0;
let halfhealthcheck = false;
	#include_function ".\Eirininclude.txt";

	@Initialize{
	DeleteSE("se\seEnemyExplode01.wav");
	shotinit;
	LoadGraphic(imglifebar); 
	LoadSE(time1);
	LoadSE(capture);
	LoadGraphic(imageFile);
	LoadSE(time2);
	LoadSE(charge);
	SetCommonData("last", true);
	LoadSE(laser2);
	LoadSE(familiarspawn);
	InitializeAction;
	LoadSE(lastspell);
	SetLife(1500);
	LoadSE(shot);
	SetEffectForZeroLife(90, 175, 1);
	DelayedStart;
	LoadSE(shot2);
	SetTimer(99);
	SetEnemyMarker(true);
	SetInvincibility(600);
	SetDamageRate(25, 0);
	SetMovePosition02(GetCenterX, GetClipMinY + 120, 60);
	SetAction(ACT_MOVE, 60);
	SetShotAutoDeleteClip(100, 100, 100, 30);
	LoadGraphic(SP);
	LoadGraphic(MC);
	LoadSE(explode);
	MagicCircle(false);
	LoadGraphic(CBG1);
	LoadGraphic(CBG2);
	LoadGraphic(CBG3);
	LoadGraphic(CBG4);
	LoadGraphic(CBG5);
	LoadGraphic(Cut);
	LoadSE(orb);
	LoadSE(warp);
	LoadSE(caution);
	LoadSE(border);
	SetAction(ACT_MOVE, 60);
	}


task DelayedStart {


wait(120);

Concentration01(120);
PlaySE(charge);
wait(120);
SetScore(5000000);
PlaySE(GetCurrentScriptDirectory~"cardcall.wav");
PlaySE(lastspell);
cutin("Future "\""Medical Nanites"\", Cut, 0, 0, 256, 512);
SetAction(ACT_SPELL, 90);
attack1;
healthcheck;
SetTimer(120);
wait(120);
SetCommonData("spells", GetCommonDataDefault("spells", 0)+1);
}



task healthcheck{
loop{
if(GetEnemyLife<=750 && halfhealthcheck==false){
SetInvincibility(5);
}
wait(1);
}
}
		

task attack1 {
//collision=false;
let one = 1;
let firsttime = true;
let j = 0;
wait(120);
PlaySE(charge);
Concentration01(120);
wait(120);

loop{
if(halfhealthcheck==false && GetEnemyLife<=750){
SetCommonData("die", true);
DeleteEnemyShot(ALL);
wait(10);
SetDamageRate(17.5, 0);
firsttime = true;
SetMovePosition02(GetCenterX, GetClipMinY+120, 120);
SetAction(ACT_MOVE, 120);
wait(120);
PlaySE(charge);
Concentration01(120);
SetAction(ACT_SHOT_B, 120);
wait(120);
p = 2;
halfhealthcheck=true;
SetCommonData("die", false);
}




if(firsttime==false){
Concentration01(60);
wait(60);
}
firsttime=false;
SetAction(ACT_SHOT_A, 90);
wait(15);
loop(6+(p*2)){
PlaySE(familiarspawn);
CreateEnemyFromScript("familiar", GetX, GetY, 0.95, angle, angle);
angle+=360/(6+(p*2));
}
angle = rand(0, 360);
wait(180);
ExMove;
wait(120);
if(firsttime==false){
Concentration01(60);
wait(60);
}
firsttime=false;
SetAction(ACT_SHOT_A, 90);
wait(15);
loop(4){
PlaySE(familiarspawn);
loop(2){
CreateEnemyFromScript("familiar", GetX, GetY, 0.95, angle+anglea, angle);
anglea+=360/2;
}
angle+=360/8;
wait(30);
}
if(p==2){
angle = rand(0, 360);
wait(120);
loop(4){
PlaySE(familiarspawn);
loop(2){
CreateEnemyFromScript("familiar", GetX, GetY, 0.95, angle+anglea, angle);
anglea-=360/2;
}
angle-=360/8;
wait(30);
}
wait(180);
}
angle = rand(0, 360);
wait(45);
if((halfhealthcheck==false) && (GetEnemyLife<=750)==false){
wait(180-45);
ExMove;
wait(120);
}
}
}





@BackGround{
SetTexture(CBG1);
SetGraphicRect(0, anim2/-2, 512, 512+(anim2/-2));
DrawGraphic(GetCenterX, GetCenterY);
SetTexture(CBG2);
SetAlpha(130);
SetGraphicScale(0.5, 1);
SetGraphicRect(0, anim2*3, 512, 512 + anim2*3);
DrawGraphic(GetCenterX-130, GetCenterY);
DrawGraphic(GetCenterX+130, GetCenterY);
SetGraphicScale(1, 1);
SetAlpha(255);
SetTexture(CBG3);
SetGraphicRect( 0, 0, 512, 512 );
DrawGraphic(GetCenterX, GetCenterY);
SetTexture(CBG4);
SetRenderState(ADD);
SetGraphicRect(0, 0, 512, 512);
SetGraphicScale(0.9, 0.9);
SetColor(80, 80, 80);
DrawGraphic(GetCenterX, GetCenterY-70);
SetColor(255, 255, 255);
SetRenderState(ALPHA);
SetGraphicScale(1, 1);



anim2 += 1;
acc1 = 6;


}




}









script_enemy familiar {
	let c = rand_int(0, 120);
	let radiusmax = 100;
	let boom = GetCurrentScriptDirectory~"sfx\se_enep00.wav";
	let angle = GetArgument;
	let angle2 = 0;
	let angle3 = 0;
	let i = 0;
	let f = 0;
	let bloo = 0;
	let h = 0;
	let time = 0;
	let radius = 360;
	let radius2 = GetArgument;
	let charge = GetCurrentScriptDirectory~"sfx\Charge.wav";
	let laser = GetCurrentScriptDirectory~"sfx\laser.wav";
	let shot2 = GetCurrentScriptDirectory~"sfx\shot2.wav";
	let shot3 = GetCurrentScriptDirectory~"sfx\shot3.wav";
	let shot4 = GetCurrentScriptDirectory~"sfx\shot4.wav";
	let shot = GetCurrentScriptDirectory~"sfx\shot.wav";
	let familiar = GetCurrentScriptDirectory~"sprites\familiar.png";
	let Custom = GetCurrentScriptDirectory~"sup\supershot.txt";
	#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
	let frame = 0;
	let frame2 = 0;
	@Initialize{
	attack1;
	
	LoadGraphic(familiar);
	LoadSE(boom);
	SetLife(325);
	LoadSE(shot);
	LoadSE(shot2);
	LoadSE(laser);
	LoadSE(shot3);
	LoadSE(charge);
	LoadSE(shot4);
	shotinit;
	SetDamageRateEx(200, 50, 50, 1);
}

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


task attack1{
wait(30);
loop{
PlaySE(shot4);
loop(2+bloo){
	CreateShot02(GetX, GetY, 3, angle, -0.1, 2-f, [RED01, ORANGE01, YELLOW01, GREEN01, AQUA01, BLUE01, PURPLE01][h%7], 10);
	angle+=360/(2+bloo);
	}
f+=0.075;
i+=0.5;
bloo = rand_int(0, 1);
h = floor(i);
if(f>=1.75){
f = 1.75;
}
angle+=31.6;
wait(15);
}
}




	@MainLoop{
time++;
SetCollisionA(GetX, GetY, 10);
	if(GetX>GetClipMaxX+100 || GetY>GetClipMaxY+30 || GetX<GetClipMinX-100 || GetY<GetClipMinY-100){
	VanishEnemy;
	}
	if(GetCommonDataDefault("die", false)==true){
	VanishEnemy;
	}

	yield;
	
	
	 
}
	@DrawLoop{
	frame++;
	SetTexture(familiar);
	SetGraphicRect(64, 0, 128, 64);
	SetGraphicScale(0.5, 0.5);
	SetAlpha(255);
	SetGraphicAngle(0, 0, frame*4);
	DrawGraphic(GetX, GetY);
	
}

	
	
	@Finalize{
	if(BeVanished==false){
	PlaySE(boom);
	DeleteEnemyShotToItemInCircle(SHOT, GetX, GetY, 40);
	}
	if(GetCommonDataDefault("die", false)==true && BeVanished==true){
	PlaySE(boom);
	}
		


	}

}



	