summaryrefslogblamecommitdiff
path: root/npc/081-3/logic.txt
blob: b2fe131b9e9222ecf071aaa5955397c74306cdb8 (plain) (tree)






















































































































































                                                                                                                         
// TMW Script.
// Author:
//    Jesusalva
// Notes:
//    Christmas 2021 - Boss Chamber #1
// FIXME: Cleanup

081-3,44,36,0	script	Pentagram#Xmas21A	NPC424,{
    .@id = X21ID();
    if ($@XMAS21_BC1[.@id]) end;
    .@n$ = instance_npcname("Pentagram#Xmas21A");
    .@cl = X21BC1_CLEAR();

    mesn;
    mesq l("Should we break the Pentagram?");
    next;
    select
        l("I'm not ready yet."),
        l("Bring it on!"),
        rif(.@cl, l("Make it harder!")),
        rif(.@cl, l("Make it a nightmare!")),
        rif(.@cl, l("Kill me semi-instantly!"));
    mes "";
    if (@menu == 1) {
        closeclientdialog;
        close;
    }

    .@mg = monster(getmap(), 44, 36, "Existential Crisis", Santaboo, 1, .@n$+"::OnFin"); // FIXME Santaboo => SnowBallMan

    // Prepare the difficulty settings
    // Each difficulty level doubles the nº of players difficulty setting
    // Can go up to 12 * 4 = 48, but we use 16 as the theoretical max
    .@df = max(1, getmap() * ((@menu - 1) * 2));
    .@lv = BaseLevel;

    setunitdata(.@mg, UDT_MAXHP, 5000 + (.@lv * 150) + (1200 * .@df));
    setunitdata(.@mg, UDT_HP,    5000 + (.@lv * 150) + (1200 * .@df));

    setunitdata(.@mg, UDT_ADELAY, 2200 - max(1200, 75 * .@df));
    setunitdata(.@mg, UDT_ATKRANGE, 3);

    /*
    setunitdata(.@mg, UDT_ATKMIN,   .@lv*4+.@df*3);
    setunitdata(.@mg, UDT_ATKMAX,   .@lv*4+.@df*3);
    */
    setunitdata(.@mg, UDT_ATKMIN,   (.@lv+.@df)*5);
    setunitdata(.@mg, UDT_ATKMAX,   (.@lv+.@df)*6);
    setunitdata(.@mg, UDT_DEF,      min(50+.@df, 98));
    setunitdata(.@mg, UDT_MDEF,     min(50+.@df, 98));
    setunitdata(.@mg, UDT_HIT,      9999);

    // Destroy the instance only after half hour has passed
    instance_set_timeout(1800, 1800);
    initnpctimer;
    setnpctimer(29000);
    disablenpc(.@n$);
    $@XMAS21_BC1[.@id] = X21BC1_ON;
    .BC1ID = .@mg;
    close;

OnFin:
    // FIXME: Memorize who broke the seal
    // and attach the seal broker
    // FIXME: Mark quest as complete
    // FIXME: Give experience to the MVP as well
    stopnpctimer;
    end;

// Pseudo-Magic
OnTimer30000:
    .CYCLE += 1;
    .@m$=getmapinfo(MAPINFO_NAME); // Maybe .map$?
    debugmes "HEARTBEAT";
    debugmes "map$ is %s", .map$;
    debugmes "MAPINFO is %s", .@m$;
    debugmes "-----------------------------------------------\n";
    areamonster(.@m$, 31, 23, 58, 50, "Snowballz", IceElement, 1+getmapusers(.@m$)); // FIXME IceElement => Snowball

    if (.CYCLE % 3 != 0) {
        initnpctimer;
        end;
    }

    // The boss special skill depends on its health
    .@hp = 100 * getunitdata(.BC1ID, UDT_HP) / getunitdata(.BC1ID, UDT_MAXHP);

    // HP > 70%, just some warm-up
    if (.@hp > 70) {
        unittalk(.BC1ID, "Blizzard!");
        rectharm(.BC1ID, 6, 6, rand2(250), Ele_Neutral, "filter_always", BL_PC);

    // HP < 70%, cripple half the attackers
    } else if (.@hp > 40) {
        .@sc = any(SC_SILENCE, SC_BLIND);
        if (.@sc == SC_SILENCE)
            unittalk(.BC1ID, "Silence!");
        else
            unittalk(.BC1ID, "Blind!");
        areasc2(.@m$, 44, 36, 14, rand2(15000), BL_PC, .@sc);

    // HP < 40%, cause great damage
    } else if (.@hp > 15) {
        unittalk(.BC1ID, "Greater Blizzard!");
        rectharm(.BC1ID, 8, 8, 100+rand2(250), Ele_Neutral, "filter_always", BL_PC);

    // HP < 15%, use more dangerous conditions
    } else {
        .@sc = any(SC_POISON, SC_CURSE);
        if (.@sc == SC_SILENCE)
            unittalk(.BC1ID, "Poison!");
        else
            unittalk(.BC1ID, "Curse!");
        areasc2(.@m$, 44, 36, 14, rand2(15000), BL_PC, .@sc);
    }

    // Repeat forever
    initnpctimer;
    end;

OnInit:
    .distance=2;
    .BC1ID = 0;
    .CYCLE = 0;
    end;
}


081-3,44,22,0	script	#0813Nexit	NPC_HIDDEN,0,0,{
    if (!X21BC1_CLEAR()) {
        dispbottom l("A strong magic barrier prevents me from using this exit.");
        end;
    }
    .@id = X21ID();
    if ($@XMAS21_BC1[.@id] == X21BC1_ON) end;
    if ($@XMAS21_BC1[.@id] == X21BC1_OFF) {
        mesn;
        mesq l("Should we leave?");
        next;
        if (askyesno() == ASK_YES) {
            // FIXME: Alissa's ED Cutscene
            warp "081-1", 68, 31;
        }
        close;
    }
    end;
OnInit:
    .distance=2;
    end;
}