summaryrefslogtreecommitdiff
path: root/npc/functions/quest-debug/functions.txt
blob: 9dd057ad656bc47cd84ea6e0e7d20f1e77179402 (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
// Evol functions.
// Author:
//     gumi
// Description:
//     generic quest debug functions



// GenericQuestDebug
//     makes a generic quest debug menu for the given quest when the server
//     is in debug mode.

function	script	GenericQuestDebug	{
    if (!debug && !is_admin())
    {
        select
            l("Go back");

        @menuret = -0x7FFFFFFF;
        return 1;
    }

    mes l("Choose desired quest state:");

    deletearray .@vals;
    .@menustr$ = menuimage("actions/abort", l("Do nothing")) + ":";
    .@vals[0] = -0x7FFFFFFF;
    .@cnt = 1;

    for (.@f = 1; .@f < getargcount(); .@f += 2)
    {
        if (getarg(.@f) != "")
        {
            .@qv = getarg(.@f + 1);
            .@s$ = menuimage("actions/" + (.@qv ? "edit" : "reset"), "[" + .@qv + "] " + getarg(.@f));
            .@menustr$ += (.@qv < 0 ? getarg(.@f) : .@s$) + ":";
            .@vals[.@cnt] = .@qv;
            ++.@cnt;
        }
    }

    if (is_admin())
    {
        .@menustr$ += menuimage("actions/nuke", l("Set state manually"));
        .@vals[.@cnt] = -0x7FFFFFFE;
    }


    @menu = 255;
    @menuret = -1;
    select(.@menustr$);
    if (@menu == 255)
        return -1;

    --@menu;
    if (@menu < 0 || @menu >= getarraysize(.@vals))
        return -1;

    @menuret = .@vals[@menu];

    switch (@menuret)
    {
        case -0x7FFFFFFE: input @menuret; setq getarg(0,0), @menuret;
        case -0x7FFFFFFF: return 1;
    }

    if (@menuret >= 0)
    {
        setq getarg(0,0), @menuret;
    }
    return;
}