#TouhouDanmakufu
#Title[Mima s2]
#Text[An astronomy lesson about the Orion Constellation.Is it me,or there are flickering blue lights?]
#BackGround[User(.\img\BG.png,0,0)]
#PlayLevel[Normal]
#Player[FREE]
#BGM[.\bgm.mp3]
#ScriptVersion[2]



script_enemy_main{
let csd = GetCurrentScriptDirectory;

let Enemy = csd~"img/sprites/mima.png";
let EnemyCutin = csd~"img/cut/Mima.png";
let SpellBG = csd~"img/sprites/BG3.png";

let shot5 = csd~"se/shot5.wav";
let Charge = csd~"se/Charge.wav";
let time01 = csd~"se/timeout0.wav";
let time02 = csd~"se/timeout1.wav";
let angle=0;

#include_function ".\shots\MS_Shot_Name.txt"


@Initialize
{
LoadGraphic(Enemy);	//The CutIn function will automatically load and delete the cutin later.
LoadGraphic(SpellBG);

LoadSE(shot5);
LoadSE(time01);
LoadSE(time02);

SetLife(1000);		//Spell cards tend to have low health, but high resistance to damage until a certain amount of time passes.
SetDamageRate(10,5);	//This spell will take 10% damage from shots, and 5% from bombs (to prevent bombing through a card quickly).
SetTimer(45);

SetScore(100000);	//Sets the spell card bonus.

//The boss's cutin. KOUMA can be used as an alternate style. Next is the spell name (slashes are to prevent premature string ending), the last 4 are the same as SetGraphicRect.
CutIn(YOUMU,"Beta Orionis"\""Rigel"\",EnemyCutin,0,0,256,512);

//Creates a special effect when the boss dies. The second paramter determines motion blur (0-255) and the third is slowdown (1 being half speed, 2 being third, etc).
SetEffectForZeroLife(60,0,0);
	
SetMovePosition02(GetCenterX,GetCenterY-120,60);

LoadUserShotData(GetCurrentScriptDirectory~".\shots\newshots9c.txt");

MainTask;
Vulnerable;
Timer;
}

task Vulnerable
{
Wait(1200);
SetDamageRate(50,50);	//Becomes more vulnerable after 20 seconds.
}


task MainTask{
Wait(60);
SetColor(64,64,255);	
Concentration01(120);	//Charges for 2 seconds.
SetColor(255,255,255);	//Sets color back to normal.
PlaySE(Charge);

Wait(120);

loop{

loop(10){
LuminousStrikeShot(angle);
PlaySE(shot5);
Wait(10);
angle+=37.7;
}
Wait(180);

loop(10){
LuminousStrikeShot(-angle+180);
PlaySE(shot5);
Wait(10);
angle+=37.7;
}


Wait(180);

LuminousStrikeShot(GetAngleToPlayer);
LuminousStrikeShot(GetAngleToPlayer+5);
LuminousStrikeShot(GetAngleToPlayer-5);

LuminousStrikeShot(GetAngleToPlayer+115);
LuminousStrikeShot(GetAngleToPlayer+120);
LuminousStrikeShot(GetAngleToPlayer+125);

LuminousStrikeShot(GetAngleToPlayer+235);
LuminousStrikeShot(GetAngleToPlayer+240);
LuminousStrikeShot(GetAngleToPlayer+245);

PlaySE(shot5);

Wait(240);



	}
}




task LuminousStrikeShot(angle){
yield;
 
let obj= Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj,GetX+15,GetY-15);
Obj_SetAngle(obj,angle);
Obj_SetSpeed(obj,5);
ObjShot_SetGraphic(obj,BALL_L_BLUE);
ObjShot_SetDelay(obj,0);
 
		

while(!Obj_BeDeleted(obj)){
yield;
let num=7;
loop(num){CreateShot02(Obj_GetX(obj),Obj_GetY(obj),5,angle,-0.4,1.5,STAR_S_BLUE,20);
CreateShot02(Obj_GetX(obj),Obj_GetY(obj),5,angle+180,-0.4,1,STAR_S_BLUE,20);
angle+=360/num;}
angle+=9.9;
	
		Wait(30);

if(Obj_GetX(obj)>GetClipMaxX||Obj_GetX(obj)<GetClipMinX||Obj_GetY(obj)>GetClipMaxY ||Obj_GetY(obj)<GetClipMinY){Obj_Delete(obj); yield;}
                        
                }
 
 
}




task Timer{
loop{
	if (GetTimer > 5 && GetTimer <= 11){PlaySE(time01);}
	if (GetTimer >= 1 && GetTimer <= 5){PlaySE(time02);}
	Wait(60);
	}
}

function Wait(t){loop(t){yield;}}



@MainLoop
{
SetCollisionA(GetX,GetY,48);
SetCollisionB(GetX,GetY,32);
yield;
}



@DrawLoop
{
SetAlpha(255);
SetGraphicScale(1,1);
SetColor(255,255,255);
SetGraphicAngle(0,0,0);
SetTexture(Enemy);
SetGraphicRect(44,34,87,95);

DrawGraphic(GetX,GetY);
}

let bgalpha1 = 0;

@BackGround	//This section is for drawing the background, and normally only works if the script is a spell card. Draws under everything else.
{

if (bgalpha1 < 255){bgalpha1 += 5;}


SetAlpha(bgalpha1);
SetGraphicScale(2.2,2.2);	//The background is scaled up so it can fill the whole screen.
SetColor(255,255,255);
SetGraphicRect(0,0,256,256);
SetTexture(SpellBG);
DrawGraphic(GetCenterX,GetCenterY);

//Remember to set everything back to default before drawing something else (spinning Reimu?!).
}







@Finalize
{
DeleteGraphic(Enemy);
DeleteGraphic(SpellBG);
}

}