
#Title[EirinS4_H]
#Text[The title of this card honestly has nothing to do with the content.]
#Player[FREE]
#ScriptVersion[2]
#BGM[.\mu\bgm.mp3]

script_enemy_main {
let c = 0;
let life = 0;
	#include_function ".\Eirininclude.txt";

	@Initialize{
	DeleteSE("se\seEnemyExplode01.wav");
	shotinit;
	LoadGraphic(imglifebar); 
	LoadSE(time1);
	LoadGraphic(imageFile);
	LoadSE(time2);
	LoadSE(charge);
	LoadSE(capture);
	LoadSE(laser2);
	LoadSE(familiarspawn);
	InitializeAction;
	SetLife(1500);
	LoadSE(shot);
	DelayedStart;
	LoadSE(shot2);
	SetTimer(99);
	SetEnemyMarker(true);
	SetInvincibility(600);
	SetDamageRate(70, 25);
	SetMovePosition02(GetCenterX, GetClipMinY + 120, 60);
	SetAction(ACT_MOVE, 60);
	SetShotAutoDeleteClip(50, 100, 50, 50);
	LoadGraphic(SP);
	LoadGraphic(MC);
	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(60);
SetCommonData("spells", GetCommonDataDefault("spells", 0)+1);
SetScore(5000000);
PlaySE(GetCurrentScriptDirectory~"cardcall.wav");
cutin("Mind of God "\""Amaterasu's Mirror"\", Cut, 0, 0, 256, 512);
SetAction(ACT_SPELL, 90);
attack1;
SetTimer(73);
wait(120);
SetCommonData("spells", GetCommonDataDefault("spells", 0)+1);
}




		

task attack1 {
//collision=false;
let one = 1;
let firsttime = true;
let j = 0;
wait(150);
Concentration01(120);
PlaySE(charge);
SetAction(ACT_SHOT_B, 120);
wait(120);
PlaySE(familiarspawn);
CreateEnemyFromScript("familiar", GetX, GetCenterY, 0, 0, angle);
angle+=360/12;
wait(180);
PlaySE(charge);
Concentration01(120);
SetAction(ACT_SHOT_A, 120);
wait(120);

loop{
angle = 0;

SetMovePosition02(GetClipMinX+rand(60, 30), GetClipMinY+rand(120, 80), 120);
SetAction(ACT_MOVE, 120);
PlaySE(shot3);
loop(36){
CreateShot01(GetX, GetY, 0.5, GetAngleToPlayer+angle, AQUA54, 10);
CreateShot01(GetX, GetY, 0.6, GetAngleToPlayer+angle+5, AQUA54, 10);
CreateShot01(GetX, GetY, 0.4, GetAngleToPlayer+angle+5, AQUA54, 10);
angle+=360/36;
}

ascent(i in 0..22){
PlaySE(shot3);

	loop(18){
		CreateShot01(GetX, GetY, 0.5+(i/4), GetAngleToPlayer+angle, AQUA54, 10);
		angle+=360/18;
		}
wait(5);
}

wait(120);

SetMovePosition02(GetCenterX+rand(-10, 10), GetClipMinY+rand(120, 80), 120);
SetAction(ACT_MOVE, 120);
PlaySE(shot3);
loop(36){
CreateShot01(GetX, GetY, 0.4, GetAngleToPlayer+angle+5, AQUA54, 10);
CreateShot01(GetX, GetY, 0.5, GetAngleToPlayer+angle, AQUA54, 10);
CreateShot01(GetX, GetY, 0.6, GetAngleToPlayer+angle+5, AQUA54, 10);
angle+=360/36;
}

ascent(i in 0..22){
PlaySE(shot3);

	loop(18){
		CreateShot01(GetX, GetY, 0.5+(i/4), GetAngleToPlayer+angle, AQUA54, 10);
		angle+=360/18;
		}
wait(5);
}

wait(120);

SetMovePosition02(GetClipMaxX-rand(60, 30), GetClipMinY+rand(120, 80), 120);
SetAction(ACT_MOVE, 120);
PlaySE(shot3);
loop(36){
CreateShot01(GetX, GetY, 0.4, GetAngleToPlayer+angle+5, AQUA54, 10);
CreateShot01(GetX, GetY, 0.5, GetAngleToPlayer+angle, AQUA54, 10);
CreateShot01(GetX, GetY, 0.6, GetAngleToPlayer+angle+5, AQUA54, 10);
angle+=360/36;
}

ascent(i in 0..22){
PlaySE(shot3);

	loop(18){
		CreateShot01(GetX, GetY, 0.5+(i/4), GetAngleToPlayer+angle, AQUA54, 10);
		angle+=360/18;
		}
wait(5);
}

wait(120); 

SetMovePosition02(GetCenterX+rand(-10, 10), GetClipMinY+rand(120, 80), 120);
SetAction(ACT_MOVE, 120);
PlaySE(shot3);

loop(36){
CreateShot01(GetX, GetY, 0.4, GetAngleToPlayer+angle+5, AQUA54, 10);
CreateShot01(GetX, GetY, 0.5, GetAngleToPlayer+angle, AQUA54, 10);
CreateShot01(GetX, GetY, 0.6, GetAngleToPlayer+angle+5, AQUA54, 10);
angle+=360/36;
}

ascent(i in 0..22){
PlaySE(shot3);

	loop(18){
		CreateShot01(GetX, GetY, 0.5+(i/4), GetAngleToPlayer+angle, AQUA54, 10);
		angle+=360/18;
		}
wait(5);
}

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\boom.wav";
	let angle = 0+GetArgument;
	let angle2 = 0;
	let angle3 = 0;
	let i = 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;
	attack2;
	LoadGraphic(familiar);
	LoadSE(boom);
	SetLife(500);
	LoadSE(shot);
	LoadSE(shot2);
	LoadSE(laser);
	LoadSE(shot3);
	LoadSE(charge);
	LoadSE(shot4);
	shotinit;
	SetDamageRateEx(0, 0, 0, 0);
}

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


task attack1{

SetMovePosition02(GetClipMaxX-20, GetY, 120);
wait(180);
Concentration01(30);
loop{
PlaySE(laser);
//CreateLaserA(1, GetX, GetY, 600, 15, ORANGE60, 60);
//SetLaserDataA(1, 0, GetAngle+90+rand(-2, 2), 0, 10, 0, 0);
//SetShotKillTime(1, 240);
//FireShot(1); 

CreateLaser(GetAngle+90+rand(-2, 2), ORANGE60, 60);


wait(20);
}
}



task CreateLaser(angle, graphic, delay){
let obj = Obj_Create(OBJ_LASER);
		let width = 20;
		let count = 0;
		let length = 700;
		Obj_SetPosition(obj,GetX,GetY);
		ObjLaser_SetLength(obj,0);
		ObjLaser_SetWidth(obj,width);
		Obj_SetAngle(obj,angle);
		ObjShot_SetGraphic(obj,graphic);
		ObjShot_SetDelay(obj,delay);
		ObjLaser_SetSource(obj, true);
		while(!Obj_BeDeleted(obj)) {
		ObjLaser_SetLength(obj,length);
		if(count>=230){
		width-=0.75;
		}
		if(width<=7.5){
		Obj_SetCollisionToPlayer(obj, false);
		}
		
		if(count>=251){
		Obj_Delete(obj);
		}
		ObjLaser_SetWidth(obj,width);
		count++;
		yield;
		}
	}


task attack2{
wait(160);
SetSpeed(3.5);
SetAngle(90);
loop{
if(GetY>=GetClipMaxY-10 && GetAngle==90){
SetAngle(180);
}
if(GetX<=GetClipMinX+10 && GetAngle==180){
SetAngle(270);
}
if(GetY<=GetClipMinY+10 && GetAngle==270){
SetAngle(360);
}
if(GetX>=GetClipMaxX-10 && GetAngle==360){
SetAngle(90);
}
wait(1);
}
}
	@MainLoop{
time++;
//SetCollisionA(GetX, GetY, 10);
	//SetMovePosition02(GetEnemyX+radius*cos(angle), GetEnemyY+radius*sin(angle), 10);


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

	
	
	@Finalize{
	PlaySE(boom);
	}

}



	