// スペカ３用使い魔
script_enemy Familiar {
    let arg = GetArgument;
    let shot_color;
    if(arg == 1){shot_color = RED21;}
    else if(arg == -1){shot_color = WHITE21;}
    
    task Tmain {
        SetMovePosition02(GetCenterX+(arg*110),GetClipMaxY-70, 80);
        wait(100);
        Tshot01(GetX,GetY,shot_color);
    }

    task Tshot01(x,y,color){
        loop{
            Tshot01A;
            wait(13);
        }
    
        task Tshot01A{
            let bspMaxX = 1.7;
            let bspMaxY = 4;
            let bspX = rand(-bspMaxX, bspMaxX);
            let bspY = rand(bspMaxY*0.7, bspMaxY);
            let baspY = -0.09;
            let bspMaxY = -3;
            loop(10){
                CreateShot12(x,y,bspX,bspY,-bspX*0.05,baspY,bspX*0.6,bspMaxY,color,0);
                wait(2);
            }
        }
    }
    
    //------------------------------------------------------
    let csd     = GetCurrentScriptDirectory;

    // 使い魔の配置に必要な時間
    let wSetFam = 30;

    @Initialize {
        SetLife(2000);
        SetScore(10000);
        SetDamageRate(0, 0); //無敵
        
        LoadGraphic(imgFam);
        SetTexture(imgFam);
        setGraphicFast;

        Tmain;
    }
    
    @MainLoop {
        SetCollisionA(GetX, GetY, 24);//敵と自弾の当たり判定
        SetCollisionB(GetX, GetY, 20); //敵と自機の当たり判定（体当たり）
        yield;
    }
    
    @DrawLoop {
        SGangle;
        DrawGraphic(GetX, GetY);
    }

    // グラフィックの設定
    let imgFam  = csd ~ "img/effect_tiny.png";
    sub setGraphicFast { SetGraphicRect(48,56,48+48,56+48); }
    
    let AC = 0;
    sub SGangle{
        SetGraphicAngle(0,0,AC*arg);
        AC++;
    }

    // w フレームだけ待つ
    function wait(w) {
        loop(w) { yield; }
    }
}