summaryrefslogblamecommitdiff
path: root/world/map/npc/052-2/storage.txt
blob: b52dc7591fa6b44624d09a086fe9d7918f0625bc (plain) (tree)





















































































































































                                                                                                                                                         
                                   





































                                                                                                 
//-----------------------------------------------------------------------------
// Illia Forsaken Inn - Storage
// $@illia_progress = 6
//
// Level progress:
//     0: Initial state
//     1: Items and/or mobs are spawned
//     2: All spawns are done and the players killed all mobs
//-----------------------------------------------------------------------------

052-2.gat,23,69,0|script|#TriggerItemsInvoker|32767,1,0,{
    set @step, 6;
    if ($@illia_progress < @step) goto L_ShouldNotBeHere;
    if (strcharinfo(0) != $@ILLIA_HERO$) end;
    if ($@illia_level_6_progress == 0) goto L_StartItemInvoker;
    end;

L_ShouldNotBeHere:
    percentheal -100, 0;
    end;

L_StartItemInvoker:
    set $@illia_level_6_progress, 1;
    cmdothernpc "#ItemsInvoker", "Start";
    end;

}

052-2.gat,1,1,0|script|#ItemsInvoker|127,{
end;

onInit:
    setarray $@illia_storage_items, 541, 567, 568, 562;
    setarray $@illia_storage_special_items, 687, 827, 1229;
    // Map coords : x1,y1, x2,y2, ...
    setarray $@illia_storage_item_points, 20,67, 22,75, 27,71, 30,73, 34,76, 30,64, 34,65, 34,62, 21,61, 22,64;
    end;

OnCommandStart:
    set $@illia_storage_max_items, 20;
    set $@illia_storage_deviation, (8 + ($Illia_Luvia_Harvest*70)/100)*3;
    initnpctimer;
    areatimer "052-2.gat", 19, 60, 35, 78, 10, "#ItemsInvoker::onStart";
    end;

onStart:
    message strcharinfo(0), "You feel a strange atmosphere in this room... You sense a strong magic rising from the depth!";
    end;

OnTimer1000:
    if ($@illia_storage_max_items == 0)
        goto L_CheckMobs;
    set $@item_invoke_index, rand(getarraysize($@illia_storage_item_points)/2);
    set $@item_invoke_x, $@illia_storage_item_points[$@item_invoke_index*2];
    set $@item_invoke_y, $@illia_storage_item_points[($@item_invoke_index*2)+1];
    npcwarp $@item_invoke_x, $@item_invoke_y, "#ItemsInvoker";
    // This is a fix to force the official mana client to display a npc after a warp.
    // Note: the manaplus client do not need this.
    disablenpc "#ItemsInvoker";
    end;

OnTimer1500:
    // See the note above.
    enablenpc "#ItemsInvoker";
    areatimer "052-2.gat", 19, 60, 35, 78, 10, "#ItemsInvoker::onItem";
    misceffect FX_GROUND_SPAWN;
    end;

OnTimer3750:
    setnpctimer 0;
    set $@item_invoke_x, 0;
    set $@item_invoke_y, 0;
    set $@item_invoke_index, 0;
    end;

onItem:
    if (strcharinfo(0) == $@ILLIA_HERO$)
        goto L_ItemSpawn;
    end;

L_ItemSpawn:
    // This section will decide what to spawn: special monster, monster, item, special item
    // Calculation uses a decreasing variable which introduces a deviation.
    // Its initial value is based on $@Illia_Luvia_Harvest
    //  * first decide (50% / 50%) if the deviation will be positive or negative
    //  * Apply the deviation to a random number between 0, 100. (note the final value can be < 0 or > 100)
    // The purpose is that, when the initial deviation is high, there are high chances to get either
    // a special monster, or a special item.
    set @m, rand(100);
    if (@m < 50)
        set @r, rand(100) - $@illia_storage_deviation;
    if (@m >= 50)
        set @r, rand(100) + $@illia_storage_deviation;
    // Reduce the deviation
    set $@illia_storage_deviation, $@illia_storage_deviation*83/100;
    if (@r < 5)
        goto L_MakeSpecialMonster;
    if (@r < 50)
        goto L_MakeMonster;
    if (@r > 98)
        goto L_MakeSpecialItem;
    // Normal item
    makeitem $@illia_storage_items[rand(getarraysize($@illia_storage_items))], rand(2, 8), "052-2.gat", $@item_invoke_x, $@item_invoke_y;
    set $@illia_storage_max_items, $@illia_storage_max_items - 1;
    set @r, 0;
    end;

L_MakeSpecialMonster:
    monster "052-2.gat", $@item_invoke_x, $@item_invoke_y, "", 1103, 1, "#ItemsInvoker::onDeath";
    areatimer "052-2.gat", 19, 60, 35, 78, 10, "#ItemsInvoker::onWtf";
    set $@illia_storage_max_items, $@illia_storage_max_items - 1;
    end;

L_MakeMonster:
    monster "052-2.gat", $@item_invoke_x, $@item_invoke_y, "", 1101, rand(1, 3), "#ItemsInvoker::onDeath";
    set $@illia_storage_max_items, $@illia_storage_max_items - 1;
    set @r, 0;
    end;

L_MakeSpecialItem:
    makeitem $@illia_storage_special_items[rand(getarraysize($@illia_storage_special_items))], rand(2, 4), "052-2.gat", $@item_invoke_x, $@item_invoke_y;
    areatimer "052-2.gat", 19, 60, 35, 78, 10, "#ItemsInvoker::onWow";
    set $@illia_storage_max_items, $@illia_storage_max_items - 1;
    set @r, 0;
    end;

L_CheckMobs:
    if ($@illia_progress != 6)
        goto L_Clear;
    if (mobcount("052-2.gat", "#ItemsInvoker::onDeath") < 0)
        goto L_Stop;
    setnpctimer 0;
    end;

L_Clear:
    stopnpctimer;
    setnpctimer 0;
    set $@illia_storage_deviation, 0;
    set $@illia_storage_max_items, 0;
    killmonster "052-2.gat", "#ItemsInvoker::onDeath";
    end;

L_Stop:
    stopnpctimer;
    setnpctimer 0;
    npcwarp 1, 1, "#ItemsInvoker";
    set $@illia_storage_deviation, 0;
    set $@illia_storage_max_items, 0;
    set $@illia_level_6_progress, 2;
    set $@illia_progress, 7;
    callfunc "UpdateIlliaProgress";
    set $@illia_max_time, $@illia_max_time + 1200;
    areatimer "052-2.gat", 19, 60, 35, 78, 10, "#ItemsInvoker::onStop";
    end;

onDeath:
    end;

onStop:
    message strcharinfo(0), "The magic seems to quickly dissipate.";
    end;

onWtf:
    message strcharinfo(0), "Look out!";
    end;

onWow:
    message strcharinfo(0), "Wow, see what appeared!";
    end;

}

052-2.gat,35,68,0|script|#ToPartyRoom|32767,1,1,{
    set @step, 6;
    if ($@illia_progress < @step) goto L_ShouldNotBeHere;
    if ($@illia_level_6_progress == 2) goto L_Warp;
    message strcharinfo(0), "The strong magic inside this room prevents you from going further.";
    end;

L_Warp:
    warp "052-2.gat", 73, 48;
    end;

L_ShouldNotBeHere:
    percentheal -100, 0;
    end;

}