summaryrefslogtreecommitdiff
path: root/world/map/npc/items/anchor_stone.txt
blob: e0be2f1c0ab1a1ad094b93753628848b13418d5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
function|script|useAnchorStone
{
    addtimer 0, "AS_Core::OnUse";
    return;
}

-|script|AS_Core|32767
{
    end;

OnUse:
    if (isin("botcheck",25,27,51,47))
        goto L_Prison;
    if (getmapflag(getmap(), MF_NOSAVE) || getmapflag(getmap(), MF_NOTELEPORT) || getmapflag(getmap(), MF_NOWARP) || isin("009-7",$@fightclub_x1,$@fightclub_y1,$@fightclub_x2,$@fightclub_y2))
        goto L_Forbid;

    if ( @StoneName$ == "AnchorStone" ) goto L_AnchorStone;
    if ( @StoneName$ == "AnchoredAnchorStone" ) goto L_AnchoredAnchorStone;
    goto L_Close;

L_AnchorStone:
    mes "\"You really want to bind the [@@" + AnchorStone + "|@@] to this place?\"";
    menu
        "No", L_Close,
        "Yes", L_AS_Yes;

L_AS_Yes:
    set AnchorStoneDest, getmaphash(getmap()); // since a hash could be negative I take a separate variable for that since shifting would destroy the sign bit and create a different hash
    set AnchorStoneDestCoord, gety() << AS_Y_SHIFT | getx() << AS_X_SHIFT;

    delitem AnchorStone, 1;
    getitem AnchoredAnchorStone, 1;
    close;

L_AnchoredAnchorStone:
    if ((AnchorStoneDest < 1) && (AnchorStoneDest > -1)) goto L_AAS_Error;
    mes "\"You want to recall to the place the [@@" + AnchoredAnchorStone + "|@@] is bound to?\"";
    menu
        "No", L_Close,
        "Yes", L_AAS_Yes,
        "Unbind Anchored Anchor Stone", L_AAS_Unbind;

L_AAS_Yes:
    warp getmapnamefromhash(AnchorStoneDest), (AnchorStoneDestCoord & AS_X_MASK >> AS_X_SHIFT), (AnchorStoneDestCoord & AS_Y_MASK >> AS_Y_SHIFT);
    goto L_AAStoAS;

L_AAS_Unbind:
    mes "";
    mes "\"You really want to unbind the [@@" + AnchoredAnchorStone + "|@@] from it's destination?\"";
    menu
        "No", L_Close,
        "Yes", L_AAStoAS;

L_AAS_Error:
    mes "\"Something went wrong the [@@" + AnchoredAnchorStone + "|@@] lost its destination and turns back to normal.\"";
    goto L_AAStoAS;

L_AAStoAS:
    set AnchorStoneDest, 0;
    set AnchorStoneDestCoord, 0;

    delitem AnchoredAnchorStone, 1;
    getitem AnchorStone, 1;
    close;

L_Forbid:
    message strcharinfo(0), "Anchor Stone : This area is protected by a force that doesn't tolerate the power of the Anchor Stone.";
    goto L_Close;

L_Prison:
    message strcharinfo(0), "Anchor Stone : You must be warped by a GM to leave the botcheck area.";
    goto L_Close;

L_Close:
    close;
}