script_enemy_main
{
    let count=0;
    let MT=0;
    let mm=0;
    let N15=0;
    let N16=0;
    let N16=0;
    let N17=0;
    let N18=0;
    let life=0;
    let Ang=0;
    let Level=0;

function CreateWayShot02(Way,Gap,PosX,PosY,Dist,Speed,Angle,Accelerate,MaxSpeed,Graphic,Delay) {
    ascent(let i in 0..Way) {
        CreateShot02(PosX+Dist*cos(Angle+Gap*(i+0.5-(Way * 0.5))),PosY+Dist*sin(Angle+Gap*(i+0.5-(Way * 0.5))),Speed,Angle+Gap*(i+0.5-(Way*0.5)),Accelerate,MaxSpeed,Graphic,Delay);
    }
}

function CreateWayShot03(Way,Gap,PosX,PosY,Dist,Speed,Angle,Accelerate,MaxSpeed,Graphic,Delay) {
    ascent(let i in 0..Way) {
        CreateShot02(PosX+Dist*cos(180+Angle+Gap*(i+0.5-(Way * 0.5))),PosY+Dist*sin(180+Angle+Gap*(i+0.5-(Way * 0.5))),Speed,Angle+Gap*(i+0.5-(Way*0.5)),Accelerate,MaxSpeed,Graphic,Delay);
    }
}

function CreateWayLaser(Way,Gap,PosX,PosY,Dist,Speed,Angle,Length,Width,Graphic,Delay,Remove) {
    ascent(let i in 0..Way) {
        Laser(PosX+Dist*cos(Angle+Gap*(i+0.5-(Way * 0.5))),PosY+Dist*sin(Angle+Gap*(i+0.5-(Way * 0.5))),Speed,Angle+Gap*(i+0.5-(Way*0.5)),Length,Width,Graphic,Delay,Remove);
    }
}

task Laser(x,y,s,a,l,w,g,d,rm)
{
    let obj = Obj_Create(OBJ_LASER);
    let c = 0;
    Obj_SetX(obj,x);
    Obj_SetY(obj,y);
    Obj_SetAngle(obj,a);
    ObjShot_SetGraphic(obj,g);
    ObjShot_SetDelay(obj,d);
    ObjLaser_SetLength(obj,l);
    ObjLaser_SetWidth(obj,w);
    ObjShot_SetBombResist(obj,true);
    ObjShot_ToItem(obj,false);
    ObjLaser_SetSource(obj,false);

    while (c<rm)
    {
        ObjLaser_SetLength(obj,l);
        l+=s;
        c++;
        if (d>=c) {
            ObjLaser_SetWidth(obj,20);
        }else {
            ObjLaser_SetWidth(obj,w);
        }
        if (c>=d+20) {
            Obj_SetCollisionToPlayer(obj,false);
        }
        if (c>=rm-20) {
            w=w/1.2;
            ObjLaser_SetWidth(obj,w);
        }
        if (c>=rm) {
            Obj_Delete(obj);
        }
        yield;
    }

}

task LaserP(x,y,s,a,l,w,g,d,rm)
{
    let obj = Obj_Create(OBJ_LASER);
    let c = 0;
    Obj_SetX(obj,x);
    Obj_SetY(obj,y);
    Obj_SetAngle(obj,atan2(GetPlayerY-Obj_GetY(obj),GetPlayerX-Obj_GetX(obj))+rand(-a,a));
    ObjShot_SetGraphic(obj,g);
    ObjShot_SetDelay(obj,d);
    ObjLaser_SetLength(obj,l);
    ObjLaser_SetWidth(obj,w);
    ObjShot_SetBombResist(obj,false);
    ObjShot_ToItem(obj,false);
    ObjLaser_SetSource(obj,false);

    while (c<rm)
    {
        ObjLaser_SetLength(obj,l);
        l+=s;
        c++;
        Obj_SetX(obj,Obj_GetX(obj)+1.2*cos(Obj_GetAngle(obj)));
        Obj_SetY(obj,Obj_GetY(obj)+1.2*sin(Obj_GetAngle(obj)));
        if (d>=c) {
            ObjLaser_SetWidth(obj,20);
        }else {
            ObjLaser_SetWidth(obj,w);
        }
        if (c>=rm-20) {
            Obj_SetCollisionToPlayer(obj,false);
        }
        if (c>=rm-20) {
            w=w/1.2;
            ObjLaser_SetWidth(obj,w);
        }
        if (c>=rm) {
            Obj_Delete(obj);
        }
        yield;
    }

}

@Initialize
{
    SetLife(5000);
    SetDamageRate(1,50);
    SetScore(500000);
    Level+=GetPlayerLife();
}


@MainLoop
{
    if (GetArgument==4) {
        SetDamageRate(0,0);
        if (count>40) {
            VanishEnemy;
        }
        if (count<=40) {
            DeleteEnemyShotToItemInCircle(ALL,GetX(),GetY(),count*50);
        }
    }

    count++;
    yield;

}

@Finalize
{
}

@DrawLoop
{
}
}
