#TouhouDanmakufu
#Title[Mima s4]
#Text[A complex spell where only two colors are used to make one spell.Is it a new part of universe?It sure looks nice.]
#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/BG4.png";

let shot1 = csd~"se/shot1.wav";
let shot3 = csd~"se/shot3.wav";
let shot6 = csd~"se/shot6.wav";
let Charge = csd~"se/Charge.wav";
let time01 = csd~"se/timeout0.wav";
let time02 = csd~"se/timeout1.wav";
let angle=90;

#include_function ".\shots\MS_Shot_Name.txt"


@Initialize{
LoadGraphic(Enemy);	//The CutIn function will automatically load and delete the cutin later.
LoadGraphic(SpellBG);
LoadSE(shot1);
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(15,5);	//This spell will take 10% damage from shots, and 5% from bombs (to prevent bombing through a card quickly).
SetTimer(60);

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,"Supernova"\""Universe of Scarlet and Colbalt"\",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;
Move;
}

task Vulnerable{
Wait(1800);
SetDamageRate(25,25);
}

task Move{
loop{
Wait(360);
SetMovePosition02(GetCenterX+rand(-50,50),GetCenterY-rand(80,130),60);}

}


task MainTask{
SetInvincibility(360);
Wait(60);

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

Wait(120);

loop{

YatagaraShot;
PlaySE(shot1);
if(GetLife<=750){

CreateShot02(GetX+15,GetY-15,7,rand(0,360),-0.4,rand(2,1),STAR_S_RED,5);
CreateShot02(GetX+15,GetY-15,7,rand(0,360),-0.4,rand(2,1),STAR_S_BLUE,5);
}

if(GetLife<=500){
CreateShot02(GetX+15,GetY-15,7,rand(0,360),-0.4,rand(2,1),BALL_M_RED,5);
CreateShot02(GetX+15,GetY-15,7,rand(0,360),-0.4,rand(2,1),BALL_M_BLUE,5);
}


if(GetLife<=350){
CreateShot02(GetX+15,GetY-15,7,angle,-0.4,3,RICE_M_RED,5);
CreateShot02(GetX+15,GetY-15,7,-angle+180,-0.4,3,RICE_M_BLUE,5);
angle+=101.7;
}

Wait(3);





	}
}




task YatagaraShot{
yield;
CreateShotA(1,GetX+15,GetY-15,5);
SetShotDataA(1,0,2,rand(0,360),9,0,2,STAR_S_RED);
SetShotDataA(1,1,0,NULL,0,0.02,rand(1,2),RICE_S_RED);
FireShot(1);

CreateShotA(2,GetX+15,GetY-15,5);
SetShotDataA(2,0,2,rand(0,360),-4,0,2,STAR_S_BLUE);
SetShotDataA(2,1,0,NULL,0,0.02,rand(1,2),RICE_S_BLUE);
FireShot(2);	


}




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 bgalpha = 0;
let bgangle = 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 (bgalpha < 255){bgalpha += 5;}
bgangle+=0.5;

SetAlpha(bgalpha);
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);
SetGraphicAngle(0,0,bgangle);
SetTexture(SpellBG);
DrawGraphic(GetCenterX,GetCenterY);

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







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

}