-
Notifications
You must be signed in to change notification settings - Fork 0
/
PNJpuertas_NG.h
353 lines (327 loc) · 12 KB
/
PNJpuertas_NG.h
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! PNJPUERTAS Una libreria para InformATE complementaria a PNJMovil
! para la codificación sencilla de puertas
! utilizables por los PNJs.
! Escrita por Jævius. <jaevius@teleline.es>
!
! Basada en una traducción y adaptación de la
! libreria DOORS de L. Ross Raszewski.<rraszews@skipjack.bluecrab.org>
!
! La documentación sobre el uso de la librería se incluyen en el
! archivo adjunto PNJPuertas.txt, dado su extensión.
#ifndef tras_abrir;
Property tras_abrir;
#endif;
#ifndef pnj_abrir;
Property pnj_abrir;
!Property additive pnj_abrir; ! ¿Por qué additive? (c) Alpha
#endif;
Constant DEJA_ALEATORIO = 0;
Constant DEJA_ABIERTO = 1;
Constant DEJA_CERRADO = 2;
Constant DEJA_CERRADO_CON = 3;
Constant NO_PUEDE_ABRIR = 4;
Class PnjPuerta
with
name_f 'puerta',
name_fp 'puertas',
interior 0, ! (c) Alpha
exterior 0, ! (c) Alpha
door_dir [;
if (parent(self) == self.ladoa) return self.dira;
else return self.dirb;
],
door_to [;
if (parent(self) == self.ladoa) return self.ladob;
else return self.ladoa;
],
ladoa 0,
dira 0,
ladob 0,
dirb 0,
found_in 0 0,
lado_cierre 0,
bloqueada false,
entra_o_sale [;
if (self.interior == 0 or parent(self)) return "entra";
else return "sale";
],
entrando_o_saliendo [;
if (self.interior == 0 or parent(self)) return "entrando";
else return "saliendo";
],
el_o_ella [
gna;
gna = GetGNAOfObject(self);
switch (gna) {
0, 6: print "él";
1, 7: print "ella";
3, 9: print "ellos";
4, 10: print "ellas";
}
],
pnj_abrir [ quien res x;
if (self has open) {
res = 0;
} else {
if (quien.tras_abrir == NO_PUEDE_ABRIR) {
if (TestScope(quien)) {
print "^", (Link_) quien, " quiere abrir ", (link) self,
", pero no puede.^";
} else {
if (TestScope(self)) {
print "^Se oyen ruidos al otro lado ", (link_del) self,
", como si algo intentara abrirla.^";
}
}
rfalse;
} else {
if (self hasnt locked) {
res = 7;
} else {
if (self provides with_key) {
if (self.with_key in quien) {
if (self.lado_cierre == 0 || quien in self.lado_cierre) {
res = 1;
} else {
res = 2;
}
} else {
if (self.lado_cierre == 0 || quien in self.lado_cierre) {
res = 3;
} else {
res = 4;
}
}
} else {
if (self.lado_cierre == 0 || quien in self.lado_cierre) {
res = 5;
} else {
res = 6;
}
}
}
}
}
if (self.bloqueada) {
switch (res) {
1: res = 8;
5: res = 9;
7: res = 10;
}
}
!****** YA TENEMOS EN RES CODIFICADO EL RESULTADO DEL MOVIMIENTO DEL PNJ
! EN RELACION CON LA PUERTA. Los códigos son:
! 0.- Puerta abierta.- Pnj pasa sin problema
! 1.- Puerta cerrada con llave y PNJ tienen la llave.- pasa sin problema
! 2.- " " " " " " ,pero no hay cerradura a este lado.- no pasa
! 3.- " " " " no tiene la llave. No pasa.
! 4.- " " " " " " " , además no hay cerradura aquí. No pasa.
! 5.- Puerta cerrada con pestillo y está al alcance del PNJ.- Pasa.
! 6.- " " " Y NO está al alcance pnj. No pasa.
! 7.- Puerta cerrada pero sin llave ni pestillo. Pasa.
! 8, 9 y 10 corresponden a 1, 5 y 7 (únicos casos en los que el
! pnj atravesaría la puerta abriendola), cuando ésta se ha bloqueado. No
! pasan.
!************* AHORA DESCRIBIMOS LA ACCION -SI SE VE EL PNJ O LA PUERTA...
if (TestScope(quien)) {
new_line;
switch (res) {
0: print (Link_el_) quien, " ", (string) self.entra_o_sale(), " por ",
(link_el) self, ".^";
1: print (Link_el_) quien, " abre con ", (a) self.with_key, " ",
(link_el) self, " y ", (string) self.entra_o_sale(), " por ",
(string) self.el_o_ella(), ".^";
2, 3, 4, 6: print (Link_el_) quien, " intenta abrir ", (link_el) self,
" pero parece cerrad", (o) self, ".^";
5: print (Link_el_) quien, " abre ", (link_el) self,
" accionando el pestillo, y ", (string) self.entra_o_sale(),
" por ", (string) self.el_o_ella(), ".^";
7: print (Link_el_) quien, " abre ", (link_el) self, " y ",
(string) self.entra_o_sale(), " por ",
(string) self.el_o_ella(), ".^";
8: print (Link_el_) quien, " intenta abrir con ", (a) self.with_key,
" ", (link_el) self, ", pero parece que algo l", (o) self,
" atranca.^";
9: print (Link_el_) quien, " acciona el pestillo ", (link_del) self,
" pero algo impide que l", (o) self, " abra.^";
10: print (Link_el_) quien, " intenta abrir ", (link_el) self,
" pero parece atascad", (o) self, " con algo.^";
}
} else {
if (TestScope(self)) {
new_line;
switch (res) {
0: print (Link_el_) quien, " ", (string) self.entra_o_sale(),
" por ", (link_el) self, ".^";
1: print "Oyes abrirse una cerradura, y ", (link_el) self,
" se abre ",
(string) self.entrando_o_saliendo(), " ", (link_el) quien,
".^";
2, 3, 4, 6, 8, 9, 10: print "Alguien intenta abrir ",
(link_el) self,
" sin conseguirlo.^";
5: print "Oyes descorrer un pestillo, y ", (link_el) self,
" se abre ", (string) self.entrando_o_saliendo(), " ",
(link_el) quien, ".^";
7: print (Link_el_) self, " se abre y ",
(string) self.entra_o_sale(), " ", (link_el) quien,
" por ", (string) self.el_o_ella(), ".^";
}
}
}
!******************* ESTADO DE LA PUERTA TRAS ABRIRLA **********************
! En función de la propiedad tras_abrir del PNJMovil...
if (res == 0 && self hasnt openable) rtrue;
! Si la puerta estaba abierta y no es abrible - no es necesario ejecutar
! codigo de cierre.
! Esto permite crear entradas como arcos, dinteles, etc, sin puerta
! propiamente dicha.
x = 0;
if (quien provides tras_abrir) x = quien.tras_abrir;
if (x == DEJA_ALEATORIO) x = random(3);
! PRIMERO IMPRIMIMOS EL MENSAJE SI LA ACCION ES VISIBLE POR EL JUGADOR
if (TestScope(self) || TestScope(quien)) {
if (x == DEJA_CERRADO && res == 0 or 1 or 5 or 7) {
new_line;
print (Link_el_) quien, " cierra ", (link_el) self, ".^";
}
if (x == DEJA_CERRADO_CON && res == 0 or 1 or 5 or 7) {
new_line;
print (Link_el_) quien, " cierra ", (link_el) self;
if (self.lado_cierre == parent(quien)) {
print ".^";
} else {
switch (res) {
0, 7: if (self provides with_key) {
if (self.with_key in quien) print " con llave.^";
else print".^";
} else {
if (self has lockable) print " echándole el pestillo.^";
else print ".^";
}
1: print " con llave.^";
5: print " echándole el pestillo.^";
} ! fin de switch
}
} ! fin de if (x == DEJA_CERRADO_CON...
} ! fin de if (PruebaDeAlcance....
! AHORA EJECUTAMOS EL RESULTADO DE TODO EL PROCESO *************************
switch (res) {
0: if (x == DEJA_CERRADO or DEJA_CERRADO_CON) give self ~open;
if (x == DEJA_CERRADO_CON &&
self.lado_cierre ~= parent(quien)) {
if (self provides with_key) {
if (self.with_key in quien) give self locked;
else rtrue;
} else {
if (self has lockable) give self locked;
}
}
rtrue;
1, 5: if (x == DEJA_ABIERTO or DEJA_CERRADO) give self ~locked;
if (x == DEJA_ABIERTO) give self open;
if (x == DEJA_CERRADO_CON &&
self.lado_cierre ~= 0) give self ~locked;
rtrue;
7: if (x == DEJA_ABIERTO) give self open;
if (x == DEJA_CERRADO_CON && self.lado_cierre ~= parent(quien)) {
if (self provides with_key) {
if (self.with_key in quien) give self locked;
else rtrue;
} else {
if (self has lockable) give self locked;
}
}
rtrue;
default:
rfalse;
}
],
before [;
Open, Close:
if (self.bloqueada) {
print "^Algo bloquea ", (link_el) self, " impidiendo que l", (o) self;
if (action == ##Open) " abras.";
else " cierres.";
}
Open:
if (self provides with_key) {
rfalse;
} else {
if (self has lockable && self has locked) {
"^Está cerrad", (o) self, " con un pestillo.^";
}
}
! Corrige un defecto de la libreria.- en puertas cerradas con pestillo,
! al intentar abrirlas te informaba que estaban cerradas con llave.
! (supongo que un problema de traduccion (...lock)
Lock, Unlock:
if (self.lado_cierre == 0 or location) {
rfalse;
} else {
if (self provides with_key) {
"No hay cerradura a este lado ", (link_del) self, ".";
}
"No existe pestillo a este lado ", (link_del) self, ".";
}
! El lado_cierre afecta tanto a los Pnjs como al jugador
Examine:
if (self provides description) {
PrintOrRun(self, description, 1);
print " ";
}
! else new_line;
if (self.lado_cierre == 0 or location) {
if (self provides with_key) {
print (Link_el_) self,
" puede abrirse y cerrarse desde aquí con una llave.^";
} else {
if (self has lockable) {
print (Link_el_) self,
" puede abrirse y cerrarse desde aquí con un pestillo.^";
}
}
}
if (self has openable) {
if (self has open) "Ahora está abiert", (o) self, ".";
else "Está cerrad", (o) self, "."; ! ^";
}
rtrue;
],
each_turn [
o;
Open, Close:
if (noun ofclass PnjPuerta) {
LimpiarPropagacion();
objectloop (o ofclass Ruido) {
if (o.jugador_oye()) {
if (o notin location && o hasnt absent) move o to location;
TocaDesde(o, true);
}
}
}
],
has
door static;
[ IniciarPuertas o i j;
objectloop (j ofclass PnjPuerta) {
objectloop (o in compass) {
i = o.door_dir;
if (j provides i) {
j.ladoa = j.i;
j.dirb = i;
}
}
objectloop (o in compass) {
i = o.door_dir;
if ((j provides i) && (j.dirb ~= i)) {
j.ladob = j.i;
j.dira = i;
}
}
j.&found_in-->0 = j.ladoa;
j.&found_in-->1 = j.ladob;
}
];