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

    @Initialize {
        SetPlayerInvincibility(310);
	TMain;
    }

    @Finalize {
    }

    @MainLoop {
        yield;

    }

 task TMain {
	let secount = 0;
	PlaySE("seBomb_MarisaA.wav");
	loop(310){
		if(secount == 0){
			callSun();
		}
		secount++;
		yield;
	}
	End;
    }
	task callSun(){
		Flare(GetPlayerX(),GetPlayerY(),12,3000,6,1.5,1);
		yield;
	}
	
	task Flare(let x,let y,let damage,let penetlate,let stype, let scale, lv){
	let objShot= Obj_Create(OBJ_LASER);
	let Alpha = 50;
	let size = 0;
	let speed = 0;
	let life = 0;
	Obj_SetX(objShot, x);
	Obj_SetY(objShot, y-15);
	Obj_SetAlpha(objShot,Alpha); 
        	ObjShot_SetGraphic(objShot, stype);
	ObjShot_SetDamage(objShot, damage);
			ObjLaser_SetLength( objShot, 0);
			ObjLaser_SetWidth( objShot, 0);
	ObjLaser_SetSource(objShot,false);
	ObjShot_SetPenetration(objShot, penetlate);
	Obj_SetAngle(objShot, -90);
	PlaySE(caution);
	while( !Obj_BeDeleted(objShot)){
		life++;
		if(Alpha<255){
			Alpha += (5/lv);
			Obj_SetAlpha(objShot,Alpha);
		}
		if(size<=250){
			size += scale;
			speed += 0.001;
			ObjLaser_SetLength( objShot, size);
			ObjLaser_SetWidth( objShot, size);
		}
		else{speed += 0.05;}
		if(life%5==0 && life < 280){
			let lifey = Obj_GetY(objShot)-(size/2);
			explode(x,lifey,rand(2,5),rand(-180,180),3,300,size/2);
			explode(x,lifey,rand(2,5),rand(-180,180),3,300,size/2);
			explode(x,lifey,rand(2,5),rand(-180,180),3,300,size/2);
		}
		ObjShot_SetDamage(objShot, damage+(size/20));
		Obj_SetY(objShot,Obj_GetY(objShot)-speed);
		yield;
		}
	Obj_Delete(objShot);
	}
	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);
	}
}