summaryrefslogtreecommitdiff
path: root/npc/034-3/gemini.txt
blob: 72c4707c3cf9a3a8374b78837f3a65b70d5778bc (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
// TMW2 scripts.
// Authors:
//    Jesusalva
// Description:
//    Gemini Sisters Quest - Outside the Building

034-3,23,50,0	script	#GeminiBack2	NPC_HIDDEN,0,0,{
    end;
OnTouch:
    if (instance_id() < 0 || getcharid(1) < 1) end;
    GeminiCheck(8);
    .@p=getcharid(1);
    warp "val2@"+.@p, 37, 25;
    end;
}

034-3,57,29,0	script	#GeminiDoor	NPC_HIDDEN,0,0,{
    end;

OnTouch:
    if (instance_id() < 0 || getcharid(1) < 1) end;
    GeminiCheck(8);
    .@p=getcharid(1);
    if ($@VALIA_STATUS[.@p] >= 9) {
        warp "val4@"+.@p, 43, 51;
        end;
    }
    slide 58, 34;
    percentheal -20, 0;
    dispbottom l("You are pushed back violently. There is probably some way to break this barrier.");
    end;
}

034-3,51,38,0	script	Engravings#Gemini	NPC_NO_SPRITE,{
    mes l("You can read some words engraved inside this rock, but some are erased by wind and time:");
    next;
    mes l("\".. can use this .. power..´. . .´. . . amplify a spell ..´.");
    mes l(" . ´´. Don't let .. spell power .´..´ . .. fade away ...");
    mes l("´ .Use lazurite stones ´..´. they will appear. ..´ .. drop them inside .. this circle.");
    mes l(". ´ power.. drains .. life..´. .´  focus . .not move at all´. .\"");
    next;
    mes l("Below this strange writing, you notice a word still deeply engraved in the stone:");
    next;
    mesq b("catalazuli");
    next;
    .@p=getcharid(1);
    mes l("... that looks like an incantation or something.");
    if (strcharinfo(0) != getpartyleader(.@p)) {
        mes l("I probably should let %s chant it.", getpartyleader(.@p));
        close;
    }
    next;
    mes l("I think this blue circle right here can be helpful to break the enchantment that blocks the door of the Inn.");
    next;
    mes l("Let's see how I can activate it...");
    mes l("But I should probably get inside it, first.");
    close;

OnChannel:
    if (instance_id() < 0 || getcharid(1) < 1) end;
    GeminiCheck(8);

    // Check location
    getmapxy(.@m$, .@x, .@y, 0);
    if (.@x < 52 ||
        .@x > 54 ||
        .@y < 37 ||
        .@y > 38) end;

    // Only party leader may proceed
    .@p=getcharid(1);
    if (strcharinfo(0) != getpartyleader(.@p)) {
        percentheal 0, -25;
        specialeffect(312, AREA, getcharid(3));
        dispbottom l("Argh! I assume I can't do this chant!");
        end;
    }

    // Bonus is based on int
    .@bonus = readparam2(bInt) / 25;
    // Unlike TMW's, all Lazurites show up at same place
    // ...
    // amount of initial magic power
    .@magic_power = 1811 + readparam2(bInt)*2;
    // Channelling required power depends on the base Int of the character
    .@magic_power_required = 5707 - 2*readparam2(bInt);
    // magic power loss depends also on Int. TMW uses 53, we use 21
    .@magic_power_loss = 21 - (((readparam2(bInt)+1)*2)/10);

    dispbottom l("Ok, let's stay focused now!");
    areamonster getmap(), 27, 20, 77, 47, strmobinfo(1, Forain), Forain, 1;
    // TODO: Loop
    debugmes "NPC: %s / %s (%d)", .name$, .extname$, instance_id();
    .aid=getcharid(3);
    .mp$=getmap();
    .power=.@magic_power;
    .state=0;
    .maxpw=.@magic_power_required;
    .mloss=.@magic_power_loss;
    initnpctimer;
    end;

OnTimer13000:
    initnpctimer; // Reset timer
    // Time to spawn monsters
    .@pc = getmapusers(.mp$);
    areamonster .mp$, 56, 30, 60, 31, "Guardian", Scar, 1+.@pc;
    areamonster .mp$, 27, 20, 77, 47, strmobinfo(1, Forain), Forain, 2;
    // Terranites only show up when doing multiplayer, based on number of players
    if (.@pc >= 2)
        areamonster .mp$, 56, 30, 60, 31, "Guardian", Terranite, (.@pc/2);
