#TouhouDanmakufu
#Title[SatoriNonSpell H]
#Text[Nonspell]
#BackGround[User(.\img\stage.png,0,-0.5)]
#PlayLevel[Extra]
#Player[FREE]
#BGM[.\yamabiko.mp3]
#ScriptVersion[2]

script_enemy_main
{
#include_function ".\Library.dnh"

let imgBeam=GetCurrentScriptDirectory~"\img\houtou.png";
let imgFire=GetCurrentScriptDirectory~"\img\Fire.png";
let SatoriSprite = csd~"img/Satori/SatoriSprite.png";
let SatoriCutin = csd~"img/Satori/SatoriCutin.png";
let SpellBG01 = csd~"img/Satori/SpellBG01.png";
let SpellBG02 = csd~"img/Satori/SpellBG02.png";
let shot1=csd~"se/shot1.wav";
let shot2=csd~"se/shot2.wav";
let shot3=csd~"se/shot3.wav";
let shot4=csd~"se/shot4.wav";
let spell=csd~"se/spellcard.wav";
let laser=csd~"se/lazer.wav";
let charge=csd~"se/charge2.wav";
let lazer=csd~"se/lazer.mp3";
let beamready=csd~"se/beamready.mp3";
let widthglo=[1,1];
let gloang=[0,180];
let glox=[0,0];
let gloy=[0,0];
let switch=0;

@Initialize
	{
	LoadUserShotData(csd~"Shot.txt");
	LoadGraphic(SatoriSprite);
	LoadGraphic(SpellBG01);
	LoadGraphic(SpellBG02);
	LoadGraphic(imgBeam);
	LoadGraphic(imgFire);
	LoadSE(shot1);
	LoadSE(shot2);
	LoadSE(shot3);
	LoadSE(shot4);
	LoadSE(spell);
	LoadSE(laser);
	LoadSE(charge);
	LoadSE(lazer);
	LoadSE(beamready);
	SetLife(800);
	SetScore(100);
	SetEnemyMarker(true);
	SetDamageRate(5,0);
	SetTimer(71);
	CutIn(YOUMU,"Shou's Gift -- Mantra Collecting Vajra",SatoriCutin,0,0,256,512);
	//let a=0;
	//SetEffectForZeroLife(60,0,0);	
	

Vulnerable;
Timer;
IdleSatori;
//MoveAbout;
SetMovePosition03(GetCenterX, GetCenterY - 0, 30,10);
}

task Vulnerable
{
Wait(600);
SetDamageRate(10,0);
Wait(600);
SetDamageRate(20,0);
Wait(600);
SetDamageRate(30,0);
Wait(600);
SetDamageRate(40,0);
}

function Houtou(x, y, angle, color, delay, delTime,rotation,id,off) {
	let Obj    = Obj_Create(OBJ_EFFECT);
	Houtou_Beam(Obj, x, y, angle, color, delay, delTime,rotation,id,off);
	return Obj;
}


task Houtou_Beam(Obj, x, y, angle, Color, delay, delTime,rotation,id,off) {
	let Laser  = Obj_Create(OBJ_LASER);
	let Detail = Obj_Create(OBJ_EFFECT);
	let Fire   = Obj_Create(OBJ_EFFECT);

	let Length  = 0;
	let width   = 1;
	let grazeC  = 0;
	let color   = Color;
	let clrPlus = 0.25;
	let count   = 0;

	let Fire_count = 0;
	let Fire_scale = 0.5;
	let Fire_sclct = 0;

	if(Color == 8) {
		color = 0;
	}

	let u = 0;
	let uPlus = -15;

	Obj_SetPosition(Obj, x, y);
	ObjEffect_SetTexture(Obj, imgBeam);
	ObjEffect_SetRenderState(Obj, ADD);
	ObjEffect_SetPrimitiveType(Obj, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_SetScale(Obj, 1, width/40);
	ObjEffect_SetLayer(Obj, 5);

	Obj_SetPosition(Detail, x, y);
	ObjEffect_SetTexture(Detail, imgBeam);
	ObjEffect_SetRenderState(Detail, ALPHA);
	ObjEffect_SetPrimitiveType(Detail, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_SetScale(Detail, 1, width/40);
	ObjEffect_SetLayer(Detail, 5);

	Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
	ObjEffect_SetTexture(Fire, imgFire);
	ObjEffect_SetRenderState(Fire, ADD);
	ObjEffect_SetPrimitiveType(Fire, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_SetScale(Fire, Fire_scale, Fire_scale);
	ObjEffect_SetLayer(Fire, 5);

	Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
	Obj_SetAngle(Laser, Obj_GetAngle(Obj));
	Obj_SetAlpha(Laser, 0);
	Obj_SetAutoDelete(Laser, false);
	ObjShot_SetGraphic(Laser, RED01);
	ObjShot_SetDelay(Laser, 0);
	ObjShot_SetBombResist(Laser, true);
	ObjShot_ToItem(Laser, false);
	ObjLaser_SetLength(Laser, 768);
	ObjLaser_SetWidth(Laser, width*(3/4));
	ObjLaser_SetSource(Laser, false);

	Obj_SetAngle(Obj, angle);
	ObjEffect_CreateVertex(Obj, 4);
	ObjEffect_SetVertexXY(Obj, 0,   0, -20);
	ObjEffect_SetVertexXY(Obj, 1,   0,  20);
	ObjEffect_SetVertexXY(Obj, 2, 768, -20);
	ObjEffect_SetVertexXY(Obj, 3, 768,  20);
	ObjEffect_SetVertexUV(Obj, 0, 128+(trunc(color)*16)   , 368);
	ObjEffect_SetVertexUV(Obj, 1, 128+(trunc(color)*16)+16, 368);
	ObjEffect_SetVertexUV(Obj, 2, 128+(trunc(color)*16)   , 384);
	ObjEffect_SetVertexUV(Obj, 3, 128+(trunc(color)*16)+16, 384);
	ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));

	ObjEffect_CreateVertex(Detail, 4);
	ObjEffect_SetVertexXY(Detail, 0,   0, -15);
	ObjEffect_SetVertexXY(Detail, 1,   0,  15);
	ObjEffect_SetVertexXY(Detail, 2, 768, -15);
	ObjEffect_SetVertexXY(Detail, 3, 768,  15);
	ObjEffect_SetVertexUV(Detail, 0,   0, 330);
	ObjEffect_SetVertexUV(Detail, 1,   0, 360);
	ObjEffect_SetVertexUV(Detail, 2, 768, 330);
	ObjEffect_SetVertexUV(Detail, 3, 768, 360);
	ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));
	ObjEffect_CreateVertex(Fire, 4);
	ObjEffect_SetVertexXY(Fire, 0,  -1, -64);
	ObjEffect_SetVertexXY(Fire, 1,  -1,  64);
	ObjEffect_SetVertexXY(Fire, 2, 127, -64);
	ObjEffect_SetVertexXY(Fire, 3, 127,  64);
	ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));

	Obj_SetCollisionToPlayer(Laser,false);

	PlaySE(beamready);

	loop(delay) {
		if(Obj_BeDeleted(Obj) == true) { break; }

		ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));
		
		Obj_SetPosition(Detail, Obj_GetX(Obj), Obj_GetY(Obj));
		ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));

		if(trunc(Fire_count)%2 == 0) {
			ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256    ,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256    , ((trunc(color)%4)*128)+128);
			ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
		} else if(trunc(Fire_count)%2 == 1) {
			ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
			ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+256,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+256, ((trunc(color)%4)*128)+128);
		}

		Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
		ObjEffect_SetScale(Fire, Fire_scale+1.5*(1-Fire_sclct), Fire_scale*Fire_sclct);
		ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));

		Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
		Obj_SetAngle(Laser, Obj_GetAngle(Obj));
		ObjLaser_SetWidth(Laser, width*(5/4));

		Fire_count += 0.5;
		if(Fire_sclct < 1) { Fire_sclct += 0.2; }
		if(Color == 8) { color += clrPlus; }
		if(Color == 8 && color >= 7)  { color = 0; }
		yield;
	};

	ObjEffect_SetScale(Obj, (Length/768), 1);
	ObjEffect_SetVertexUV(Obj, 0,   0, (trunc(color)*40)+5);
	ObjEffect_SetVertexUV(Obj, 1,   0, (trunc(color)*40)+45);
	ObjEffect_SetVertexUV(Obj, 2, 256, (trunc(color)*40)+5);
	ObjEffect_SetVertexUV(Obj, 3, 256, (trunc(color)*40)+45);
	ObjEffect_SetScale(Fire, Fire_scale, Fire_scale);

	Obj_SetCollisionToPlayer(Laser,true);

	//PlaySE(lazer);
	
	loop(30) {
		if(Obj_BeDeleted(Obj) == true) { break; }
			Length += 20;
		//if(width < 40) { width  += (39/15); } else { width = 40; }
		u += uPlus;

		ObjEffect_SetScale(Obj, (Length/768), width/40);
		ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));
		ObjEffect_SetVertexUV(Obj, 0,   0, (trunc(color)*40)+5);
		ObjEffect_SetVertexUV(Obj, 1,   0, (trunc(color)*40)+45);
		ObjEffect_SetVertexUV(Obj, 2, 256, (trunc(color)*40)+5);
		ObjEffect_SetVertexUV(Obj, 3, 256, (trunc(color)*40)+45);

		Obj_SetPosition(Detail, Obj_GetX(Obj), Obj_GetY(Obj));
		ObjEffect_SetScale(Detail, 1, width/40);
		ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));
		ObjEffect_SetVertexUV(Detail, 0,   0+u, 330);
		ObjEffect_SetVertexUV(Detail, 1,   0+u, 360);
		ObjEffect_SetVertexUV(Detail, 2, 768+u, 330);
		ObjEffect_SetVertexUV(Detail, 3, 768+u, 360);

		if(trunc(Fire_count)%2 == 0) {
			ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256    ,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256    , ((trunc(color)%4)*128)+128);
			ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
		} else if(trunc(Fire_count)%2 == 1) {
			ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
			ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+256,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+256, ((trunc(color)%4)*128)+128);
		}

		Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
		ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));

		Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
		Obj_SetAngle(Laser, Obj_GetAngle(Obj));
		ObjLaser_SetWidth(Laser, width*(5/4));

		Fire_count += 0.5;
		if(Color == 8) { color += clrPlus; }
		if(Color == 8 && color >= 7)  { color = 0; }
		yield;
	}

	Length = 768;
	ObjEffect_SetScale(Obj, (Length/768), 0);

	while(!Obj_BeDeleted(Obj)) {
		if(count >= delTime && delTime >= 0) { break; }
		u += uPlus;

		ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));
		Obj_SetAngle(Obj, gloang[id]+off);
		Obj_SetX(Obj,glox[id]);
		Obj_SetY(Obj,gloy[id]);
		ObjEffect_SetScale(Obj, (Length/768), widthglo[id]/40);
		ObjEffect_SetScale(Detail, 1, widthglo[id]/40);
		ObjEffect_SetScale(Fire, 1,0.6 );
		ObjEffect_SetVertexUV(Obj, 0,   0, (trunc(color)*40)+5);
		ObjEffect_SetVertexUV(Obj, 1,   0, (trunc(color)*40)+45);
		ObjEffect_SetVertexUV(Obj, 2, 256, (trunc(color)*40)+5);
		ObjEffect_SetVertexUV(Obj, 3, 256, (trunc(color)*40)+45);

		Obj_SetPosition(Detail, Obj_GetX(Obj), Obj_GetY(Obj));
		ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));
		ObjEffect_SetVertexUV(Detail, 0,   0+u, 330);
		ObjEffect_SetVertexUV(Detail, 1,   0+u, 360);
		ObjEffect_SetVertexUV(Detail, 2, 768+u, 330);
		ObjEffect_SetVertexUV(Detail, 3, 768+u, 360);

		if(trunc(Fire_count)%2 == 0) {
			ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256    ,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256    , ((trunc(color)%4)*128)+128);
			ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
		} else if(trunc(Fire_count)%2 == 1) {
			ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
			ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+256,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+256, ((trunc(color)%4)*128)+128);
		}

		Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
		ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));

		Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
		Obj_SetAngle(Laser, Obj_GetAngle(Obj));
		ObjLaser_SetWidth(Laser, widthglo[id]);

		Fire_count += 0.5;
		if(Color == 8) { color += clrPlus; }
		if(Color == 8 && color >= 7)  { color = 0; }
		if(delTime >= 0) { count++; }
		yield;
	}

	Obj_SetCollisionToPlayer(Laser,false);

	loop(30) {
		if(Obj_BeDeleted(Obj) == true) { break; }

		width -= (4/3);
		u += uPlus;

		ObjEffect_SetScale(Obj, 1, width/40);
		ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));
		ObjEffect_SetVertexUV(Obj, 0,   0, (trunc(color)*40)+5);
		ObjEffect_SetVertexUV(Obj, 1,   0, (trunc(color)*40)+45);
		ObjEffect_SetVertexUV(Obj, 2, 256, (trunc(color)*40)+5);
		ObjEffect_SetVertexUV(Obj, 3, 256, (trunc(color)*40)+45);

		Obj_SetPosition(Detail, Obj_GetX(Obj), Obj_GetY(Obj));
		ObjEffect_SetScale(Detail, 1, width/40);
		ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));
		ObjEffect_SetVertexUV(Detail, 0,   0+u, 330);
		ObjEffect_SetVertexUV(Detail, 1,   0+u, 360);
		ObjEffect_SetVertexUV(Detail, 2, 768+u, 330);
		ObjEffect_SetVertexUV(Detail, 3, 768+u, 360);

		Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
		ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));
		ObjEffect_SetScale(Fire, Fire_scale, Fire_scale*(width/40));

		if(trunc(Fire_count)%2 == 0) {
			ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256    ,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256    , ((trunc(color)%4)*128)+128);
			ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
		} else if(trunc(Fire_count)%2 == 1) {
			ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
			ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+256,  (trunc(color)%4)*128);
			ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+256, ((trunc(color)%4)*128)+128);
		}

		Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
		Obj_SetAngle(Laser, Obj_GetAngle(Obj));
		ObjLaser_SetWidth(Laser, width*(5/4));

		if(Color == 8) { color += clrPlus; }
		if(Color == 8 && color >= 7)  { color = 0; }
		yield;
	}

	Obj_Delete(Obj);
	Obj_Delete(Fire);
	Obj_Delete(Detail);
	Obj_Delete(Laser);
}



