#TouhouDanmakufu
#ScriptVersion[3]
#Title["England Non-Spell 8"]

#include".\ZUNShot_Const.txt"
#include".\drawstuff.txt"
#include "script/default_system/Default_Effect.txt"

let ex;
let ey;
let fx1;
let fx2;
let fy1;
let fy2;
let AttackAnim = 0;
let End = 1;
let objEnemy;


	@Initialize{
		objEnemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
		ObjEnemy_Regist(objEnemy);
		ObjEnemy_SetDamageRate(objEnemy, 0, 0);
		DeleteShotAll(TYPE_ALL, TYPE_ITEM);
		Magiccircle(objEnemy);
		AuraMake;
		mainTask;	
		}

	@MainLoop
	{
		ex = ObjMove_GetX(objEnemy);
		ey = ObjMove_GetY(objEnemy);
		ObjEnemy_SetIntersectionCircleToShot(objEnemy, ex, ey, 32);//Sets the hitbox against player bullets
		ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey, 24);//Sets the hitbox against the player

		yield;
		if(ObjEnemy_GetInfo(objEnemy,INFO_LIFE)<=0){
			Obj_Delete(objEnemy);
			CloseScript(GetOwnScriptID());
		}
	}

	@Event
	{
		alternative(GetEventType())
		case(EV_REQUEST_LIFE)
		{
			SetScriptResult(2500);//Sets the life to 1500
		}
		case(EV_REQUEST_TIMER)
		{
			SetScriptResult(40);//Sets the time limit to 60
		}
		case(EV_REQUEST_SPELL_SCORE)
		{
			SetScriptResult(0);//Sets spellcard bonus to 30000 points
		}
	}

task mainTask{
	ObjMove_SetDestAtWeight(objEnemy,GetStgFrameWidth/2,GetStgFrameHeight/2-50,4,5);
	EnglandMove;
	loop(60){yield;}
	move;
	AimedShot;
	yield;
	}


task AimedShot(){
	loop(60){yield;}
	ObjEnemy_SetDamageRate(objEnemy, 100, 100);
	let x = 0;
	let y = 0;
	let dir = 0;
	loop{
		loop(10){
			DelaySE(SShot2,0,-5);
			while(x<1){
				Bullet(ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),65*sin(dir)+0);
				Bullet(ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),180-65*sin(dir));
				Laser(ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),65*sin(dir)+0);
				Laser(ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),180-65*sin(dir));
				x+=1;
				dir+=9.6;
			}
			loop(2){yield;}
			x = 0;
			y++;
		}
	}
}
task Bullet(posx,posy,angle){
	let objAnc = ObjShot_Create(OBJ_SHOT);
	let frame = 0;
	ObjMove_SetSpeed(objAnc,4);
	ObjMove_SetPosition(objAnc,posx,posy);
	ObjShot_SetGraphic(objAnc,169);
	ObjMove_SetAngle(objAnc,angle);
	ObjShot_SetSpellResist(objAnc,true);
	ObjShot_Regist(objAnc);
	while(!Obj_IsDeleted(objAnc)){
		if(ObjMove_GetX(objAnc)<0||ObjMove_GetX(objAnc)>GetStgFrameWidth){
			CreateShotA1(ObjMove_GetX(objAnc),ObjMove_GetY(objAnc),3,180-ObjMove_GetAngle(objAnc),170,0);
			Obj_Delete(objAnc);
		}
		yield;
	}
}
task Laser(posx,posy,angle){
	let objAnc = ObjShot_Create(OBJ_LOOSE_LASER);
	let frame = 0;
	ObjMove_SetSpeed(objAnc,4);
	ObjMove_SetPosition(objAnc,posx,posy);
	ObjShot_SetGraphic(objAnc,25);
	ObjMove_SetAngle(objAnc,angle);
	ObjShot_SetSpellResist(objAnc,true);
	ObjLaser_SetLength(objAnc,100);
	ObjLaser_SetRenderWidth(objAnc,10);
	ObjLaser_SetIntersectionWidth(objAnc,10);
	ObjShot_Regist(objAnc);
	while(!Obj_IsDeleted(objAnc)){
		if(ObjMove_GetX(objAnc)<0||ObjMove_GetX(objAnc)>GetStgFrameWidth){
			CreateLooseLaserA1(ObjMove_GetX(objAnc),ObjMove_GetY(objAnc),3,180-ObjMove_GetAngle(objAnc),100,10,24,0);
			loop(40){yield;}
			Obj_Delete(objAnc);
		}
		yield;
	}
}
task move{
	loop{
	ObjMove_SetDestAtWeight(objEnemy,(GetStgFrameWidth/2)+rand(-100,100),rand(75,100),10,2);
	loop(120){yield;}
	}
}