summaryrefslogtreecommitdiff
path: root/world/map/npc/functions/barber.txt
blob: 311bbb85398a75a9933c87db4fbad35edcf19e89 (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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
// The Barber script has been around since before the repository split
// so it's hard to figure out who wrote it.

// o11c updated it according to new scripting standards while adding pink.
// ... and added the code that shows your old color/style.

// Note: there is a soft limit of 15 colors per classes and 20 styles (0-19)
// This is the number that can be set when creating a character
// or using GM commands, but scripts (such as this one) can set
// any value 0-255

function|script|Barber
{
    if (getequipid(equip_head) == 647)
        goto L_Debug;
    callfunc "getHeadStyles";
    set @hairOpts, 0;
    set @colorOpts, 0;
    set @menu, 0;
    goto L_Main;

L_MainClear:
    clear;
    goto L_Main;

L_Main:
    set @style, getlook(LOOK_HAIR_STYLE);
    set @color, getlook(LOOK_HAIR_COLOR);
    set @style$, "Unknown";
    set @color$, "Unknown";

    if (@style >= 1 && @style <= 20)
        set @style$, @HairStyles$[(@style - 1)];

    if (@color == ((HC_WHITE - Class) + 1))
        set @color$, "Shocked White";
    set @color, (@color - (15 * (Class - 1)));
    if (@color >= 0 && @color <= 15)
        set @color$, @HairColors$[@color];

    if (Sex == 0) set @gender$, " female";
    elif (Sex == 1) set @gender$, " male";
    elif (Class == 3 || Class == 6) set @gender$, "n";
    else set @gender$, "";

    mes "You are a" + @gender$ + " " + @species$ + ".";
    mes "Your current style is " + @style$ + " and your current color is " + @color$ + ".";
    set @style$, "";
    set @color$, "";
    menu
        "Change my style", L_Style,
        "Change my color", L_Color,
        "Change my gender", L_Gender,
        "Change my species", L_Species,
        "Nah, I'm fine", L_Done;

L_Gender:
    menu
        "Female.", L_Female,
        "Male.", L_Male,
        "Non-binary.", L_NonBinary,
        "Nah, I'm fine", L_MainClear;

L_Female:
    set Sex, 0;
    goto L_MainClear;

L_Male:
    set Sex, 1;
    goto L_MainClear;

L_NonBinary:
    set Sex, 3;
    goto L_MainClear;

L_Species:
    if (countitem("SkeletonCharm") >= 1)
        menu
            "Talpan", L_Species_next,
            "Tritan", L_Species_next,
            "Ifriton", L_Species_next,
            //"Gispaan", L_Species_next,
            //"Sparron", L_Species_next,
            "Undead", L_Species_next,
            "Nah, I'm fine", L_MainClear;
    //else
        menu
            "Talpan", L_Species_next,
            "Tritan", L_Species_next,
            "Ifriton", L_Species_next,
            //"Gispaan", L_Species_next,
            //"Sparron", L_Species_next,
            "Nah, I'm fine", L_MainClear;

L_Species_next:
    if (@menu == 4) set @menu, 6;
    set Class, @menu;
    callfunc "fixHeadStyles";
    goto L_MainClear;

L_Style:
    if(!@hairOpts) set @HairStyles$[getarraysize(@HairStyles$)], "Surprise me";
    if(!@hairOpts) set @HairStyles$[getarraysize(@HairStyles$)], "Nah, I'm fine";
    if(!@hairOpts) set @hairOpts, 1;
    menu
        @HairStyles$[0], L_MenuItems,
        @HairStyles$[1], L_MenuItems,
        @HairStyles$[2], L_MenuItems,
        @HairStyles$[3], L_MenuItems,
        @HairStyles$[4], L_MenuItems,
        @HairStyles$[5], L_MenuItems,
        @HairStyles$[6], L_MenuItems,
        @HairStyles$[7], L_MenuItems,
        @HairStyles$[8], L_MenuItems,
        @HairStyles$[9], L_MenuItems,
        @HairStyles$[10], L_MenuItems,
        @HairStyles$[11], L_MenuItems,
        @HairStyles$[12], L_MenuItems,
        @HairStyles$[13], L_MenuItems,
        @HairStyles$[14], L_MenuItems,
        @HairStyles$[15], L_MenuItems,
        @HairStyles$[16], L_MenuItems,
        @HairStyles$[17], L_MenuItems,
        @HairStyles$[18], L_MenuItems,
        @HairStyles$[19], L_MenuItems,
        @HairStyles$[20], L_MenuItems,
        @HairStyles$[21], L_MenuItems;

L_MenuItems:
    if(@menu == (getarraysize(@HairStyles$) - 1)) goto L_RandomStyle;
    if(@menu >= getarraysize(@HairStyles$)) goto L_MainClear;
    setlook LOOK_HAIR_STYLE, @menu;
    goto L_MainClear;

L_RandomStyle:
    setarray @randomStyle[0], rand(1, (getarraysize(@HairStyles$) - 2));
    setarray @randomStyle[1], @randomStyle[1] + 1; // infinite loop prevention
    if(@randomStyle[0] == @style && @randomStyle[1] < 15) goto L_RandomStyle;
    setlook LOOK_HAIR_STYLE, @randomStyle[0];
    setarray @randomStyle[1], 0;

    set .@style$, @HairStyles$[(@randomStyle[0] - 1)];
    mes "Your new style is " + .@style$;

    menu
        "Surprise me once again", L_RandomStyle,
        "Go back", L_MainClear,
        "Goodbye", L_Done;

L_Color:
    if(!@colorOpts) set @HairColors$[getarraysize(@HairColors$)], "Surprise me";
    if(!@colorOpts) set @HairColors$[getarraysize(@HairColors$)], "Nah, I'm fine";
    if(!@colorOpts) set @colorOpts, 1;
    menu
        @HairColors$[0], L_MenuItems1,
        @HairColors$[1], L_MenuItems1,
        @HairColors$[2], L_MenuItems1,
        @HairColors$[3], L_MenuItems1,
        @HairColors$[4], L_MenuItems1,
        @HairColors$[5], L_MenuItems1,
        @HairColors$[6], L_MenuItems1,
        @HairColors$[7], L_MenuItems1,
        @HairColors$[8], L_MenuItems1,
        @HairColors$[9], L_MenuItems1,
        @HairColors$[10], L_MenuItems1,
        @HairColors$[11], L_MenuItems1,
        @HairColors$[12], L_MenuItems1,
        @HairColors$[13], L_MenuItems1,
        @HairColors$[14], L_MenuItems1,
        @HairColors$[15], L_MenuItems1,
        @HairColors$[16], L_MenuItems1;

L_MenuItems1:
    if(@menu == (getarraysize(@HairColors$) - 1)) goto L_RandomColor;
    if(@menu >= getarraysize(@HairColors$)) goto L_MainClear;
    setlook LOOK_HAIR_COLOR, ((@menu - 1) + (15 * (Class - 1)));
    goto L_MainClear;

L_RandomColor:
    setarray @randomColor[0], rand((15 * (Class - 1)), ((getarraysize(@HairColors$) - 3) + (15 * (Class - 1))));
    setarray @randomColor[1], @randomColor[1] + 1;
    if(@randomColor[0] == @color && @randomColor[1] < 15) goto L_RandomColor;
    setlook LOOK_HAIR_COLOR, @randomColor[0];
    setarray @randomColor[1], 0;
    menu
        "Surprise me once again", L_RandomColor,
        "Go back", L_MainClear,
        "Goodbye", L_Done;

L_Done:
    // cleanup
    set @menu, 0;
    set @style, 0;
    set @color, 0;
    cleararray @HairStyles$, "", getarraysize(@HairStyles$);
    cleararray @HairColors$, "", getarraysize(@HairColors$);
    set @hairOpts, 0;
    set @colorOpts, 0;
    return;

L_Debug:
    npcaction 9; // FIXME: this should become a builtin (ie `clear`)
    mes "Class: " + Class;
    mes "Style: " + getlook(LOOK_HAIR_STYLE);
    mes "Color: " + getlook(LOOK_HAIR_COLOR);
    mes "Gender: " + Sex;
    menu
        "edit| Set Class", L_DebugClass,
        "edit| Set Style", L_DebugStyle,
        "edit| Set Color", L_DebugColor,
        "edit| Set Gender", L_DebugGender,
        "toggle| Simulate logout", L_DebugLogout,
        "Close", L_Done;

L_DebugLogout:
    callfunc "fixHeadStyles";
    goto L_Debug;

L_DebugClass:
    set @dbg_class, 0;
    mes "input class (0-32767)";
    input @dbg_class;
    if (@dbg_class >= 0 && @dbg_class <= 32767)
        set Class, @dbg_class;
    set @dbg_class, 0;
    goto L_Debug;

L_DebugStyle:
    set @dbg_style, 0;
    mes "input style (0-255)";
    input @dbg_style;
    if (@dbg_style >= 0 && @dbg_style <= 255)
        setlook LOOK_HAIR_STYLE, @dbg_style;
    set @dbg_style, 0;
    goto L_Debug;

L_DebugColor:
    set @dbg_color, 0;
    mes "input color (0-255)";
    input @dbg_color;
    if (@dbg_color >= 0 && @dbg_color <= 255)
        setlook LOOK_HAIR_COLOR, @dbg_color;
    set @dbg_color, 0;
    goto L_Debug;

L_DebugGender:
    set @dbg_gender, 0;
    mes "input gender (0-3)";
    input @dbg_gender;
    if (@dbg_gender >= 0 && @dbg_gender <= 3)
        set Sex, @dbg_gender;
    set @dbg_gender, 0;
    goto L_Debug;
}