task Vajra(t1,t2,angle,charge,id){
let flag=0;
let a=0;
let obj=Obj_Create(OBJ_LASER);
ObjLaser_SetLength(obj,600);
ObjLaser_SetWidth(obj,5);
Obj_SetX(obj,GetX);
	Obj_SetY(obj,GetY);
	Obj_SetSpeed(obj,0);
	ObjShot_SetGraphic(obj,t1);
	ObjShot_SetDelay(obj,60);
	Obj_SetAngle(obj,angle);

loop(60){yield;widthglo[id]=ObjLaser_GetWidth(obj);
	gloang[id]=Obj_GetAngle(obj);
	glox[id]=Obj_GetX(obj);
	gloy[id]=Obj_GetY(obj);}
loop{
let x=rand(100,350);
let y=rand(120,360);
let X=Obj_GetX(obj);
let Y=Obj_GetY(obj);
let t=0;
loop(120){
	t=t+1/120;
	Obj_SetAngle(obj,Obj_GetAngle(obj)+1/2);
	Obj_SetX(obj,t*x+(1-t)*X);
	Obj_SetY(obj,t*y+(1-t)*Y);
	widthglo[id]=ObjLaser_GetWidth(obj);
	gloang[id]=Obj_GetAngle(obj);
	glox[id]=Obj_GetX(obj);
	gloy[id]=Obj_GetY(obj);
	yield;
	}
loop(120){Obj_SetAngle(obj,Obj_GetAngle(obj)+1/2);
widthglo[id]=ObjLaser_GetWidth(obj);
	gloang[id]=Obj_GetAngle(obj);
	glox[id]=Obj_GetX(obj);
	gloy[id]=Obj_GetY(obj);
if(a%2==0){Amp(obj,224,240,1.5,360*sin(2*a)+angle,t2);}
a++;
yield;}
if(ObjLaser_GetWidth(obj)>40){
	Obj_SetAngle(charge,Obj_GetAngle(charge)+1);
	loop{yield;
	Obj_SetAngle(obj,Obj_GetAngle(obj)+1/2);
	widthglo[id]=ObjLaser_GetWidth(obj);
	gloang[id]=Obj_GetAngle(obj);
	glox[id]=Obj_GetX(obj);
	gloy[id]=Obj_GetY(obj);
	if(Obj_GetAngle(charge)>=2){break;}
	}
	
	loop(60){yield;
	widthglo[id]=ObjLaser_GetWidth(obj);
	gloang[id]=Obj_GetAngle(obj);
	glox[id]=Obj_GetX(obj);
	gloy[id]=Obj_GetY(obj);
	x=GetX+100*cos(angle);
	y=GetY+100*sin(angle);
	X=Obj_GetX(obj);
	Y=Obj_GetY(obj);
	Obj_SetX(obj,0.02*x+0.98*X);
	Obj_SetY(obj,0.02*y+0.98*Y);}
	
	loop{yield;
	widthglo[id]=ObjLaser_GetWidth(obj);
	gloang[id]=Obj_GetAngle(obj);
	glox[id]=Obj_GetX(obj);
	gloy[id]=Obj_GetY(obj);
	x=GetX+100*cos(angle);
	y=GetY+100*sin(angle);
	X=Obj_GetX(obj);
	Y=Obj_GetY(obj);
	Obj_SetX(obj,0.02*x+0.98*X);
	Obj_SetY(obj,0.02*y+0.98*Y);
	if(Obj_GetAngle(charge)>=2){break;}
	}
	ascent(i in 0..100){Obj_SetX(obj,0.02*GetX+0.98*Obj_GetX(obj));
	Obj_SetY(obj,0.02*GetY+0.98*Obj_GetY(obj));
	widthglo[id]=ObjLaser_GetWidth(obj);
	gloang[id]=Obj_GetAngle(obj);
	glox[id]=Obj_GetX(obj);
	gloy[id]=Obj_GetY(obj);
	yield;}
	yield;
	PlaySE(lazer);
	ascent(i in -2..3){
		ascent(j in -101..101){
			CreateShot02(Obj_GetX(obj)+20*j*cos(Obj_GetAngle(obj)),Obj_GetY(obj)+20*j*sin(Obj_GetAngle(obj)),0,Obj_GetAngle(obj)+90+27*j+360/5*i,0.015,0.5+absolute(i)/3,t2,30);
						}	
						}
ObjLaser_SetWidth(obj,5);
loop(420){yield;
widthglo[id]=ObjLaser_GetWidth(obj);
	gloang[id]=Obj_GetAngle(obj);
	glox[id]=Obj_GetX(obj);
	gloy[id]=Obj_GetY(obj);}
	PlaySE(beamready);
Obj_SetAngle(charge,0);						
}
}	
loop{yield;}
}

