summaryrefslogblamecommitdiff
path: root/npc/commands/warp.txt
blob: 35af43406ff6067480389ba4fe4a4d18a3d612da (plain) (tree)































































                                                                           

                                                               



                                                          
 


                                                                                     
                   
                                                                       










                                             
// @w atcommand
// warps using anchors or map name
//
// group lv: 1
// group char lv: 2
// log: True
//
// usage:
//    @w <map or anchor> [, x [, y]]
//    #w "char" <map or anchor> [, x [, y]]
//
// example:
//    @w artis
//    #w "char" artis

-	script	@w	32767,{
    end;

OnCall:
    .@request$ = strtoupper(strip(.@atcmd_parameters$[0])); // sanitize
    .@map$ = "";
    .@x = 0;
    .@y = 0;

    for (.@i = 0; .@i < .count; .@i += 2)
    {
        if (.@request$ ~= .aliases$[.@i])
        {
            sscanf .aliases$[.@i + 1], "%s %d %d", .@map$, .@x, .@y;
            break;
        }
    }

    if (.@map$ == "")
    {
        .@map$ = .@atcmd_parameters$[0];
    }

    if (.@atcmd_parameters$[2] != "")
    {
        .@x = atoi(.@atcmd_parameters$[1]);
        .@y = atoi(.@atcmd_parameters$[2]);
    }

    // FIXME: here getmapusers() is used only to check if the map exists
    //        replace this when/if we get a dedicated function for that
    if (getmapusers(.@map$) < 0)
    {
        end; // invalid map
    }

    while (!checkcell(.@map$, .@x, .@y, cell_chkpass))
    {
        if (.@e == 50) end;
        .@x = rand(20, 250);
        .@y = rand(20, 250);
        ++.@e;
    }

    cwarp .@map$, .@x, .@y; // XXX: maybe here use a slide_or_warp function

OnInit:
    setarray .aliases$[0],

        // PROLOGUE
        "^START|^BEGIN",    "000-0 22 24",    // starting point

        // TMW2
        "^TULIM",           "003-1 41 48",    // Tulishmar
        "^CANDOR",          "005-1 28 92",    // Tulishmar

        // TMW-BR
        "^AEROS",           "aeros 76 26",    // Floating Island of Aeros (GM Events)

        // WOODLAND
        "^HURN",            "008-1 79 64";    // hurnscald: town square

    .count = getarraysize(.aliases$[0]);

    if (debug > 0)
    {
        bindatcmd "w", "@w::OnCall", 0, 2, 0;
        end;
    }

    bindatcmd "w", "@w::OnCall", 1, 2, 1;
}