summaryrefslogtreecommitdiff
path: root/npc/009-4/barriers.txt
blob: 0185a2fdfc120a7abfd976637c82430c51e8393a (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
//# see detailed description at orum.txt
function	script	GetBarrierColor	{
	if (@Barrier < 0 || @Barrier > 2) goto L_Error;

	set @Mask, 15;
	set @Shift, 4 * @Barrier;
	set @BarrierColor, (OrumQuestBarrier >> @Shift) & @Mask;
	return;

L_Error:
	mes "Barrier number is out of range.";
	close;
}

function	script	SetBarrierColor	{
	if (@Barrier < 0 || @Barrier > 2) goto L_Error;
	if (@Color < 0 || @Color > 12) goto L_Error2;

	set @Mask, (15 << (4 * @Barrier));
	set OrumQuestBarrier, (OrumQuestBarrier & (~(@Mask))) | @Color << (4 * @Barrier);
	return;

L_Error:
	mes "Barrier number is out of range.";
	close;

L_Error2:
	mes "Barrier color is out of range.";
	close;
}


// Starting Barrier / Quest Entrance
009-4.gat,37,120,0	script	#OrumCaveStartBarrier	0,1,0,{

	if (OrumQuest >= 3) close;
	if (OrumQuest == 2) goto L_Started;

	warp "009-4.gat", 37, 118;
	mes "As you try to pass, two torches begin to flare and push you back. They seem to form some kind of barrier..";
	close;

L_Started:
	message strcharinfo(0), "The torches dim as you approach, granting you passage.";
	set OrumQuest, 3;
	close;
}

// First Barrier
009-4.gat,57,29,0	script	#OrumCaveFirstBarrier	0,1,0,{

	if (OrumQuest >= 5) close;

	message strcharinfo(0), "Nothing seems to happen as you enter this room.. The barrier must need both of its torches to function properly..";
	set OrumQuest, 5;
	close;
}

// Second Barrier
009-4.gat,61,54,0	script	#OrumCaveSecondBarrier	0,1,0,{

	if (OrumQuest == 3) set OrumQuest, 4;

	set @Barrier, 0;
	callfunc("GetBarrierColor");
	set @Torch, 0;
	callfunc("GetTorchColor");
	if (OrumQuest > 7 && @TorchColor == @BarrierColor) goto L_Allow_Second_Passage;

	warp "009-4.gat", 61, 56;
	mes "As you try to pass, the torches begin to flare and push you back. Perhaps there's a way to get past it..";
	mes "";
	setarray @colors$,"transparent","red","dark orange","orange","light orange","yellow","light green","green","dark green","blue","dark purple","purple","light purple";
	mes "Looking closely between the two torches you can see the barrier has a " + @colors$[@BarrierColor] + " tint to it..";
	close;

L_Allow_Second_Passage:
	if (OrumQuest < 9) goto L_Advance_Quest;
	close;

L_Advance_Quest:
	message strcharinfo(0), "The torches dim as you enter like the first. You must be on the right trail..";
	set OrumQuest, 9;
	close;
}

// Third Barrier
009-4.gat,24,66,0	script	#OrumCaveThirdBarrier	0,1,0,{

	if (OrumQuest == 3) set OrumQuest, 4;

	set @Barrier, 1;
	callfunc("GetBarrierColor");

	set @Torch, 0;
	callfunc("GetTorchColor");
	set @Torch1Color, @TorchColor;

	set @Torch, 1;
	callfunc("GetTorchColor");
	set @Torch2Color, @TorchColor;

	set @firstColor, @BarrierColor - 2;
	set @secondColor, @BarrierColor + 2;
	if (@firstColor < 1) set @firstColor, 12;
	if (@secondColor > 12) set @secondColor, 1;

	if (OrumQuest > 8 && @Torch1Color == @firstColor && @Torch2Color == @secondColor)
		goto L_Allow_Third_Passage;
	if (OrumQuest > 8 && @Torch2Color == @firstColor && @Torch1Color == @secondColor)
		goto L_Allow_Third_Passage;

	warp "009-4.gat", 24, 64;
	mes "As you try to pass, the torches begin to flare and push you back. Perhaps there is a way to get past it..";
	mes "";
	setarray @colors$,"transparent","red","dark orange","orange","light orange","yellow","light green","green","dark green","blue","dark purple","purple","light purple";
	mes "Looking closely between the two torches you can see the barrier has a " + @colors$[@BarrierColor] + " tint to it..";
	close;

L_Allow_Third_Passage:
if (OrumQuest < 10) goto L_Advance_Quest;
	close;

