summaryrefslogtreecommitdiff
path: root/npc/081-3/logic.txt
blob: 42681e43d641c9b3609361c862a72bf50acc422a (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
// TMW Script.
// Author:
//    Jesusalva
// Notes:
//    Christmas 2021 - Boss Chamber #1
// FIXME: What if players *fail* this? e.g. die

081-3,44,36,0	script	Pentagram#Xmas21A	NPC424,{
    .@id = X21ID();
    if ($@XMAS21_BC1[.@id] == X21BC1_ON) end;
    .@n$ = instance_npcname("Pentagram#Xmas21A");
    .@cl = X21BC1_CLEAR();

    mesn;
    mesq l("Should we break the Pentagram?");
    next;
    select
        l("I'm not ready yet."),
        l("Bring it on!"),
        rif(.@cl, l("Make it harder!")),
        rif(.@cl, l("Make it a nightmare!")),
        rif(.@cl, l("Kill me semi-instantly!"));
    mes "";
    closeclientdialog;
    if (@menu == 1 || 'LOCKD) {
        close;
    }

    'LOCKD = true;
    'BC1LV = @menu - 1;
    @BC1ME = getcharid(3);
    .@mg = monster(getmap(), 44, 36, "Der Schneemann", SnowmanBoss, 1, "Pentagram#Xmas21A::OnFin");

    // Prepare the difficulty settings
    // Each difficulty level doubles the nº of players difficulty setting
    // Can go up to 12 * 4 = 48, but we use 16 as the theoretical max
    .@df = max(1, getmapusers(getmap()) * ('BC1LV * 2));
    .@lv = BaseLevel;

    setunitdata(.@mg, UDT_MAXHP, 5000 + (.@lv * 150) + (1200 * .@df));
    setunitdata(.@mg, UDT_HP,    5000 + (.@lv * 150) + (1200 * .@df));

    setunitdata(.@mg, UDT_ADELAY, 2200 - max(1200, 75 * .@df));
    setunitdata(.@mg, UDT_ATKRANGE, 3);

    /*
    setunitdata(.@mg, UDT_ATKMIN,   .@lv*4+.@df*3);
    setunitdata(.@mg, UDT_ATKMAX,   .@lv*4+.@df*3);
    */
    setunitdata(.@mg, UDT_ATKMIN,   (.@lv+.@df)*5);
    setunitdata(.@mg, UDT_ATKMAX,   (.@lv+.@df)*6);
    setunitdata(.@mg, UDT_DEF,      min(50+.@df, 98));
    setunitdata(.@mg, UDT_MDEF,     min(50+.@df, 98));
    setunitdata(.@mg, UDT_HIT,      9999);

    // Destroy the instance only after half hour has passed
    instance_set_timeout(1800, 1800);
    initnpctimer;
    setnpctimer(39000);
    disablenpc(.@n$);
    $@XMAS21_BC1[.@id] = X21BC1_ON;
    .BC1ID = .@mg;
    close;

OnFin:
    if (!playerattached()) {
        consolemes(CONSOLEMES_ERROR, "Player not attached after Christmas 2021 victory! Script aborted!");
        end;
    }
    killmonsterall(getmap());
    getexp 10000, 0;
    getitem XmasTicket, 1 + 'BC1LV;
    maptimer(getmap(), 10, "Pentagram#Xmas21A::OnFlush");
    end;

// Distribute experience and handle quest progress
OnFlush:
    getexp 5000, 0;
    if (@BC1ME > 0) {
        if (!X21BC1_CLEAR()) {
            dispbottom l("Whatever that guardian was, the path is now clear, and the gate, open.");
            X21BC1_DOCLEAR();
        }
    }
    @BC1ME = 0;
    .@id = X21ID();
    $@XMAS21_BC1[.@id] = X21BC1_OFF;
    getitem XmasTicket, X21_TICKET_SUPPORT + ('BC1LV / 2);
    end;

// Pseudo-Magic
OnTimer37000:
    if (getunittype(.BC1ID) < 0) {
        stopnpctimer;
        end;
    }

    .CYCLE += 1;
    .@m$=getmapinfo(MAPINFO_NAME); // We could use .map$ too
    areamonster(.@m$, 31, 23, 58, 50, "Snowballz", Snowman, 1+getmapusers(.@m$));

    if (.CYCLE % 2 != 0) {
        initnpctimer;
        end;
    }

    // The boss special skill depends on its health
    .@hp = 100 * getunitdata(.BC1ID, UDT_HP) / getunitdata(.BC1ID, UDT_MAXHP);

    // HP > 70%, just some warm-up
    if (.@hp > 70) {
        unittalk(.BC1ID, "Blizzard!");
        rectharm(.BC1ID, 6, 6, rand2(250), HARM_MAGI, Ele_Neutral, "filter_always", BL_PC);

    // HP < 70%, cripple half the attackers
    } else if (.@hp > 40) {
        .@sc = any(SC_SILENCE, SC_BLIND);
        if (.@sc == SC_SILENCE)
            unittalk(.BC1ID, "Silence!");
        else
            unittalk(.BC1ID, "Blind!");
        areasc2(.@m$, 44, 36, 14, rand2(15000), BL_PC, .@sc);
        rectharm(.BC1ID, 5, 5, rand2(50), HARM_MAGI, Ele_Neutral, "filter_always", BL_PC);

    // HP < 40%, cause great damage
    } else if (.@hp > 15) {
        unittalk(.BC1ID, "Greater Blizzard!");
        rectharm(.BC1ID, 8, 8, 100+rand2(250), HARM_MAGI, Ele_Neutral, "filter_always", BL_PC);

    // HP < 15%, use more dangerous conditions
    } else {
        .@sc = any(SC_POISON, SC_CURSE);
        if (.@sc == SC_SILENCE)
            unittalk(.BC1ID, "Poison!");
        else
            unittalk(.BC1ID, "Curse!");
        areasc2(.@m$, 44, 36, 14, rand2(15000), BL_PC, .@sc);
        rectharm(.BC1ID, 5, 5, rand2(100), HARM_MAGI, Ele_Neutral, "filter_always", BL_PC);
    }

    // Repeat forever
    initnpctimer;
    end;

OnClean:
    enablenpc(.name$);
    killmonsterall(getmapinfo(MAPINFO_NAME));
OnInstanceInit:
    'LOCKD = false;
OnInit:
    .distance=2;
    .BC1ID = 0;
    .CYCLE = 0;
    end;
}


081-3,44,22,0	script	#0813Nexit	NPC_HIDDEN,0,0,{
    end;
OnTouch:
    if (!isChristmas21()) end;
    if (!X21BC1_CLEAR()) {
        dispbottom l("A strong magic barrier prevents me from using this exit.");
        end;
    }
    .@id = X21ID();
    if ($@XMAS21_BC1[.@id] == X21BC1_ON) end;
    if ($@XMAS21_BC1[.@id] == X21BC1_OFF) {
        mesn l("Northern Lights");
        mes l("Past this gate, beyond the existential frontier, I can see the Northern Lights.");
        mes l("Should we walk toward it?");
        next;
        select
            l("Yes"),
            l("Not yet"),
            l("[Run away]");
        mes "";
        if (@menu == 1) {
            /* We need to determine if instance exists and is needed */
            X21INIT();

            .@mapn$="0803@"+X21ID2();
            warp .@mapn$, 83, 154;
        }
        // NOTE: Right now, anyone can do so?
        else if (@menu == 3) {
            enablenpc(instance_npcname("Pentagram#Xmas21A"));
            warp "081-2", 90, 21;
            'LOCKD = false;
        }
        closeclientdialog;
        close;
    }
    end;
}

081-3,44,50,0	script	#0813Sexit	NPC_HIDDEN,0,0,{
    end;
OnTouch:
    .@id = X21ID();
    if ($@XMAS21_BC1[.@id] == X21BC1_ON) end;
    X21INIT();
    .@mapn$="0812@"+X21ID2();
    warp .@mapn$, 90, 21;
    end;
}