script_spell STAR{
   let imgEffect = GetArgument[0];
   let caution = GetArgument[1];
   let thePower = 1;

    @Initialize {
        SetPlayerInvincibility(350);
	TMain;
	
    }

    @Finalize {
    }

    @MainLoop {
        yield;

    }

 task TMain {
	let secount = 0;
	PlaySE("seBomb_MarisaA.wav");
	loop(350){
		if(secount == 10){
			sunbirth(0, -90, 6, 99999999, 6, 100);
		}
		secount++;
		if(secount <= 250 && secount%5 == 0){
			let cX = (GetClipMaxX-GetCenterX);
			let cY = (GetClipMaxY-GetCenterY);
			let dist = ((cX^2) + (cY^2))^(1/2) +10;
			ascent(n in 0..6){
				let delay = 0;
				let thisX = GetCenterX+(dist*sin(60*n-(secount*2)));
				if(thisX > GetClipMaxX){
					delay = thisX - GetClipMaxX;
					thisX = GetClipMaxX+10;
				}
				if(thisX < GetClipMinX){
					delay = GetClipMinX - thisX;
					thisX = GetClipMinX-10;
				}
				let thisY = GetCenterY+(dist*cos(60*n-(secount*2)));
				if(thisY > GetClipMaxY){
					delay = thisY - GetClipMaxY;
					thisY = GetClipMaxY+10;
				}
				if(thisY < GetClipMinY){
					delay = GetClipMinY - thisY;
					thisY = GetClipMinY-10;
				}
				particle(thisX,thisY,350-secount, delay);
			}
		}
		yield;
	}
	End;
    }

task sunbirth(let speed,let angle,let damage,let penetlate,let stype, rad){
	let life = 0;
	let y = rad;
	let objShot= Obj_Create(OBJ_LASER);
	Obj_SetX(objShot, GetPlayerX);
	Obj_SetY(objShot, GetPlayerY+(y/2));
	Obj_SetAlpha(objShot,255); 
	ObjLaser_SetLength( objShot, rad);
	ObjLaser_SetWidth( objShot, rad);
        	ObjShot_SetGraphic(objShot, stype);
	ObjShot_SetDamage(objShot, damage);    
	ObjShot_SetPenetration(objShot, penetlate);
	Obj_SetAngle(objShot, angle);
	Obj_SetSpeed(objShot,speed);
	ObjLaser_SetSource(objShot,false);
	SetSpeed(0, 0);
	PlaySE(caution);
	loop(300){
		SetPlayerX(GetPlayerX-(GetPlayerX-GetCenterX)/20);
		SetPlayerY(GetPlayerY-(GetPlayerY-GetCenterY)/20);
		life++;
		if(life > 110){
			thePower =2;
			if(y < rad*thePower){
			y += rad/10;}
			ObjLaser_SetLength( objShot, y);
			ObjLaser_SetWidth( objShot, y);
		}
		if(life > 210){
			thePower =3;
			if(y < rad*thePower){
			y += rad/10;}
			ObjLaser_SetLength( objShot, y);
			ObjLaser_SetWidth( objShot, y);
		}
		if(life%5==0 && life<=250){
			explode(GetPlayerX,GetPlayerY,rand(2,5),rand(-180,180),3,300, y);
			explode(GetPlayerX,GetPlayerY,rand(2,5),rand(-180,180),3,300, y);
			explode(GetPlayerX,GetPlayerY,rand(2,5),rand(-180,180),3,300, y);
		}
		Obj_SetX(objShot, GetPlayerX);
		Obj_SetY(objShot, GetPlayerY+(y/2));
		ObjShot_SetDamage(objShot, damage+(y/50));
		yield;
		}
	SetSpeed(3.7, 1.3);
	Obj_Delete(objShot);
	}

task particle(let x, let y, let lifetime, let delay){
		let part = Obj_Create(OBJ_SHOT);
		let life = 0;
		let stype = 1;
		Obj_SetX(part, x);
		Obj_SetY(part, y);
		Obj_SetAlpha(part,500); 
		ObjShot_SetGraphic(part, stype);
		ObjShot_SetPenetration(part, 300);
		while( !Obj_BeDeleted(part))
		{
			life++;
			let toAngle=atan2(GetPlayerY-Obj_GetY(part), GetPlayerX-Obj_GetX(part));	
			if(life<= lifetime){Obj_SetAngle(part, toAngle);}
			else{Obj_Delete(part);}
			Obj_SetSpeed(part, 1.5+thePower);
			if(delay >= 0){
				Obj_SetSpeed(part, 0);
				delay -= 1+(thePower * 0.5);
			}
			ObjShot_SetDamage(part,0.5*thePower);
			yield;
		}
		Obj_Delete(part);
	}
task explode(let x,let y,let speed,let angle,let damage,let penetlate, let dist){
	let objShot= Obj_Create(OBJ_SHOT);
	let Alpha = 255;
	let life = 0;
	let stype = 30;
	Obj_SetX(objShot, x);
	Obj_SetY(objShot, y);
	Obj_SetAlpha(objShot,Alpha); 
        	ObjShot_SetGraphic(objShot, stype);
	ObjShot_SetDamage(objShot, damage);    
	ObjShot_SetPenetration(objShot, penetlate);
	Obj_SetAngle(objShot, angle);
	Obj_SetSpeed(objShot,speed);
	while( !Obj_BeDeleted(objShot)){
		life++;
		if(life >= dist/(3*speed) && life%2 == 0){stype++;
			ObjShot_SetGraphic(objShot, stype)}
		if(stype >=38){Obj_Delete(objShot);}
		yield;
		}
	Obj_Delete(objShot);
	}

}