OnTimer10000:
OnTimer8000:
OnTimer6000:
OnTimer4000:
OnTimer2000:
    if (instance_id() < 0) end;

    if (!attachrid(.aid)) {
        npctalk "The caster ceased to exist!";
        stopnpctimer;
        end;
    }

    getmapxy(.@m$, .@x, .@y, 0, .aid);
    if (.@m$ != .mp$) {
        npctalk "The caster is gone!";
        stopnpctimer;
        end;
    }
    if (.@x < 52 ||
        .@x > 54 ||
        .@y < 37 ||
        .@y > 38) {
        npctalk "The caster left the power circle!";
        dispbottom l("The magic accumulated backfires at you!");
        heal -(.power), -(.power/2);
        stopnpctimer;
        end;
    }

    // Harm you
    //misceffect FX_CHANNELLING_RAISE;
    percentheal -4, -1;

    if (ispcdead()) {
        npctalk "The caster is dead!";
        stopnpctimer;
        end;
    }
    if (Sp <= 0) {
        npctalk "The caster ran out of mana!";
        stopnpctimer;
        end;
    }

    // Deplete power over time
    // But only if not doing solo
    if (getmapusers(.mp$) > 1 || .mloss < 0)
        .power -= .mloss;

    // Remove stones inside the circle
    .@cat=getareadropitem(.mp$, 52, 37, 54, 39, LazuriteShard, true) * 12;
    .@cbt=getareadropitem(.mp$, 52, 37, 54, 39, LazuriteCrystal, true) * 32;
    .@cct=getareadropitem(.mp$, 52, 37, 54, 39, LazuriteHeart, true) * 65;

    // Grant them POWER
    .power+=.@cat+.@cbt+.@cct;
    .@cur = 4 * .power / .maxpw; // Goes from 0 to 4

    // Check status and update
    if (.@cur < .status)
        npctalk "NOTICING a sudden power loss!";
    else if (.@cur > .status)
        npctalk "NOTICING an increase of power!";
    .status=.@cur;

    // Are we done?
    if (.power >= .maxpw) {
        npctalk "*the gate spell has been redefined*";
        if (getcharid(1) > 0) {
            $@VALIA_STATUS[getcharid(1)]=9;
            stopnpctimer;
            .power=0;
            .mloss=0;
            .maxpw=0;
            .state=0;
            .mp$="";
            .aid=0;
        }
        stopnpctimer;
        end;
    }
    detachrid();
    // Should we spawn items?
    .@t = (getnpctimer(0)+500) / 1000;
    // Item time!
    if (.@t == 6 ||
        .@t == 10) {
        .@i = 0;
        // More Shards than Crystals and Hearts
        freeloop(true);
        while (.@i < ((5-getmapusers(.mp$)) * 2 + 5)) {
            .@it=any(LazuriteShard, LazuriteShard, LazuriteShard,
                     LazuriteCrystal, LazuriteCrystal,
                     LazuriteHeart);
            makeitem(.@it, 1, .mp$, rand2(27, 77), rand2(20, 47));
            .@i += 1;
        }
        freeloop(false);
    }
    end;

OnTalkNearby:
    // not very obvious stuff by gumi
    .@no_nick$ = strip(substr($@p0$, getstrlen(strcharinfo(PC_NAME)) + 3, getstrlen($@p0$) - 1));
    .@message$ = strtoupper(.@no_nick$);
    if (.@message$ == "CATALAZULI") {
        goto OnChannel;
    }
    end;

OnInit:
OnInstanceInit:
    .distance=3;
    .pid=getnpcid();
    // For players
    .aid=0;
    .mp$="";
    .power=0;
    .state=0;
    .maxpw=0;
    .mloss=0;

    debugmes "Gemini Pattern %d", .pid;
    //defpattern(.pid, "^([Kk][Aa][Tt][Aa][Zz][Uu][Ll][Ii])$", "OnTalkNearby");
    defpattern(.pid, "^(.*)$", "OnTalkNearby");
    activatepset(.pid);
    end;
}