summaryrefslogtreecommitdiff
path: root/npc/functions/barber.txt
blob: 6ce19eea62adbded8ef90af3d041ed9a680429e9 (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
// Evol scripts.
// Authors:
//    omatt
//    Reid
//    Travolta
//    Jesusalva
// Description:
//    Function for supporting barber NPC.

function	script	BarberSayStyle	{

    .@get_color = getlook(LOOK_HAIR_COLOR);
    .@get_look = getlook(LOOK_HAIR);
    .@style_name$ = $@hairstyle$[.@get_look];
    .@color_name$ = $@haircolor$[.@get_color];

    switch (getarg(0))
    {
        case 1:
            message strcharinfo(0), l("@@", .@style_name$);
            break;
        case 2:
            message strcharinfo(0), l("@@", .@color_name$);
            break;
        case 3:
            speech S_FIRST_BLANK_LINE | S_LAST_NEXT,
                l("Your hairstyle is @@ and its color is @@.", .@style_name$, .@color_name$);
            break;
    }
    return;
}
function	script	BarberChangeStyle	{
    do
    {
        .@hairsizearray = getarraysize($@hairstyle$);
        .@get_look = getlook(LOOK_HAIR);

        // Here .@i starts from 1 because hairstyle 0 doesn't exist.
        for (.@i = 1; .@i < .@hairsizearray; .@i++)
        {
            .@menustr$ = .@menustr$
                        + rif(.@get_look !=  .@i, l("" + $@hairstyle$[.@i] + ""))
                        + ":";
        }

        .@menustr$ = .@menustr$ + l("I'm fine for now, thank you.");

        .@idx = select(l("As you want!"),.@menustr$);

        if (.@idx == .@i + 1) return; // last choice to quit dialog

        switch (@menu)
        {
            case 1:
                do
                {
                    // here "- 1" because i don't use the 0 of array
                    .@rand_hair = rand(1,(.@hairsizearray - 1));
                } while (.@rand_hair == getlook(LOOK_HAIR));
                setlook LOOK_HAIR, .@rand_hair;
                setlook LOOK_HAIR_COLOR, getlook(LOOK_HAIR_COLOR);
                BarberSayStyle 1;
                break;
            default:
                // and here "- 1" because the first choice is taken by the random
                setlook LOOK_HAIR, (@menu - 1);
                setlook LOOK_HAIR_COLOR, getlook(LOOK_HAIR_COLOR);
                break;
        }
        .@menustr$ = "";
    } while (1);
}

function	script	BarberChangeColor	{
    do
    {
        .@get_look = getlook(LOOK_HAIR_COLOR);
        .@hairsizearray = getarraysize($@haircolor$);

        for (.@i = 0; .@i < .@hairsizearray; .@i++)
        {
            .@menustr$ = .@menustr$
                        + rif(.@get_look !=  .@i, l("" + $@haircolor$[.@i] + ""))
                        + ":";
        }

        .@menustr$ = l("Surprise me!") + ":" + .@menustr$ + l("I'm fine for now, thank you.");

        .@idx = select(.@menustr$);

        if (.@idx == .@i + 2) return;

        switch (@menu)
        {
            case 1:
                do
                {
                    .@rand_color = rand(0, .@hairsizearray);
                } while (.@rand_color == getlook(LOOK_HAIR_COLOR));
                setlook LOOK_HAIR_COLOR, .@rand_color;
                BarberSayStyle 2;
                break;
            default:
                setlook LOOK_HAIR_COLOR, (@menu - 2);
                break;
        }
        .@menustr$ = "";
    } while (1);

    return;
}

function	script	BarberChangeGender	{
    mesn("Note");
    mes(b(l("Changing your gender will send you back to the character selection screen.")));
    next();

    mes(l("Please select the desired gender:"));
    menuint(
        rif(Gender == GENDER_FEMALE, "► ") + l("Gender female"), GENDER_FEMALE,
        rif(Gender == GENDER_MALE, "► ") + l("Gender male", 2), GENDER_MALE,
        rif(Gender == GENDER_HIDDEN, "► ") + l("Gender hidden"), GENDER_HIDDEN);

    if (Gender == @menuret) {
        return; // don't kick to char selection when not needed
    }

    // FIXME: when manaplus supports seamless changing for evol2, use a simple return;
    closedialog();
    close2();
    Gender = @menuret;
    close;
}

// THIS FUNCTION SHOULD BE USED ONLY AT REBIRTH
// Unless current game development design changes!
function	script	BarberChangeRace	{

    mes l("What's your race?");
    menuint
        get_race(GETRACE_FULL, KaizeiViro), KaizeiViro,
        get_race(GETRACE_FULL, ArgaesViro), ArgaesViro,
        get_race(GETRACE_FULL, TonoriViro), TonoriViro,
        get_race(GETRACE_FULL, CaveUkar), CaveUkar,
        get_race(GETRACE_FULL, MountainUkar), MountainUkar,
        get_race(GETRACE_FULL, SeaTritan), SeaTritan,
        get_race(GETRACE_FULL, LakeTritan), LakeTritan,
        rif(REBIRTH, get_race(GETRACE_FULL, LightRaijin)), LightRaijin,
        rif(REBIRTH, get_race(GETRACE_FULL, DarkRaijin)), DarkRaijin,
        rif(REBIRTH, get_race(GETRACE_FULL, FireKralog)), FireKralog,
        rif(REBIRTH, get_race(GETRACE_FULL, FrostKralog)), FrostKralog;

    mes "";
    // Something went *terribly* wrong
    if (@menuret >= LightRaijin && !REBIRTH) {
        channelmes("#irc", "Illegal operation at BarberChangeRace, sysadmin help required.");
        consolemes(CONSOLEMES_ERROR, "Account %d tried to change race to %d but rebirth is not set. Race not changed.", getcharid(3), @menuret);
        return;
    }

    // Change race and we're done
    //Class = @menuret;
    jobchange(@menuret); // STUPID idea, but imposed by Hercules
    return;
}