Touhou Wiki
Register
Advertisement

File List[]

Danmakufu_sample02
|
+-- Danmakufu_sample02.txt
|
+-- Danmakufu_shot_pellet.txt
|
+-- img
    |
    +-- Danmakufu_sample02.png
    |
    +-- Danmakufu_shot_pellet.png

Danmakufu_sample02.txt[]

#TouhouDanmakufu
#Title[Wave Sign "Mind Shaker" Easy]
#Text[IN Stage 5: Clone of the Reisen's spell card]
#Image[.\img\Danmakufu_sample02.png]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
    let Name       = "Wave Sign "\""Mind Shaker"\";
    let ImgBoss    = "script\img\ExRumia.png";

    let CSD        = GetCurrentScriptDirectory;
    let ShotData   = CSD ~ "Danmakufu_shot_pellet.txt";
    let ShotRed    = 1;
    let ShotBlue   = 6;

    // initial position
    let xIni       = GetCenterX;
    let yIni       = GetClipMinY + 128;

    // whether in the optical illusion or not
    let inIllusion = false;

    @Initialize {
        SetLife(2000);
        SetTimer(49);
        SetScore(25000000);
        SetDamageRate(5, 5);

        LoadGraphic(ImgBoss);
        SetTexture(ImgBoss);
        setGraphicStop;

        CutIn(YOUMU, Name, "", 0, 0, 0, 0);
        LoadUserShotData(ShotData);

        TMain;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
        yield;
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
    }

    @Finalize {
        DeleteGraphic(ImgBoss);
    }

    // main task
    task TMain {
        let typeRed  = ShotRed;
        let typeBlue = ShotBlue;
        let wFire1   = 50;
        let wFire2   = 25;
        yield;

        ready;

        TRate;

        loop {
            fire1(1, typeRed);
            wait(wFire1);
            illusion;

            fire2([1.25, 0.95], typeRed);
            wait(wFire2);

            fire2([1.05, 0.85], typeBlue);
            wait(wFire2);
        }
    }

    // change the damage rates
    task TRate {
        wait(380);
        SetDamageRate(60, 60);
    }

    // go to the initial position and ready to attack
    sub ready {
        let wIni = 120;

        SetMovePosition02(xIni, yIni, wIni);
        setGraphicMove;

        SetInvincibility(wIni);
        wait(wIni);

        setGraphicPose;
    }

    // fire a single circular n-way shot
    //     v      : velocity
    //     graphic: graphic of the bullets
    function fire1(v, graphic) {
        let base  = rand(-180, 180);
        let right = true;    // true: slip to right, false: slip to left

        loop(2) {
            nwayCircle(48, v, base, graphic, right);

            base += 3.75;
            right = ! right;
        }
    }

    // fire a double circular n-way shot
    //     v      : velocity (2-element array)
    //     graphic: graphic of the bullets
    function fire2(v, graphic) {
        let base  = rand(-180, 180);
        let right = true;    // true: slip to right, false: slip to left

        ascent(i in 0..2) {
            loop(2) {
                nwayCircle(24, v[i], base, graphic, right);

                base += 3.75;
                right = ! right;
            }
        }
    }

    // optical illusion
    sub illusion {
        let wStop = 100;

        inIllusion = true;

        TimeStop(wStop, 0, 0, 1);
        MotionBlurEx(SHOT, wStop, 128, ALPHA);
        wait(wStop);

        inIllusion = false;
    }

    // circular n-way shot
    //     way    : number of the ways
    //     v      : velocity
    //     base   : base direction
    //     graphic: graphic of the bullets
    //     right  : true: slip to right, false: slip to left
    function nwayCircle(way, v, base, graphic, right) {
        let interval = 360 / way;
        let dir      = base;

        loop(way) {
            TMagicShot(GetX, GetY, v, dir, graphic, right);
            dir += interval;
        }
    }

    // shot slipped by the optical illusion
    //     x, y   : position
    //     v      : velocity
    //     dir    : direction
    //     graphic: graphic of the bullets
    //     right  : true: slip to right, false: slip to left
    task TMagicShot(x, y, v, dir, graphic, right) {
        let obj = Obj_Create(OBJ_SHOT);

        // slip interval per frame
        let dx = [-0.25, 0.25][right];
        let dy = 0.2;

        Obj_SetX          (obj, x);
        Obj_SetY          (obj, y);
        Obj_SetAngle      (obj, dir);
        ObjShot_SetGraphic(obj, graphic);

        while(! Obj_BeDeleted(obj)) {
            Obj_SetSpeed            (obj, v);
            Obj_SetAlpha            (obj, 255);
            Obj_SetCollisionToPlayer(obj, true);

            // wait for the optical illusion
            while(! inIllusion) { yield; }

            Obj_SetSpeed            (obj, 0);
            Obj_SetAlpha            (obj, 128);
            Obj_SetCollisionToPlayer(obj, false);

            // slip
            while(inIllusion) {
                Obj_SetX(obj, Obj_GetX(obj) + dx);
                Obj_SetY(obj, Obj_GetY(obj) + dy);
                yield;
            }
        }
    }

    // set the graphic region
    sub setGraphicStop  { SetGraphicRect(  0,   0,  64,  64); }    // stopping
    sub setGraphicPose  { SetGraphicRect( 64,   0, 128,  64); }    // special pose
    sub setGraphicLeft  { SetGraphicRect(128,   0, 192,  64); }    // move left
    sub setGraphicRight { SetGraphicRect(192,   0, 256,  64); }    // move right

    // set the graphic region according to the moving direction
    sub setGraphicMove {
        if(GetSpeedX < 0) {
            setGraphicLeft;
        } else {
            setGraphicRight;
        }
    }

    // wait for w frames
    function wait(w) {
        loop(w) { yield; }
    }
}


Danmakufu_shot_pellet.txt[]

#UserShotData

ShotImage = ".\img\Danmakufu_shot_pellet.png"

// Red
ShotData {
    id          = 1
    rect        = (0, 0, 8, 16)
    delay_color = (255, 128, 128)
}

// Orange
ShotData {
    id          = 2
    rect        = (8, 0, 16, 16)
    delay_color = (255, 192, 128)
}

// Yellow
ShotData {
    id          = 3
    rect        = (16, 0, 24, 16)
    delay_color = (255, 255, 128)
}

// Green
ShotData {
    id          = 4
    rect        = (24, 0, 32, 16)
    delay_color = (128, 255, 128)
}

// Aqua
ShotData {
    id          = 5
    rect        = (32, 0, 40, 16)
    delay_color = (128, 255, 255)
}

// Blue
ShotData {
    id          = 6
    rect        = (40, 0, 48, 16)
    delay_color = (128, 128, 255)
}

// Purple
ShotData {
    id          = 7
    rect        = (48, 0, 56, 16)
    delay_color = (255, 128, 255)
}

// White
ShotData {
    id          = 8
    rect        = (56, 0, 64, 16)
    delay_color = (255, 255, 255)
}


Danmakufu_sample02.png[]

Danmakufu sample02


Danmakufu_shot_pellet.png[]

Danmakufu shot pellet


Advertisement