L_Advance_Quest:
	set OrumQuest, 10;
	close;
}

// Ending Barrier
009-4.gat,48,38,0	script	#OrumCaveEndBarrier	0,1,0,{

	if (OrumQuest >= 11) close;
	if (OrumQuest == 3) set OrumQuest, 4;

	set @Barrier, 2;
	callfunc("GetBarrierColor");

	if (OrumQuest < 10) goto L_Deny_Final_Passage;

	set @Torch, 0;
	callfunc("GetTorchColor");
	set @Torch1Color, @TorchColor;

	set @Torch, 1;
	callfunc("GetTorchColor");
	set @Torch2Color, @TorchColor;

	set @Torch, 2;
	callfunc("GetTorchColor");
	set @Torch3Color, @TorchColor;

	// Extract the secondary color
	set @secondary, @BarrierColor - 1;
	if (@secondary != 3 && @secondary != 7 && @secondary != 11)
		set @secondary, @BarrierColor + 1;

	// Make sure it's in bounds
	if (@secondary > 12) set @secondary, @secondary - 12;
	if (@secondary < 1) set @secondary, @secondary + 12;

	// Extract first 2 required colors
	set @firstColor, @secondary - 2;
	set @secondColor, @secondary + 2;
	if (@firstColor > 12) set @firstColor, @firstColor - 12;
	if (@firstColor < 1) set @firstColor, @firstColor + 12;
	if (@secondColor > 12) set @secondColor, @secondColor - 12;
	if (@secondColor < 1) set @secondColor, @secondColor + 12;

	set @thirdColor, 12;
	set @offsetOne, @BarrierColor + 1;
	set @offsetTwo, @BarrierColor - 1;

	// Make sure they in bounds
	if (@offsetOne > 12) set @offsetOne, @offsetOne - 12;
	if (@offsetOne < 1) set @offsetOne, @offsetOne + 12;
	if (@offsetTwo > 12) set @offsetTwo, @offsetTwo - 12;
	if (@offsetTwo < 1) set @offsetTwo, @offsetTwo + 12;

	// Extract third needed color
	if (@secondary == @offsetOne)
		set @thirdColor, @firstColor;
	if (@secondary == @offsetTwo)
		set @thirdColor, @secondColor;

	set @firstDone, 0;
	set @secondDone, 0;
	set @thirdDone, 0;

	if (@firstDone == 0 && @secondDone != 1 && @thirdDone != 1 && @Torch1Color == @firstColor)
		set @firstDone, 1;
	if (@firstDone != 1 && @secondDone == 0 && @thirdDone != 1 && @Torch1Color == @secondColor)
		set @secondDone, 1;
	if (@firstDone != 1 && @secondDone != 1 && @thirdDone == 0 && @Torch1Color == @thirdColor)
		set @thirdDone, 1;

	if (@firstDone == 0 && @secondDone != 2 && @thirdDone != 2 && @Torch2Color == @firstColor)
		set @firstDone, 2;
	if (@firstDone != 2 && @secondDone == 0 && @thirdDone != 2 && @Torch2Color == @secondColor)
		set @secondDone, 2;
	if (@firstDone != 2 && @secondDone != 2 && @thirdDone == 0 && @Torch2Color == @thirdColor)
		set @thirdDone, 2;

	if (@firstDone == 0 && @secondDone != 3 && @thirdDone != 3 && @Torch3Color == @firstColor)
		set @firstDone, 3;
	if (@firstDone != 3 && @secondDone == 0 && @thirdDone != 3 && @Torch3Color == @secondColor)
		set @secondDone, 3;
	if (@firstDone != 3 && @secondDone != 3 && @thirdDone == 0 && @Torch3Color == @thirdColor)
		set @thirdDone, 3;

	if (@firstDone != 0 && @secondDone != 0 && @thirdDone != 0) goto L_Allow_Final_Passage;
	goto L_Deny_Final_Passage;

L_Deny_Final_Passage:
	warp "009-4.gat", 48, 36;
	mes "As you try to pass, the torches begin to flare and push you back. Perhaps there is a way to get past it..";
	mes "";
	setarray @colors$,"transparent","red","dark orange","orange","light orange","yellow","light green","green","dark green","blue","dark purple","purple","light purple";
	mes "Looking closely between the two torches you can see the barrier has a " + @colors$[@BarrierColor] + " tint to it..";
	close;

L_Allow_Final_Passage:
	if (OrumQuest < 11) goto L_Advance_Quest;
	close;

L_Advance_Quest:
	message strcharinfo(0), "The torches dim as you enter. At last you finally have access!";
	set OrumQuest, 11;
	close;
}