task Amp(vaj,x,y,s,a,t){
let obj=Obj_Create(OBJ_SHOT);

	Obj_SetX(obj,x);
	Obj_SetY(obj,y);
	Obj_SetSpeed(obj,s);
	ObjShot_SetGraphic(obj,t);
	ObjShot_SetDelay(obj,0);
	Obj_SetAngle(obj,a);
	let u=0;
	while(!Obj_BeDeleted(obj)){
		yield;
		u++;
		let A=Obj_GetAngle(vaj);
		let X=Obj_GetX(vaj);
		let Y=Obj_GetY(vaj);
		if(absolute((Obj_GetX(obj)-X)*sin(A)-(Obj_GetY(obj)-Y)*cos(A))<2*s ){ObjLaser_SetWidth(vaj,ObjLaser_GetWidth(vaj)+0.3);
		Obj_Delete(obj);}
}
	
	
}

task MainTask
{PlaySE(spell);
Wait(120);
let p1=0;
let p2=0;
let p3=0;
let p4=0;
let a=0;
let t=0;
let cj=1;
let d=200;
let w=0;
let v=180;
let r=0;
let R=200;
Houtou(GetX,GetY,45,3,0,-1,0.5,0,0);
Houtou(GetX,GetY,-45,2,0,-1,0.5,1,0);
Houtou(GetX,GetY,235,3,0,-1,0.5,0,180);
Houtou(GetX,GetY,305,2,0,-1,0.5,1,180);
let charge=Obj_Create(OBJ_LASER);
Obj_SetAngle(charge,0);
Vajra(241,241,45,charge,0);
Vajra(243,243,-45,charge,1);

loop{r=(r+50)%360;
	loop(60){yield};
	
	}
}

