summaryrefslogtreecommitdiff
path: root/npc/functions/clear_vars.txt
blob: 76ab7bf7fa89d5b2a195c24473443d2296831d56 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
function	script	ClearVariables	{
    if(@login_event != 1) goto L_Deprecated;

    if(#BankAccount >= 0) return;
    if (Zeny >= -#BankAccount) {
        Zeny = Zeny + #BankAccount;
        #BankAccount = 0;
    }

    // Partial fix
    #BankAccount = #BankAccount + Zeny;
    Zeny = 0;
    return;
}


function	script	ClearGlobalVars	{
    $@loop = 5;
    goto L_FluffyClear;

L_FluffyClear:
    if ($@loop == 12)
        goto L_IlliaClear;

    $Record_Fluffy_Name$[$@loop] = "";
    $Record_Fluffy_Date$[$@loop] = "";
    $Record_Fluffy_Kills[$@loop] = 0;

    $@loop = $@loop + 1;
    goto L_FluffyClear;


L_IlliaClear:
    $@loop = 0;
    goto L_IlliaLoop;

L_IlliaLoop:
    if ($Illia_Win_Records$[$@loop] == "")
        goto L_EventClear;

    $Illia_Win_Records$[$@loop] = "";

    $@loop = $@loop + 1;
    goto L_IlliaLoop;

L_EventClear:
    $@loop = 0;

    $CandyOpsComplete = 0;

    $Easter_2010_Npc_State1 = 0;
    $Easter_2010_Npc_State2 = 0;
    $Easter_2010_Egg_Loc_State1 = 0;
    $Easter_2010_Egg_Loc_State2 = 0;
    $Easter_2010_Egg_Loc_State3 = 0;
    $Easter_2010_Egg_Loc_State4 = 0;
    $Easter_2010_Egg_Loc_State5 = 0;

    $hween10 = 0;
    $hween10_tondel = 0;
    $hween10_mmallow = 0;
    $hween10_jelskul = 0;
    $hween10_canpump = 0;

    $Golbenez_Inn_Cost = 0;

    $hween16 = 0;
    $hween16_tondel = 0;
    $hween16_mmallow = 0;
    $hween16_jelskul = 0;
    $hween16_canpump = 0;

    $state = 0;
    return;
}

function	script	mapexit	{
    debugmes "TRYING TO MAPEXIT IS DEPRECATED";
    return;
}

function	script	npcaction	{
    debugmes "Deprecated unitaction (did you mean npcsit; or whatever?)";
    return;
}

function	script	gmlog	{
    logmes(getarg(0), LOGMES_ATCOMMAND);
    return;
}

function	script	getx	{
    getmapxy(.@m$, .@x, .@y, 0);
    return .@x;
}

function	script	gety	{
    getmapxy(.@m$, .@x, .@y, 0);
    return .@y;
}

function	script	getnpcx	{
    return .x;
}

function	script	getnpcy	{
    return .y;
}

function	script	title	{
    setnpcdialogtitle getarg(0);
    return;
}

function	script	camera	{
    if (getarg(0, "") != "")
        setcamnpc getarg(0);
    else
        restorecam;
    return;
}

function	script	mapmask	{
    setmapmask getmapname(), getarg(0);
    return;
}

function	script	getmask	{
    return getmapmask(getmapname());
}

// isin( map, x1, y1, {[x2, y2][radius]} )
function	script	isin	{
    if (getmapxy(.@mapName$, .@xpos, .@ypos, 0) != 0)
        return false;
    if (.@mapName$ != getarg(0))
        return false;

    if (getarg(4,-1) < 0) {
        // Radius Based
        if (.@xpos >= getarg(1)-getarg(3) && .@xpos <= getarg(1)+getarg(3) && .@ypos >= getarg(2)-getarg(3) && .@ypos <= getarg(2)+getarg(3))
            return true;
    } else {
        // Coordinate based
        if (.@xpos >= getarg(1) && .@xpos <= getarg(3) && .@ypos >= getarg(2) && .@ypos <= getarg(4))
            return true;
    }
    return false;
}

// isat( map, x, y )
function	script	isat	{
    return isin(getarg(0), getarg(1), getarg(2), 0);
}

function	script	mesn	{
    if (getargcount() > 0) {
        .@s$ = "[" + getarg(0) + "]";
    } else {
        .@s$ = "[" + strnpcinfo(1) + "]";
    }
    mes .@s$;
    return;
}

// maptimer("<map>", <tick>, "<npc>::<event>")
function	script	maptimer	{
    .@c = getunits(BL_PC, .@players, false, getarg(0));
    for (.@i = 0; .@i < .@c; .@i++) {
        addtimer(getarg(1), getarg(2), .@players[.@i]);
    }
    return .@i;
}

// areatimer("<map>", <x1>, <y1>, <x2>, <y2>, <tick>, "<npc>::<event>")
function	script	areatimer	{
    .@c = getunits(BL_PC, .@players, false, getarg(0), getarg(1), getarg(2), getarg(3), getarg(4));
    for (.@i = 0; .@i < .@c; .@i++) {
        addtimer(getarg(5), getarg(6), .@players[.@i]);
    }
    return .@i;
}