task MoveAbout
{
SetMovePosition02(GetCenterX,GetCenterY-120,60);
MoveSatori;
loop
	{
	Wait(250);
	SetMovePositionRandom01(64,64,1,GetClipMinX+64,GetClipMinY+64,GetClipMaxX-64,GetClipMinY+128);
	MoveSatori;
	Wait(150);
	}
}

@MainLoop
	{
	if(switch==0){switch=1;MainTask;}
	SetCollisionA(GetX,GetY,32);
	SetCollisionB(GetX,GetY,32);
	yield;
	}



@DrawLoop
	{
	SetAlpha(255);
	if (bossflip==0){SetGraphicScale(1,1);}
	if (bossflip==1){SetGraphicScale(-1,1);}
	SetColor(255,255,255);
	SetGraphicAngle(0,0,0);
	SetTexture(SatoriSprite);
	SetGraphicRect(BR[0],BR[1],BR[2],BR[3]);
	DrawGraphic(GetX,GetY);
	}

	let bgalpha = 0;
let bgangle = 0;
let bgscroll = 0;

@BackGround
	{
	if (bgalpha < 255){bgalpha += 5;}
	bgangle += 0.3;
	bgscroll += 1;

	SetAlpha(bgalpha);
	SetGraphicScale(1,1);
	SetColor(255,255,255);

	SetTexture(SpellBG01);
SetGraphicRect(0,0,512+bgscroll,512);

	DrawGraphic(GetCenterX,GetCenterY);

	SetTexture(SpellBG02);
	SetGraphicRect(0,0,256,256);
	SetGraphicAngle(0,0,bgangle);
	DrawGraphic(GetCenterX,GetCenterY);

	}
	
@Finalize
	{
	DeleteGraphic(imgBeam);
	DeleteGraphic(imgFire);
	DeleteGraphic(SpellBG01);
	DeleteGraphic(SpellBG02);
	if(GotSpellCardBonus==true){
		
			CreateItem(ITEM_SCORE,GetX(),GetY());
			
		}
	DeleteGraphic(SatoriSprite);
	}
	
	



}