| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include <assert.h> |
| 20 |
#include <ctype.h> |
| 21 |
#include <stdio.h> |
| 22 |
#include <limits.h> |
| 23 |
|
| 24 |
#include "agility.h" |
| 25 |
#include "interp.h" |
| 26 |
#include "exec.h" |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
void v_look() |
| 35 |
{ |
| 36 |
do_look=1; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
static void v_go(int dir) |
| 41 |
|
| 42 |
{ |
| 43 |
int newloc, tmploc; |
| 44 |
int i; |
| 45 |
|
| 46 |
|
| 47 |
dir--; |
| 48 |
|
| 49 |
tmploc=loc; |
| 50 |
newloc=room[loc].path[dir]; |
| 51 |
if (newloc>exitmsg_base) |
| 52 |
{ msgout(newloc-exitmsg_base,1); |
| 53 |
return;} |
| 54 |
if (newloc<0) { |
| 55 |
int v0; |
| 56 |
|
| 57 |
v0=verb_code(-newloc); |
| 58 |
if (v0==0) { |
| 59 |
if (!PURE_ERROR) |
| 60 |
writeln("GAME ERROR: Invalid verb."); |
| 61 |
return; |
| 62 |
} |
| 63 |
clear_stack(); |
| 64 |
(void)scan_metacommand(0,v0,0,0,0,NULL); |
| 65 |
return; |
| 66 |
} |
| 67 |
if (newloc<first_room) { |
| 68 |
if (dir==12) |
| 69 |
sysmsg(182,"Nothing happens."); |
| 70 |
else if (dir==10) |
| 71 |
sysmsg(197,"$You$ can't enter anything here."); |
| 72 |
else if (dir==11) |
| 73 |
sysmsg(198,"$You're$ not inside anything that $you$ can exit."); |
| 74 |
else |
| 75 |
sysmsg(13,"$You$ can't go that way."); |
| 76 |
return; |
| 77 |
} |
| 78 |
if (newloc>maxroom) { |
| 79 |
if (!PURE_ERROR) |
| 80 |
writeln("GAME ERROR: Invalid room number."); |
| 81 |
return;} |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
if (dir!=12 && (PURE_HOSTILE || newloc!=oldloc+first_room)) |
| 88 |
creatloop(i) |
| 89 |
if (creature[i].location==loc+first_room && |
| 90 |
creature[i].hostile) { |
| 91 |
parse_rec tmpcreat; |
| 92 |
curr_creat_rec=&tmpcreat; |
| 93 |
make_parserec(i+first_creat,&tmpcreat); |
| 94 |
sysmsg(14,"$The_c$$c_name$ blocks $your$ way."); |
| 95 |
curr_creat_rec=NULL; |
| 96 |
return; |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
goto_room(newloc-first_room); |
| 101 |
if (dir!=12 && newloc!=tmploc+first_room) |
| 102 |
oldloc=tmploc; |
| 103 |
if (dir==12 && special_ptr[loc].size>0) |
| 104 |
|
| 105 |
runptr(loc,special_ptr,"INTERNAL ERROR: Invalid special ptr",0,NULL,NULL); |
| 106 |
|
| 107 |
if (tmploc==loc && dir==12) |
| 108 |
do_look=0; |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
static void v_noun(int vc,parse_rec *nounrec) |
| 115 |
|
| 116 |
{ |
| 117 |
int dobj; |
| 118 |
|
| 119 |
dobj=p_obj(nounrec); |
| 120 |
|
| 121 |
if (vc==0 && !it_pushable(dobj)) { |
| 122 |
int msgnum; |
| 123 |
if (!tcreat(dobj)) msgnum=172; |
| 124 |
else if (creature[dobj-first_creat].gender==0) |
| 125 |
if (creature[dobj-first_creat].hostile) msgnum=167; |
| 126 |
else msgnum=168; |
| 127 |
else |
| 128 |
if (creature[dobj-first_creat].hostile) msgnum=169; |
| 129 |
else msgnum=170; |
| 130 |
sysmsgd(msgnum,"$You$ can't $verb$ $the_n$$noun$.",nounrec); |
| 131 |
return; |
| 132 |
} |
| 133 |
if (vc==1 && !it_pullable(dobj)) { |
| 134 |
sysmsgd(tcreat(dobj)?173:175,"$You$ can't $verb$ $the_n$$noun$.", |
| 135 |
nounrec); |
| 136 |
return; |
| 137 |
} |
| 138 |
if (vc==2 && !it_turnable(dobj)) { |
| 139 |
sysmsgd(tcreat(dobj)?164:166,"$You$ can't $verb$ $the_n$$noun$.", |
| 140 |
nounrec); |
| 141 |
return; |
| 142 |
} |
| 143 |
if (vc==3 && !it_playable(dobj)) { |
| 144 |
sysmsgd(tcreat(dobj)?176:178,"$You$ can't $verb$ $the_n$$noun$.", |
| 145 |
nounrec); |
| 146 |
return; |
| 147 |
} |
| 148 |
if (matchclass(dobj,room[loc].key)) { |
| 149 |
v_go(13); |
| 150 |
return; |
| 151 |
} |
| 152 |
if (vc==4) { |
| 153 |
sysmsgd(tcreat(dobj)?180:181,"Nothing happens.",nounrec); |
| 154 |
return; |
| 155 |
} |
| 156 |
|
| 157 |
if (vc==0) |
| 158 |
runptr(dobj-first_noun,push_ptr, |
| 159 |
"$You$ $verb$ $the_n$$noun$ for a while, but nothing happens.", |
| 160 |
171,nounrec,NULL); |
| 161 |
if (vc==1) |
| 162 |
runptr(dobj-first_noun,pull_ptr, |
| 163 |
"$You$ $verb$ $the_n$$noun$ a bit, but nothing happens.",174, |
| 164 |
nounrec,NULL); |
| 165 |
if (vc==2) |
| 166 |
runptr(dobj-first_noun,turn_ptr, |
| 167 |
"$You$ $verb$ $the_n$$noun$, but nothing happens.",165, |
| 168 |
nounrec,NULL); |
| 169 |
if (vc==3) |
| 170 |
runptr(dobj-first_noun,play_ptr, |
| 171 |
"$You$ $verb$ $the_n$$noun$ for a bit, but nothing happens.",177, |
| 172 |
nounrec,NULL); |
| 173 |
} |
| 174 |
|
| 175 |
static void v_talk(int vc,parse_rec *nounrec,parse_rec *objrec) |
| 176 |
|
| 177 |
{ |
| 178 |
int dobj,iobj; |
| 179 |
|
| 180 |
dobj=p_obj(nounrec); |
| 181 |
iobj=p_obj(objrec); |
| 182 |
|
| 183 |
if (nounrec->info==D_END || nounrec->info==D_AND) |
| 184 |
{alt_sysmsg(211,"Who $are$ $you$ addressing?",nounrec,objrec);return;} |
| 185 |
if (!genvisible(nounrec)) |
| 186 |
{alt_sysmsg(212,"Who $are$ $you$ addressing?",nounrec,objrec);return;} |
| 187 |
if (!tcreat(dobj)) |
| 188 |
{alt_sysmsg(vc?161:156,"That isn't animate.",nounrec,objrec);return;} |
| 189 |
if (vc==0) |
| 190 |
runptr(dobj-first_creat, |
| 191 |
talk_ptr,"$Your$ conversational gambit is ignored.", |
| 192 |
creature[dobj-first_creat].gender==0 ? 157 : (iobj==0?159:158), |
| 193 |
nounrec,objrec); |
| 194 |
if (vc==1) |
| 195 |
runptr(dobj-first_creat,ask_ptr,"$You$ get no answer.", |
| 196 |
iobj==0?162:163,nounrec,objrec); |
| 197 |
} |
| 198 |
|
| 199 |
static void v_examine(parse_rec *nounrec) |
| 200 |
{ |
| 201 |
if (!islit()) { |
| 202 |
sysmsgd( room[loc].light==1?19:20,"It's too dark to see anything.", |
| 203 |
nounrec); |
| 204 |
} |
| 205 |
it_describe(nounrec->obj); |
| 206 |
} |
| 207 |
|
| 208 |
static void v_view(parse_rec *nounrec) |
| 209 |
{ |
| 210 |
int i; |
| 211 |
int dobj; |
| 212 |
dobj=p_obj(nounrec); |
| 213 |
|
| 214 |
if (tnoun(dobj) && noun[dobj-first_noun].pict!=0) |
| 215 |
pictcmd(1,pictable[noun[dobj-first_noun].pict-1]); |
| 216 |
else if (tcreat(dobj) && creature[dobj-first_creat].pict!=0) |
| 217 |
pictcmd(1,pictable[creature[dobj-first_creat].pict-1]); |
| 218 |
else if (dobj==-ext_code[wscene] && room[loc].pict!=0) |
| 219 |
|
| 220 |
pictcmd(1,pictable[room[loc].pict-1]); |
| 221 |
else { |
| 222 |
if (dobj<0) |
| 223 |
for(i=0;i<maxpix;i++) |
| 224 |
if (dobj==-pix_name[i] && |
| 225 |
(room[loc].PIX_bits & (1L<<i) ) ) |
| 226 |
{pictcmd(2,i);return;} |
| 227 |
sysmsgd(217,"That can't be VIEWed here.",nounrec); |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
|
| 232 |
static void v_read(parse_rec *nounrec) |
| 233 |
{ |
| 234 |
int dobj; |
| 235 |
dobj=p_obj(nounrec); |
| 236 |
|
| 237 |
if (!tnoun(dobj) || !noun[dobj-first_noun].readable) { |
| 238 |
sysmsg(134, |
| 239 |
"$You$ can't read $the_n$$noun$, " |
| 240 |
"so instead $you$ just examine $n_indir$."); |
| 241 |
it_describe(dobj); |
| 242 |
return;} |
| 243 |
if (text_ptr[dobj-first_noun].size>0) |
| 244 |
runptr(dobj-first_noun,text_ptr, |
| 245 |
"INTERNAL ERROR: Invalid read pointer",0,NULL,NULL); |
| 246 |
else |
| 247 |
runptr(dobj-first_noun,noun_ptr,"$You$ learn nothing new.", |
| 248 |
193,nounrec,NULL); |
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
static void v_eat(int vc,parse_rec *nounrec) |
| 253 |
{ |
| 254 |
int dobj; |
| 255 |
dobj=p_obj(nounrec); |
| 256 |
|
| 257 |
if (!tnoun(dobj)) |
| 258 |
{sysmsgd(124,"That can't be consumed.",nounrec);return;} |
| 259 |
if (vc==0 && !noun[dobj-first_noun].edible) |
| 260 |
{sysmsgd(124,"$You$ can't eat that.",nounrec);return;} |
| 261 |
if (vc==1 && !noun[dobj-first_noun].drinkable) |
| 262 |
{sysmsgd(127,"$You$ can't drink that.",nounrec);return;} |
| 263 |
|
| 264 |
sysmsgd(128,"$You$ $verb$ $the_n$$adjective$ $noun$.",nounrec); |
| 265 |
|
| 266 |
if (noun[dobj-first_noun].movable) it_destroy(dobj); |
| 267 |
if (noun[dobj-first_noun].poisonous) { |
| 268 |
sysmsgd(129,"Unfortunatly, $n_pro$ $n_was$ poisonous.",nounrec); |
| 269 |
deadflag=1; |
| 270 |
} |
| 271 |
} |
| 272 |
|
| 273 |
|
| 274 |
static int can_wear(parse_rec *objrec) |
| 275 |
|
| 276 |
{ |
| 277 |
static char *errs[]={ |
| 278 |
"$The_n$$noun$ $n_is$ far too heavy to wear.", |
| 279 |
"$You're$ already loaded down with too much weight as it is." |
| 280 |
"$The_n$$noun$ $n_is$ too big and bulky to wear.", |
| 281 |
"$You're$ wearing too much to also wear $the_n$$noun$."}; |
| 282 |
int n; |
| 283 |
|
| 284 |
if (!it_canmove(objrec->obj)) { |
| 285 |
sysmsgd(202,"$You$ can't move $the_n$$noun$.",objrec); |
| 286 |
} |
| 287 |
n=check_fit(objrec->obj,1000); |
| 288 |
if (n==FIT_OK ) return 1; |
| 289 |
sysmsgd(37+n,errs[n-1],objrec); |
| 290 |
return 0; |
| 291 |
} |
| 292 |
|
| 293 |
|
| 294 |
static int can_carry(parse_rec *objrec) |
| 295 |
|
| 296 |
{ |
| 297 |
static char *errs[]={ |
| 298 |
"$The_n$$noun$ $n_is$ far too heavy to carry.", |
| 299 |
"$You're$ already carrying too much weight as it is.", |
| 300 |
"$The_n$$noun$ $n_is$ too big and bulky to pick up.", |
| 301 |
"$You're$ carrying too much to also carry $the_n$$noun$."}; |
| 302 |
int n; |
| 303 |
|
| 304 |
n=check_fit(objrec->obj,1); |
| 305 |
if (n==FIT_OK) return 1; |
| 306 |
sysmsgd(30+n-1,errs[n-1],objrec); |
| 307 |
return 0; |
| 308 |
} |
| 309 |
|
| 310 |
static int v_get(parse_rec *objrec) |
| 311 |
{ |
| 312 |
int cnt,i; |
| 313 |
int obj; |
| 314 |
|
| 315 |
obj=objrec->obj; |
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
if (!PURE_GETHOSTILE) |
| 320 |
creatloop(i) |
| 321 |
if (creature[i].location==loc+first_room && |
| 322 |
creature[i].hostile) { |
| 323 |
parse_rec tmpcreat; |
| 324 |
make_parserec(i+first_creat,&tmpcreat); |
| 325 |
curr_creat_rec=&tmpcreat; |
| 326 |
sysmsgd(14,"$The_c$$c_name$ blocks $your$ way.",objrec); |
| 327 |
return 0; |
| 328 |
} |
| 329 |
|
| 330 |
if (objrec->info==D_ALL) { |
| 331 |
cnt=0; |
| 332 |
nounloop(i) |
| 333 |
if (noun[i].location==loc+first_room && noun[i].movable) { |
| 334 |
|
| 335 |
parse_rec tmpnoun; |
| 336 |
make_parserec(i+first_noun,&tmpnoun); |
| 337 |
if (can_carry(&tmpnoun)) { |
| 338 |
get_obj(i+first_noun); |
| 339 |
sysmsgd(8,"$You$ pick up $the_n$$adjective$ $noun$.",&tmpnoun); |
| 340 |
} |
| 341 |
cnt++; |
| 342 |
} |
| 343 |
if (cnt==0) { |
| 344 |
sysmsgd(24,"There doesn't seem to be anything here to take.",objrec); |
| 345 |
return 0; |
| 346 |
} else return 1; |
| 347 |
} |
| 348 |
if (it_door(obj,objrec->noun)) { |
| 349 |
if (room[loc].locked_door) |
| 350 |
sysmsgd(25,"You can't pick up the door.",objrec); |
| 351 |
else |
| 352 |
sysmsgd(26,"You can't pick up the doorway.",objrec); |
| 353 |
return 0; |
| 354 |
} |
| 355 |
if (!tnoun(obj) || !noun[obj-first_noun].movable) |
| 356 |
{ |
| 357 |
sysmsgd( tcreat(obj)?(creature[obj-first_creat].hostile?34:35):29, |
| 358 |
"$You$ can't pick $the_n$$noun$ up.", objrec ); |
| 359 |
return 0; |
| 360 |
} |
| 361 |
if (it_loc(obj)==1) |
| 362 |
{sysmsgd(27,"$You$ already have $the_n$$noun$.",objrec);return 1;} |
| 363 |
if (!can_carry(objrec)) return 0; |
| 364 |
get_obj(obj); |
| 365 |
sysmsgd(8,"$You$ pick up $the_n$$adjective$ $noun$.",objrec); |
| 366 |
return 1; |
| 367 |
} |
| 368 |
|
| 369 |
static int v_remove(parse_rec *objrec) |
| 370 |
{ |
| 371 |
int i,j; |
| 372 |
integer obj; |
| 373 |
|
| 374 |
obj=objrec->obj; |
| 375 |
if (objrec->info==D_ALL) { |
| 376 |
if (player_worn==0) { |
| 377 |
sysmsgd(46,"$You're$ not wearing anything.",objrec); |
| 378 |
return 0;} |
| 379 |
safecontloop(i,j,1000) |
| 380 |
if (it_canmove(i)) { |
| 381 |
parse_rec tmp; |
| 382 |
if (PURE_WEAR) drop_obj(i); |
| 383 |
else it_move(i,1); |
| 384 |
|
| 385 |
|
| 386 |
make_parserec(i,&tmp); |
| 387 |
sysmsgd(9,"$You$ take off $the_n$$noun$.",&tmp); |
| 388 |
} |
| 389 |
return 1; |
| 390 |
} |
| 391 |
if (it_loc(obj)!=1000) |
| 392 |
{sysmsgd(213,"$You're$ not wearing that.",objrec);return 0;} |
| 393 |
if (!it_canmove(obj)) { |
| 394 |
sysmsgd(201,"$You're$ not able to remove $the_n$$noun$.",objrec);return 0; |
| 395 |
} |
| 396 |
sysmsgd(9,"$You$ take off $the_n$$noun$.",objrec); |
| 397 |
if (PURE_WEAR) drop_obj(obj); |
| 398 |
else v_get(objrec); |
| 399 |
return 1; |
| 400 |
} |
| 401 |
|
| 402 |
static void v_drop(parse_rec *objrec) |
| 403 |
{ |
| 404 |
int i, j; |
| 405 |
int obj; |
| 406 |
obj=objrec->obj; |
| 407 |
|
| 408 |
if (obj==ALL_MARK) { |
| 409 |
if (player_contents==0) |
| 410 |
sysmsgd(45,"$You$ don't have anything to drop.",objrec); |
| 411 |
else safecontloop(i,j,1) { |
| 412 |
parse_rec tmp; |
| 413 |
make_parserec(i,&tmp); |
| 414 |
drop_obj(i); |
| 415 |
sysmsgd(9,"$You$ $verb$ $the_n$$noun$.",&tmp); |
| 416 |
} |
| 417 |
return; |
| 418 |
} |
| 419 |
if (!it_possess(obj)) |
| 420 |
{sysmsgd(47,"$You$ don't have that.",objrec);return;} |
| 421 |
if (!it_canmove(obj)) { |
| 422 |
sysmsgd(200,"$You're$ not able to $verb$ $the_n$$noun$.",objrec); |
| 423 |
return; |
| 424 |
} |
| 425 |
if (it_loc(obj)==1000) { |
| 426 |
sysmsgd(216,"(Taking it off first)",objrec); |
| 427 |
} |
| 428 |
sysmsgd(9,"$You$ $verb$ $the_n$$noun$.",objrec); |
| 429 |
drop_obj(obj); |
| 430 |
} |
| 431 |
|
| 432 |
static void v_wear(parse_rec *objrec) |
| 433 |
{ |
| 434 |
int i, cnt; |
| 435 |
int obj; |
| 436 |
|
| 437 |
obj=objrec->obj; |
| 438 |
if (objrec->info==D_ALL) { |
| 439 |
cnt=0; |
| 440 |
nounloop(i) |
| 441 |
if (noun[i].location!=1000 && visible(i+first_noun) && |
| 442 |
noun[i].wearable) { |
| 443 |
parse_rec tmp; |
| 444 |
make_parserec(i+first_noun,&tmp); |
| 445 |
if (can_wear(&tmp)) { |
| 446 |
it_move(i+first_noun,1000); |
| 447 |
sysmsgd(42,"$You$ put on $the_n$$adjective$ $noun$.",&tmp); |
| 448 |
} |
| 449 |
cnt++; |
| 450 |
} |
| 451 |
if (cnt==0) |
| 452 |
sysmsgd(36,"There doesn't seem to be anything $you$ can wear here.", |
| 453 |
objrec); |
| 454 |
return; |
| 455 |
} |
| 456 |
if (!tnoun(obj) || !noun[obj-first_noun].wearable) { |
| 457 |
sysmsgd( tcreat(obj)?(creature[obj-first_creat].hostile?43:44):203, |
| 458 |
"$You$ can't wear that.",objrec); |
| 459 |
return; |
| 460 |
} |
| 461 |
if (it_loc(obj)==1000) |
| 462 |
{sysmsgd(37,"$You$ $are$ already wearing $the_n$$noun$.",objrec);return;} |
| 463 |
if (!can_wear(objrec)) return; |
| 464 |
sysmsgd(42,"$You$ put on $the_n$$noun$.",objrec); |
| 465 |
it_move(obj,1000); |
| 466 |
} |
| 467 |
|
| 468 |
static int do_lock(uchar l_or_u, |
| 469 |
parse_rec *nounrec, parse_rec *objrec) |
| 470 |
|
| 471 |
{ |
| 472 |
int dnoun; |
| 473 |
int dobj, iobj; |
| 474 |
word dobj_word; |
| 475 |
|
| 476 |
dobj=p_obj(nounrec); |
| 477 |
iobj=p_obj(objrec); |
| 478 |
dobj_word=nounrec->noun; |
| 479 |
|
| 480 |
if (it_door(dobj,dobj_word) && l_or_u!=room[loc].locked_door) { |
| 481 |
|
| 482 |
if (l_or_u==0) |
| 483 |
alt_sysmsg(114,"The door is already locked.",nounrec,objrec); |
| 484 |
else |
| 485 |
alt_sysmsg(105, |
| 486 |
"There doesn't seem to be any door here that need unlocking.", |
| 487 |
nounrec,objrec); |
| 488 |
return 0; |
| 489 |
} |
| 490 |
if (!it_lockable(dobj,dobj_word)) { |
| 491 |
alt_sysmsg( (l_or_u ? 108 : 118 ),"$The_n$$noun$ can't be $verb$ed.", |
| 492 |
nounrec,objrec); |
| 493 |
return 0; |
| 494 |
} |
| 495 |
if (tnoun(dobj) && noun[dobj-first_noun].closable && it_open(dobj)) { |
| 496 |
if (l_or_u==0) { |
| 497 |
alt_sysmsg(120,"$You$ will need to close $the_n$$noun$ first.", |
| 498 |
nounrec,objrec); |
| 499 |
return 0; |
| 500 |
} else { |
| 501 |
alt_sysmsg(110,"$The_n$$noun$ $n_is$ already open!", |
| 502 |
nounrec,objrec); |
| 503 |
return 0; |
| 504 |
} |
| 505 |
} |
| 506 |
if (it_locked(dobj,dobj_word)!=l_or_u) { |
| 507 |
alt_sysmsg( (l_or_u ? 109 : 119),"$The_n$$noun$ $n_is$ already $verb$ed", |
| 508 |
nounrec,objrec); |
| 509 |
return 0; |
| 510 |
} |
| 511 |
if (it_door(dobj,dobj_word) || dobj<0) { |
| 512 |
alt_sysmsg( (l_or_u ? 104 :115), |
| 513 |
"$You$ try to $verb$ $the_n$$noun$, but fail.", |
| 514 |
nounrec,objrec); |
| 515 |
return 0; |
| 516 |
} |
| 517 |
dnoun=dobj-first_noun; |
| 518 |
if (iobj==0) { |
| 519 |
alt_sysmsg( (l_or_u ? 106 : 208), |
| 520 |
"$You$ will need to use something to do that.", |
| 521 |
nounrec,objrec); |
| 522 |
return 0; |
| 523 |
} |
| 524 |
if (!player_has(iobj)) { |
| 525 |
alt_sysmsg( (l_or_u ? 107 : 117), "$You$ don't have $the_o$$object$.", |
| 526 |
nounrec,objrec); |
| 527 |
return 0; |
| 528 |
} |
| 529 |
if (!matchclass(iobj,noun[dnoun].key)) { |
| 530 |
alt_sysmsg( l_or_u ? (vb==15?80:111) : 121, |
| 531 |
"$The_o$$object$ doesn't fit.",nounrec,objrec); |
| 532 |
return 0; |
| 533 |
} |
| 534 |
noun[dnoun].locked=!l_or_u; |
| 535 |
return 1; |
| 536 |
} |
| 537 |
|
| 538 |
static void v_lock(uchar l_or_u,parse_rec *nounrec,parse_rec *objrec) |
| 539 |
|
| 540 |
{ |
| 541 |
if (!do_lock(l_or_u,nounrec,objrec)) return; |
| 542 |
|
| 543 |
alt_sysmsg( (l_or_u ? 112 : 122), |
| 544 |
"$You$ $verb$ $the_n$$noun$ with $the_o$$object$.", |
| 545 |
nounrec,objrec); |
| 546 |
} |
| 547 |
|
| 548 |
static void v_open(parse_rec *nounrec,parse_rec *objrec) |
| 549 |
|
| 550 |
{ |
| 551 |
int dnoun; |
| 552 |
int dobj,iobj; |
| 553 |
|
| 554 |
dobj=p_obj(nounrec); |
| 555 |
iobj=p_obj(objrec); |
| 556 |
|
| 557 |
dnoun=dobj-first_noun; |
| 558 |
if (it_door(dobj,nounrec->noun)) { |
| 559 |
if (room[loc].locked_door) |
| 560 |
alt_sysmsg(71,"$The_n$$noun$ $n_is$ locked.", |
| 561 |
nounrec,objrec); |
| 562 |
else |
| 563 |
alt_sysmsg(72,"$The_n$$noun$ $n_is$ already open.", |
| 564 |
nounrec,objrec); |
| 565 |
return; |
| 566 |
} |
| 567 |
if (it_open(dobj)) { |
| 568 |
alt_sysmsg(78,"$The_n$$noun$ $n_is$ already open.",nounrec,objrec); |
| 569 |
return; |
| 570 |
} |
| 571 |
if (!tnoun(dobj) || !noun[dnoun].closable) { |
| 572 |
alt_sysmsg(77,"$You$ can't open $the_n$$noun$.",nounrec,objrec); |
| 573 |
return; |
| 574 |
} |
| 575 |
if (iobj!=0) |
| 576 |
{ |
| 577 |
if (!do_lock(1,nounrec,objrec)) return; |
| 578 |
|
| 579 |
} |
| 580 |
if (noun[dnoun].lockable && noun[dnoun].locked) { |
| 581 |
alt_sysmsg(79,"It is locked.",nounrec,objrec); |
| 582 |
return; |
| 583 |
} |
| 584 |
noun[dnoun].open=1; |
| 585 |
if (iobj!=0) |
| 586 |
alt_sysmsg(81,"$You$ have opened $the_n$$noun$ with $the_o$$object$.", |
| 587 |
nounrec,objrec); |
| 588 |
else alt_sysmsg(82,"$You$ have opened $the_n$$noun$.",nounrec,objrec); |
| 589 |
if (noun[dnoun].contents!=0) |
| 590 |
alt_sysmsg(187,"Inside, $you$ see the following:",nounrec,objrec); |
| 591 |
print_contents(dobj,1); |
| 592 |
} |
| 593 |
|
| 594 |
static void v_close(parse_rec *nounrec) |
| 595 |
{ |
| 596 |
int dobj; |
| 597 |
dobj=nounrec->obj; |
| 598 |
|
| 599 |
if (it_door(dobj,nounrec->noun)) { |
| 600 |
if (room[loc].locked_door) |
| 601 |
sysmsgd(84,"The door is already closed.",nounrec); |
| 602 |
else |
| 603 |
sysmsgd(85,"That apparently can't be closed.",nounrec); |
| 604 |
return; |
| 605 |
} |
| 606 |
if (!it_open(dobj)) { |
| 607 |
sysmsgd(88,"$The_n$$noun$ $n_is$ already closed.",nounrec); |
| 608 |
return; |
| 609 |
} |
| 610 |
if (!tnoun(dobj) || !noun[dobj-first_noun].closable) { |
| 611 |
sysmsgd(87,"$You$ can't close $the_n$$noun$.",nounrec); |
| 612 |
return; |
| 613 |
} |
| 614 |
noun[dobj-first_noun].open=0; |
| 615 |
sysmsgd(89,"$You$ have closed $the_n$$noun$.",nounrec); |
| 616 |
} |
| 617 |
|
| 618 |
|
| 619 |
static void v_light(int newstate,parse_rec *nounrec) |
| 620 |
{ |
| 621 |
int dobj; |
| 622 |
dobj=p_obj(nounrec); |
| 623 |
|
| 624 |
if (!tnoun(dobj) || !noun[dobj-first_noun].light) { |
| 625 |
sysmsgd(newstate?135:140,"$You$ can't $verb$ $the_n$$noun$.",nounrec); |
| 626 |
return; |
| 627 |
} |
| 628 |
dobj-=first_noun; |
| 629 |
if (noun[dobj].on==newstate) { |
| 630 |
if (newstate) |
| 631 |
sysmsgd(136,"$The_n$$noun$ $n_is$ already lit.",nounrec); |
| 632 |
else sysmsgd(141, |
| 633 |
"$The_n$$noun$ $n_is$n't lit, so $you$ can't extinguish $n_indir$", |
| 634 |
nounrec); |
| 635 |
return; |
| 636 |
} |
| 637 |
noun[dobj].on=newstate; |
| 638 |
if (newstate) sysmsgd(138,"$The_n$$noun$ $n_is$ now lit.",nounrec); |
| 639 |
else sysmsgd(143,"$The_n$$noun$ $n_is$ no longer lit.",nounrec); |
| 640 |
} |
| 641 |
|
| 642 |
static void v_turn(word prep, parse_rec *nounrec) |
| 643 |
{ |
| 644 |
int newstate; |
| 645 |
int dobj; |
| 646 |
dobj=p_obj(nounrec); |
| 647 |
|
| 648 |
newstate=(prep==ext_code[won]); |
| 649 |
if (!it_turnable(dobj) && !nounattr(dobj,light)) { |
| 650 |
sysmsgd(newstate?209:210, |
| 651 |
"$You$ can't turn $the_n$$noun$ $prep$.",nounrec); |
| 652 |
return; |
| 653 |
} |
| 654 |
if (matchclass(dobj,room[loc].key)) { |
| 655 |
v_go(13); |
| 656 |
return; |
| 657 |
} |
| 658 |
if (!tnoun(dobj)) { |
| 659 |
writeln("INTERNAL ERROR: Non-noun turn on/off not supported"); |
| 660 |
return; |
| 661 |
} |
| 662 |
dobj-=first_noun; |
| 663 |
if (noun[dobj].on==newstate) { |
| 664 |
sysmsgd(newstate?137:142,"$The_n$$noun$ $n_is$ already $prep$.", |
| 665 |
nounrec); |
| 666 |
return; |
| 667 |
} |
| 668 |
noun[dobj].on=newstate; |
| 669 |
sysmsgd(newstate?139:144,"$The_n$$noun$ $n_is$ now $prep$.",nounrec); |
| 670 |
} |
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
static void v_attack(uchar missile,parse_rec *targrec,parse_rec *weprec) |
| 675 |
|
| 676 |
{ |
| 677 |
int targ, wep; |
| 678 |
targ=targrec->obj; |
| 679 |
wep=weprec->obj; |
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
if (missile && targ==0) |
| 684 |
if (!tnoun(wep) || !noun[wep-first_noun].shootable) |
| 685 |
{targ=wep; targrec=weprec; wep=0;} |
| 686 |
|
| 687 |
curr_creat_rec=targrec; |
| 688 |
if (wep>0 && !player_has(wep)) { |
| 689 |
alt_sysmsg(98,"(Getting $the_o$$object$ first)",targrec,weprec); |
| 690 |
if (!v_get(weprec)) return; |
| 691 |
} |
| 692 |
if ((targ>0 && !tcreat(targ)) || targ<0) { |
| 693 |
alt_sysmsg(missile ? 90 : 93, |
| 694 |
"It only makes sense to attack living things.", |
| 695 |
targrec,weprec); |
| 696 |
return; |
| 697 |
} |
| 698 |
if (missile) { |
| 699 |
if (wep==0) { |
| 700 |
sysmsgd(94,"It's not clear what $you$ want to $verb$ with.",targrec); |
| 701 |
return; |
| 702 |
} |
| 703 |
else if (!tnoun(wep) || !noun[wep-first_noun].shootable) { |
| 704 |
alt_sysmsg(it_isweapon(wep)?96:95, |
| 705 |
"$The_o$$object$ doesn't seem to be able to fire.", |
| 706 |
targrec,weprec); |
| 707 |
return; |
| 708 |
} |
| 709 |
else if (noun[wep-first_noun].num_shots<=0) { |
| 710 |
alt_sysmsg(97,"$The_o$$object$ $o_is$ out of ammunition.", |
| 711 |
targrec,weprec); |
| 712 |
return;} |
| 713 |
else noun[wep-first_noun].num_shots--; |
| 714 |
} |
| 715 |
|
| 716 |
if (targ==0) { |
| 717 |
if (!missile) { |
| 718 |
alt_sysmsg(206,"Attack what???",NULL,weprec); |
| 719 |
return; |
| 720 |
} |
| 721 |
else { |
| 722 |
alt_sysmsg(188,"$You$ fire a shot into the air.",NULL,weprec); |
| 723 |
return; |
| 724 |
} |
| 725 |
} |
| 726 |
|
| 727 |
if (wep==0) { |
| 728 |
sysmsgd(creature[targ-first_creat].hostile?91:92, |
| 729 |
"$You$ attack $the_n$$noun$ with $your$ bare hands, but $n_pro$ " |
| 730 |
"evades $your$ attack.",targrec); |
| 731 |
return; |
| 732 |
} |
| 733 |
|
| 734 |
if (matchclass(wep,creature[targ-first_creat].weapon)) |
| 735 |
{ |
| 736 |
if (missile) |
| 737 |
alt_sysmsg(creature[targ-first_creat].hostile?99:101, |
| 738 |
"$You$ shoot $the_n$$noun$; " |
| 739 |
"$n_pro$ vanishes in a cloud of red smoke." |
| 740 |
,targrec,weprec); |
| 741 |
else |
| 742 |
alt_sysmsg(creature[targ-first_creat].hostile?49:53, |
| 743 |
"$You$ kill $the_o$$object$; " |
| 744 |
"$o_pro$ vanishes in a cloud of red smoke.", |
| 745 |
weprec,targrec); |
| 746 |
it_destroy(targ); |
| 747 |
if (!missile) drop_obj(wep); |
| 748 |
return; |
| 749 |
} |
| 750 |
else { |
| 751 |
if (!missile) { |
| 752 |
int msgnum; |
| 753 |
if (creature[targ-first_creat].hostile) { |
| 754 |
alt_sysmsg(50,NULL,weprec,targrec); |
| 755 |
msgnum=51; |
| 756 |
} else msgnum=54; |
| 757 |
if (noun[wep-first_noun].drinkable) { |
| 758 |
alt_sysmsg(msgnum+1,"$You$ splash $the_o$$object$ with " |
| 759 |
"$the_n$$noun$, but the liquid quickly evaporates " |
| 760 |
"without noticable effect.",weprec,targrec); |
| 761 |
it_destroy(wep); |
| 762 |
} else { |
| 763 |
alt_sysmsg(msgnum, |
| 764 |
"$You$ strike at $the_o$$object$ with $the_n$$noun$, " |
| 765 |
"but $your$ weapon bounces off of $o_indir$ harmlessly", |
| 766 |
weprec,targrec); |
| 767 |
drop_obj(wep); |
| 768 |
} |
| 769 |
} |
| 770 |
else |
| 771 |
alt_sysmsg(creature[targ-first_creat].hostile?100:102 , |
| 772 |
"$You$ fire at $the_n$$noun$ with $the_o$$object$, but $your$ " |
| 773 |
"shots don't seem to have any effect.",targrec,weprec); |
| 774 |
|
| 775 |
if (creature[targ-first_creat].hostile && |
| 776 |
++creature[targ-first_creat].counter>= |
| 777 |
creature[targ-first_creat].threshold) |
| 778 |
{ |
| 779 |
alt_sysmsg(204,"$The_n$$noun$ counterattacks! $N_pro$ fights " |
| 780 |
"viciously and $you$ $are$ unable to defend $your$self " |
| 781 |
"against $n_indir$.",targrec,weprec); |
| 782 |
deadflag=1; |
| 783 |
} |
| 784 |
} |
| 785 |
} |
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
static rbool v_put(parse_rec *nounrec,word prep, |
| 790 |
parse_rec *objrec,rbool child_proc) |
| 791 |
{ |
| 792 |
rbool in_prep; |
| 793 |
int dobj,iobj; |
| 794 |
|
| 795 |
dobj=p_obj(nounrec); |
| 796 |
iobj=p_obj(objrec); |
| 797 |
|
| 798 |
in_prep=(prep==ext_code[win] || prep==ext_code[winto] |
| 799 |
|| prep==ext_code[winside]); |
| 800 |
|
| 801 |
if (prep==0 || iobj==0) |
| 802 |
{ v_drop(nounrec); return 1;} |
| 803 |
if (!tnoun(dobj)) { |
| 804 |
alt_sysmsg(tcreat(dobj)?11:10, |
| 805 |
"$You$ can't do that with $the_n$$noun$.", |
| 806 |
nounrec,objrec); |
| 807 |
return 0; |
| 808 |
} |
| 809 |
if (!noun[dobj-first_noun].movable) { |
| 810 |
alt_sysmsg(61,"$You$ can't move $the_n$$adjective$ $noun$.", |
| 811 |
nounrec,objrec); |
| 812 |
return 0; |
| 813 |
} |
| 814 |
if (tcreat(iobj)) { |
| 815 |
alt_sysmsg(189,"$The_o$$object$ doesn't want $n_indir$.", |
| 816 |
nounrec,objrec); |
| 817 |
return 0; |
| 818 |
} |
| 819 |
if (!tnoun(iobj)) { |
| 820 |
alt_sysmsg(tcreat(iobj)?12:64, |
| 821 |
"$You$ can't put something $prep$ $the_o$$object$.", |
| 822 |
nounrec,objrec); |
| 823 |
return 0; |
| 824 |
} |
| 825 |
if (dobj==iobj) { |
| 826 |
alt_sysmsg(62,"$You$ can't put something $prep$ $n_indir$self.", |
| 827 |
nounrec,objrec); |
| 828 |
return 0; |
| 829 |
} |
| 830 |
if (!it_open(iobj) && in_prep) { |
| 831 |
alt_sysmsg(65,"$The_o$$object$ $o_is$n't open.",nounrec,objrec); |
| 832 |
return 0; |
| 833 |
} |
| 834 |
if (player_has(iobj) && !in_prep) { |
| 835 |
alt_sysmsg(is_within(iobj,1,0)?68:69, |
| 836 |
"$You$ can't put $the_n$$noun$ $prep$ something that $you$ " |
| 837 |
"$are$ carrying.",nounrec,objrec); |
| 838 |
return 0; |
| 839 |
} |
| 840 |
|
| 841 |
if (in_prep) { |
| 842 |
if (check_fit(dobj,iobj)!=FIT_OK) { |
| 843 |
alt_sysmsg(66,"$You$ can't fit $the_n$$noun$ into $the_o$$object$.", |
| 844 |
nounrec,objrec); |
| 845 |
return 0; |
| 846 |
} |
| 847 |
if (it_loc(dobj)==1000) |
| 848 |
alt_sysmsg(216,"(Taking $n_indir$ off first)",nounrec,objrec); |
| 849 |
it_move(dobj,iobj); |
| 850 |
} |
| 851 |
else { |
| 852 |
int parent; |
| 853 |
|
| 854 |
parent=it_loc(iobj); |
| 855 |
if (!troom(parent)) { |
| 856 |
parse_rec parent_rec; |
| 857 |
make_parserec(parent,&parent_rec); |
| 858 |
if (!v_put(nounrec,ext_code[win],&parent_rec,1)) return 0; |
| 859 |
} |
| 860 |
else { |
| 861 |
if (it_loc(dobj)==1000) |
| 862 |
alt_sysmsg(216,"(Taking $n_indir$ off first)",nounrec,objrec); |
| 863 |
drop_obj(dobj); |
| 864 |
} |
| 865 |
dobj-=first_noun; |
| 866 |
assert(noun[dobj].pos_prep==0); |
| 867 |
noun[dobj].pos_prep=prep; |
| 868 |
noun[dobj].pos_name=it_name(iobj); |
| 869 |
if (iobj>0) noun[dobj].nearby_noun=iobj; |
| 870 |
} |
| 871 |
if (!child_proc) |
| 872 |
alt_sysmsg(67,"$You$ place $the_n$$noun$ $prep$ $the_o$$object$.", |
| 873 |
nounrec,objrec); |
| 874 |
return 1; |
| 875 |
} |
| 876 |
|
| 877 |
|
| 878 |
static void v_throw(parse_rec *nounrec,word prep,parse_rec *objrec) |
| 879 |
|
| 880 |
{ |
| 881 |
int dobj,iobj; |
| 882 |
dobj=p_obj(nounrec); |
| 883 |
iobj=p_obj(objrec); |
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
if (!player_has(nounrec->obj)) { |
| 888 |
alt_sysmsg(47,"$You$ don't have $the_n$$noun$.",nounrec,objrec); |
| 889 |
return; |
| 890 |
} |
| 891 |
if (prep==0) { |
| 892 |
v_drop(nounrec); |
| 893 |
return; |
| 894 |
} |
| 895 |
if (prep!=ext_code[wat]) |
| 896 |
v_put(nounrec,prep,objrec,0); |
| 897 |
else |
| 898 |
if (!noun[dobj-first_noun].movable) { |
| 899 |
alt_sysmsg(215,"$You$ can't move $the_n$$adjective$ $noun$.", |
| 900 |
nounrec,objrec); |
| 901 |
return; |
| 902 |
} |
| 903 |
if (tcreat(iobj)) |
| 904 |
v_attack(0,objrec,nounrec); |
| 905 |
else { |
| 906 |
if (dobj==iobj) { |
| 907 |
alt_sysmsg(56,"$You$ can't $verb$ $the_n$$noun$ $prep$ $n_indir$self.", |
| 908 |
nounrec,objrec); |
| 909 |
return; |
| 910 |
} |
| 911 |
if (it_loc(dobj)==1000) |
| 912 |
alt_sysmsg(216,"(Taking it off first)",nounrec,objrec); |
| 913 |
|
| 914 |
if (tnoun(dobj) && noun[dobj-first_noun].drinkable) { |
| 915 |
|
| 916 |
if (tnoun(iobj) && noun[iobj-first_noun].open) |
| 917 |
alt_sysmsg(58,"$You$ throw $the_n$$noun$ into $the_o$$object$, " |
| 918 |
"but $n_pro$ quickly evaporates.", |
| 919 |
nounrec,objrec); |
| 920 |
else |
| 921 |
alt_sysmsg(57,"$The_n$$noun$ splashes on $the_o$$object$ but " |
| 922 |
"quickly evaporates.",nounrec,objrec); |
| 923 |
it_destroy(dobj); |
| 924 |
} else { |
| 925 |
if (tnoun(iobj) && noun[iobj-first_noun].open) |
| 926 |
if (check_fit(dobj,iobj)) { |
| 927 |
alt_sysmsg(60,"$The_n$$noun$ lands inside $the_o$$object$.", |
| 928 |
nounrec,objrec); |
| 929 |
it_move(dobj,iobj); |
| 930 |
return; |
| 931 |
} else { |
| 932 |
alt_sysmsg(205,"You $verb$ $the_n$$noun$ into $the_o$$object$, " |
| 933 |
"but there isn't enough room and $n_pro$ falls out.", |
| 934 |
nounrec,objrec); |
| 935 |
} else |
| 936 |
alt_sysmsg(59,"$The_n$$noun$ bounces off $the_o$$object$.", |
| 937 |
nounrec,objrec); |
| 938 |
|
| 939 |
|
| 940 |
it_move(dobj,first_room+loc); |
| 941 |
} |
| 942 |
} |
| 943 |
} |
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
void v_inventory(void) |
| 948 |
{ |
| 949 |
if (player_contents!=0) { |
| 950 |
sysmsg(130,"$You're$ carrying:"); |
| 951 |
print_contents(1,1); |
| 952 |
} else sysmsg(131,"$You$ $are$ empty-handed."); |
| 953 |
if (player_worn!=0) { |
| 954 |
sysmsg(132,"$You're$ wearing:"); |
| 955 |
print_contents(1000,1); |
| 956 |
} |
| 957 |
} |
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
static void v_quit(void) |
| 964 |
{ |
| 965 |
sysmsg(145,"Are you sure you want to quit?"); |
| 966 |
if (yesno("")) { |
| 967 |
sysmsg(146,NULL); |
| 968 |
quitflag=1; |
| 969 |
} |
| 970 |
} |
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
const char directions[12][10]={"north","south","east","west", |
| 975 |
"northeast","northwest","southeast","southwest", |
| 976 |
"up","down","in","out"}; |
| 977 |
|
| 978 |
void v_listexit(void) |
| 979 |
{ |
| 980 |
int i, j,k; |
| 981 |
|
| 982 |
if (!islit()) { |
| 983 |
sysmsg(23,"It is too dark to see anything.");return;} |
| 984 |
j=k=0; |
| 985 |
for(i=0;i<12;i++) |
| 986 |
if (room[loc].path[i]!=0) k++; |
| 987 |
if (k==0) |
| 988 |
sysmsg(224,"There are no immediately visible exits."); |
| 989 |
else { |
| 990 |
sysmsg(225,"There are exits to"); |
| 991 |
for(i=0;i<12;i++) |
| 992 |
if (room[loc].path[i]!=0) { |
| 993 |
j++; |
| 994 |
if (j>1) writestr(", "); |
| 995 |
if (j>1 && j==k) writestr("or "); |
| 996 |
if (i<8) writestr("the "); |
| 997 |
writestr(directions[i]); |
| 998 |
} |
| 999 |
writeln("."); |
| 1000 |
} |
| 1001 |
} |
| 1002 |
|
| 1003 |
|
| 1004 |
static void v_yell(void) |
| 1005 |
{ |
| 1006 |
sysmsg(150,"YAAAAEEEEEEEEOOOOOOUUUUUAAAAHHHHHH!!!!!"); |
| 1007 |
} |
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
static int checkgram(int vb,int dobj,word prep, int iobj, rbool redir_flag) |
| 1016 |
{ |
| 1017 |
int i; |
| 1018 |
int msgnum; |
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
if (redir_flag<2) redir_flag=0; |
| 1023 |
if (PURE_GRAMMAR) redir_flag=1; |
| 1024 |
|
| 1025 |
|
| 1026 |
if (vb>=BASE_VERB && vb<TOTAL_VERB) return 0; |
| 1027 |
|
| 1028 |
if (!(verbflag[vb]&VERB_TAKEOBJ) |
| 1029 |
&& (dobj!=0 || iobj!=0 || prep>0) |
| 1030 |
&& vb!=OLD_VERB+11) |
| 1031 |
{ |
| 1032 |
if (redir_flag) return 0; |
| 1033 |
sysmsg(190,"$Verb$ doesn't take an object."); |
| 1034 |
return -1;} |
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
if (prep>0 && !(redir_flag && syntbl[preplist[vb]]==0)) |
| 1040 |
{ |
| 1041 |
for(i=preplist[vb];syntbl[i]!=0 && syntbl[i]!=prep;i++); |
| 1042 |
if (syntbl[i]!=prep) { |
| 1043 |
msgnum=191; |
| 1044 |
if (vb==15) msgnum=74; |
| 1045 |
if (vb==17) msgnum=116; |
| 1046 |
if (vb==14) msgnum=48; |
| 1047 |
sysmsg(msgnum,"$Verb$ doesn't take $prep$ as a preposition."); |
| 1048 |
return -1; |
| 1049 |
} |
| 1050 |
} |
| 1051 |
if (iobj==ALL_MARK) { |
| 1052 |
sysmsg(199,"You can't use ALL as an indirect object");return -1;} |
| 1053 |
if (dobj==ALL_MARK && vb!=33 && vb!=41 && vb!=51 && vb!=52) { |
| 1054 |
|
| 1055 |
msgnum=5; |
| 1056 |
if (vb==31) msgnum=155; |
| 1057 |
if (vb==34) msgnum=160; |
| 1058 |
sysmsg(5,"You can't use ALL with '$verb$'.");return -1;} |
| 1059 |
return 0; |
| 1060 |
} |
| 1061 |
|
| 1062 |
|
| 1063 |
static rbool verify_scope(int vb,parse_rec *nounrec, |
| 1064 |
word prep, parse_rec *objrec) |
| 1065 |
|
| 1066 |
{ |
| 1067 |
int msgnum; |
| 1068 |
int dobj,iobj; |
| 1069 |
dobj=nounrec->obj; iobj=objrec->obj; |
| 1070 |
|
| 1071 |
if (!(verbflag[vb]&VERB_TAKEOBJ)) return 1; |
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
if (vb==31 || vb==34) |
| 1076 |
return 1; |
| 1077 |
|
| 1078 |
if (dobj==0) { |
| 1079 |
sysmsg(184,"What do $you$ want to $verb$?"); |
| 1080 |
return 0; |
| 1081 |
} |
| 1082 |
if (dobj!=ALL_MARK && !genvisible(nounrec) |
| 1083 |
&& !(it_door(dobj,nounrec->noun) && |
| 1084 |
(vb==33 || vb==15 || vb==16 || vb==17 || vb==18 |
| 1085 |
|| vb==29 || vb==24 || vb==22 || vb==21))) { |
| 1086 |
msgnum=3; |
| 1087 |
if (vb==33) msgnum=28; |
| 1088 |
if (vb==29) msgnum=63; |
| 1089 |
if (vb==15) msgnum=75; |
| 1090 |
if (vb==16) msgnum=86; |
| 1091 |
if (vb==24) msgnum=126; |
| 1092 |
if (vb==22) msgnum=133; |
| 1093 |
if (vb==21) msgnum=179; |
| 1094 |
sysmsg(msgnum,"$You$ don't see any $noun$ here."); |
| 1095 |
return 0; |
| 1096 |
} |
| 1097 |
|
| 1098 |
if (prep!=0 && vb!=35) { |
| 1099 |
if (iobj==0) { |
| 1100 |
msgnum=214; |
| 1101 |
if (vb==29) msgnum=70; |
| 1102 |
sysmsg(msgnum,"What do $you$ want to $verb$ $the_n$$noun$ $prep$?"); |
| 1103 |
return 0; |
| 1104 |
} |
| 1105 |
if (iobj==-ext_code[wdoor]) { |
| 1106 |
sysmsg(183,"You can't $verb$ $prep$ $the_o$$object$."); |
| 1107 |
return 0; |
| 1108 |
} |
| 1109 |
if (iobj!=ALL_MARK && !genvisible(objrec)) { |
| 1110 |
msgnum=4; |
| 1111 |
if (vb==15) msgnum=76; |
| 1112 |
if (vb==18) msgnum=207; |
| 1113 |
sysmsg(msgnum,"$You$ don't see any $object$ here."); |
| 1114 |
return 0; |
| 1115 |
} |
| 1116 |
} |
| 1117 |
return 1; |
| 1118 |
} |
| 1119 |
|
| 1120 |
|
| 1121 |
static void exec_verb_info(void) |
| 1122 |
{ |
| 1123 |
char *a,*b,*c; |
| 1124 |
char buff[200]; |
| 1125 |
|
| 1126 |
a=objname(dobj); |
| 1127 |
b=objname(iobj); |
| 1128 |
c=objname(actor); |
| 1129 |
sprintf(buff,"\t\t]]%s, %s %s(%ld) %s %s(%ld)",c,dict[ syntbl[auxsyn[vb]] ], |
| 1130 |
a, dobj_rec->num, prep==0 ? "->" : dict[prep], b, iobj_rec->num); |
| 1131 |
writeln(buff); |
| 1132 |
rfree(a);rfree(b);rfree(c); |
| 1133 |
} |
| 1134 |
|
| 1135 |
|
| 1136 |
|
| 1137 |
rbool metacommand_cycle(int save_vb, int *p_redir_flag) |
| 1138 |
{ |
| 1139 |
if (!have_meta) return 0; |
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
if (DEBUG_AGT_CMD) |
| 1144 |
debugout("*** Scanning: ANY metacommands ****\n"); |
| 1145 |
|
| 1146 |
supress_debug=!debug_any; |
| 1147 |
clear_stack(); |
| 1148 |
if ((PURE_METAVERB || !was_metaverb) |
| 1149 |
&& 2==scan_metacommand(0,0,0,0,0,NULL)) |
| 1150 |
return 1; |
| 1151 |
|
| 1152 |
supress_debug=0; |
| 1153 |
|
| 1154 |
vb=save_vb; |
| 1155 |
actor_in_scope|=visible(actor); |
| 1156 |
|
| 1157 |
clear_stack(); |
| 1158 |
if (actor!=0 && aver<AGX00) { |
| 1159 |
if (DEBUG_AGT_CMD) |
| 1160 |
debugout("*** Scanning: ANYBODY metacommands ****\n"); |
| 1161 |
if (2==scan_metacommand(2,vb,dobj,prep,iobj,NULL)) |
| 1162 |
return 1; |
| 1163 |
} |
| 1164 |
|
| 1165 |
clear_stack(); |
| 1166 |
if (DEBUG_AGT_CMD) |
| 1167 |
debugout("*** Scanning: VERB metacommands ****\n"); |
| 1168 |
|
| 1169 |
if (2==scan_metacommand(actor,vb,dobj,prep,iobj,p_redir_flag)) |
| 1170 |
return 1; |
| 1171 |
|
| 1172 |
|
| 1173 |
|
| 1174 |
return 0; |
| 1175 |
} |
| 1176 |
|
| 1177 |
|
| 1178 |
|
| 1179 |
void exec_verb(void) |
| 1180 |
|
| 1181 |
|
| 1182 |
{ |
| 1183 |
int objswap; |
| 1184 |
|
| 1185 |
rbool turndone; |
| 1186 |
int save_vb; |
| 1187 |
int redir_flag; |
| 1188 |
|
| 1189 |
if (DEBUG_EXEC_VERB) exec_verb_info(); |
| 1190 |
|
| 1191 |
do_disambig=0; |
| 1192 |
|
| 1193 |
save_vb=vb; |
| 1194 |
cmd_saveable=1; |
| 1195 |
redir_flag=0; |
| 1196 |
|
| 1197 |
was_metaverb=(verbflag[vb] & VERB_META) |
| 1198 |
&& actor==0 && dobj==0 && prep==0 && iobj==0; |
| 1199 |
|
| 1200 |
|
| 1201 |
if (dobj==0 && dobj_rec->info!=D_NUM && iobj!=0) { |
| 1202 |
dobj=iobj; |
| 1203 |
rfree(dobj_rec); |
| 1204 |
dobj_rec=copy_parserec(iobj_rec); |
| 1205 |
objswap=1; |
| 1206 |
} else objswap=0; |
| 1207 |
|
| 1208 |
beforecmd=1; |
| 1209 |
|
| 1210 |
turndone=metacommand_cycle(save_vb,&redir_flag) || deadflag; |
| 1211 |
|
| 1212 |
if (!turndone && DEBUG_AGT_CMD) |
| 1213 |
debugout("*** Executing Built-in Verbs ****\n"); |
| 1214 |
|
| 1215 |
if (actor>0 && !turndone) { |
| 1216 |
if (!actor_in_scope) |
| 1217 |
sysmsg(196,"I don't see whom $you$ $are$ trying to address here."); |
| 1218 |
else |
| 1219 |
sysmsg(192,"$The_name$$name$ doesn't want to."); |
| 1220 |
} |
| 1221 |
else if (vb==19 && dobj==0 && prep==0 && iobj==0) |
| 1222 |
|
| 1223 |
v_look(); |
| 1224 |
else if (!turndone) { |
| 1225 |
|
| 1226 |
if (!objswap) |
| 1227 |
{if (checkgram(vb,dobj,prep,iobj,redir_flag)==-1) return;} |
| 1228 |
else if (checkgram(vb,0,prep,iobj,redir_flag)==-1) return; |
| 1229 |
|
| 1230 |
if (!verify_scope(vb,dobj_rec,prep,iobj_rec)) return; |
| 1231 |
|
| 1232 |
if (vb<13 && vb>0) v_go(vb); |
| 1233 |
else switch(vb) { |
| 1234 |
|
| 1235 |
case 14: v_throw(dobj_rec,prep,iobj_rec);break; |
| 1236 |
case 29: v_put(dobj_rec,prep,iobj_rec,0);break; |
| 1237 |
|
| 1238 |
|
| 1239 |
case 15: v_open(dobj_rec,iobj_rec);break; |
| 1240 |
case 16: v_close(dobj_rec);break; |
| 1241 |
case 17: v_lock(0,dobj_rec,iobj_rec);break; |
| 1242 |
case 18: v_lock(1,dobj_rec,iobj_rec);break; |
| 1243 |
case 36: v_noun(0,dobj_rec);break; |
| 1244 |
|
| 1245 |
case 26: v_attack(0,dobj_rec,iobj_rec);break; |
| 1246 |
case 49: |
| 1247 |
if (prep==ext_code[wwith]) |
| 1248 |
v_attack(1,dobj_rec,iobj_rec); |
| 1249 |
else |
| 1250 |
v_attack(1,iobj_rec,dobj_rec); |
| 1251 |
break; |
| 1252 |
|
| 1253 |
|
| 1254 |
case 31: v_talk(0,dobj_rec,iobj_rec);break; |
| 1255 |
case 34: v_talk(1,dobj_rec,iobj_rec);break; |
| 1256 |
|
| 1257 |
case 28: v_yell();break; |
| 1258 |
case 27: |
| 1259 |
sysmsg(149,"Time passes..."); |
| 1260 |
break; |
| 1261 |
case 55: v_go(13);break; |
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
case 50: runptr(loc,help_ptr,"Sorry, you're on your own here.", |
| 1266 |
2,NULL,NULL); |
| 1267 |
break; |
| 1268 |
case 32: v_inventory();break; |
| 1269 |
case 56: v_view(dobj_rec); break; |
| 1270 |
case 35: |
| 1271 |
if (prep>0) |
| 1272 |
v_turn(prep,dobj_rec); |
| 1273 |
else |
| 1274 |
v_noun(2,dobj_rec); |
| 1275 |
break; |
| 1276 |
case 20: v_examine(dobj_rec);break; |
| 1277 |
case 22: v_read(dobj_rec);break; |
| 1278 |
case 23: v_eat(0,dobj_rec);break; |
| 1279 |
case 24: v_eat(1,dobj_rec);break; |
| 1280 |
case 37: v_noun(1,dobj_rec);break; |
| 1281 |
case 38: v_noun(3,dobj_rec);break; |
| 1282 |
case 47: v_light(1,dobj_rec);break; |
| 1283 |
case 48: v_light(0,dobj_rec);break; |
| 1284 |
case 21: v_noun(4,dobj_rec);break; |
| 1285 |
|
| 1286 |
case 51: v_wear(dobj_rec);break; |
| 1287 |
case 33: v_get(dobj_rec);break; |
| 1288 |
case 52: v_remove(dobj_rec);break; |
| 1289 |
case 41: v_drop(dobj_rec);break; |
| 1290 |
|
| 1291 |
case 19: v_look();break; |
| 1292 |
case 25: print_score();break; |
| 1293 |
case 30: cmd_saveable=0; v_quit();break; |
| 1294 |
|
| 1295 |
case 39: |
| 1296 |
case 42: v_listexit();break; |
| 1297 |
case 43: cmd_saveable=0; verboseflag=0; |
| 1298 |
writeln( |
| 1299 |
"[Now in BRIEF mode (room descriptions will only be printed" |
| 1300 |
" when they are entered the first time)]"); |
| 1301 |
break; |
| 1302 |
case 44: |
| 1303 |
cmd_saveable=0; verboseflag=1;v_look(); |
| 1304 |
writeln("[Now in VERBOSE mode (room descriptions will be" |
| 1305 |
" printed every time you enter a room)]"); |
| 1306 |
break; |
| 1307 |
case 45: cmd_saveable=0;savegame();break; |
| 1308 |
case 46: cmd_saveable=0;doing_restore=1; return;break; |
| 1309 |
case 53: cmd_saveable=0;script(1);break; |
| 1310 |
case 54: cmd_saveable=0;script(0);break; |
| 1311 |
case 58: |
| 1312 |
agt_clrscr(); |
| 1313 |
print_instructions(hold_fc); |
| 1314 |
close_ins_file(); |
| 1315 |
break; |
| 1316 |
case (OLD_VERB+1): cmd_saveable=0; |
| 1317 |
if (restart_state==NULL) |
| 1318 |
writeln("Sorry, too little memory to support RESTART."); |
| 1319 |
else {doing_restore=2;return;} |
| 1320 |
case (OLD_VERB+4): cmd_saveable=0; |
| 1321 |
notify_flag=!notify_flag; |
| 1322 |
if (notify_flag) writeln("Score notification is now on."); |
| 1323 |
else writeln("Score notification is now off."); break; |
| 1324 |
case (OLD_VERB+5): listexit_flag=1; |
| 1325 |
writeln("[LISTEXIT mode on: room exits will be listed.]"); |
| 1326 |
break; |
| 1327 |
case (OLD_VERB+6): listexit_flag=0; |
| 1328 |
writeln("[LISTEXIT mode off: room exits will not be listed.]"); |
| 1329 |
break; |
| 1330 |
case (OLD_VERB+7): |
| 1331 |
if (debug_mode) get_debugcmd(); |
| 1332 |
else writeln("Nice try."); |
| 1333 |
break; |
| 1334 |
case (OLD_VERB+8): |
| 1335 |
logon();break; |
| 1336 |
case (OLD_VERB+9): |
| 1337 |
if (logflag&2) break; |
| 1338 |
if (logflag&1) close_pfile(log_out,5); |
| 1339 |
logflag=0;break; |
| 1340 |
case (OLD_VERB+10): |
| 1341 |
fast_replay=0; |
| 1342 |
replay(dobj_rec->num);break; |
| 1343 |
case (OLD_VERB+11): |
| 1344 |
fast_replay=0; |
| 1345 |
replay(-1);break; |
| 1346 |
case (OLD_VERB+13): |
| 1347 |
fast_replay=1; |
| 1348 |
replay(0); break; |
| 1349 |
case (OLD_VERB+12): |
| 1350 |
if (verbmenu==NULL) { |
| 1351 |
writeln("Sorry, but menus are not supported by this game."); |
| 1352 |
menu_mode=0; |
| 1353 |
break; |
| 1354 |
} |
| 1355 |
if (freeze_mode) { |
| 1356 |
writeln("Sorry, but that is not allowed."); |
| 1357 |
break; |
| 1358 |
} |
| 1359 |
menu_mode=!menu_mode; |
| 1360 |
break; |
| 1361 |
case 57: |
| 1362 |
writeln("INTERNAL ERROR: Invalid execution of AFTER"); |
| 1363 |
break; |
| 1364 |
case (OLD_VERB+14): |
| 1365 |
musiccmd(8,0);break; |
| 1366 |
case (OLD_VERB+15): |
| 1367 |
musiccmd(9,0);break; |
| 1368 |
case (OLD_VERB+16): |
| 1369 |
agt_clrscr(); |
| 1370 |
print_descr(intro_ptr,1); |
| 1371 |
break; |
| 1372 |
default: sysmsg(185,"Don't know how to $verb$ here..."); |
| 1373 |
return; |
| 1374 |
} |
| 1375 |
} |
| 1376 |
|
| 1377 |
compute_seen(); |
| 1378 |
|
| 1379 |
if (!PURE_AFTER && !doing_restore && end_of_turn) |
| 1380 |
increment_turn(); |
| 1381 |
|
| 1382 |
beforecmd=0; |
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
|
| 1387 |
if (TWO_CYCLE && !quitflag && !turndone && !deadflag) { |
| 1388 |
if (DEBUG_AGT_CMD) |
| 1389 |
debugout("*** Scanning (after) metacommands ****\n"); |
| 1390 |
|
| 1391 |
turndone=turndone||metacommand_cycle(save_vb,&redir_flag); |
| 1392 |
} |
| 1393 |
|
| 1394 |
if (aver>=AGT15 && !quitflag && !endflag && !deadflag) { |
| 1395 |
if (DEBUG_AGT_CMD) |
| 1396 |
debugout("*** Scanning: AFTER metacommands ****\n"); |
| 1397 |
|
| 1398 |
supress_debug=!debug_any; |
| 1399 |
clear_stack(); |
| 1400 |
if ((PURE_METAVERB || !was_metaverb) && |
| 1401 |
2==scan_metacommand(0,57,0,0,0,NULL)) |
| 1402 |
turndone=1; |
| 1403 |
supress_debug=0; |
| 1404 |
} |
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
if (save_vb==30 && endflag) quitflag=1; |
| 1410 |
} |
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
|
| 1429 |
int objcheck_cycle(rbool *success, parse_rec *act, int verbid, |
| 1430 |
parse_rec *dorec, word prep, parse_rec *iorec) |
| 1431 |
{ |
| 1432 |
int result; |
| 1433 |
|
| 1434 |
actor=act->obj; actor_rec=copy_parserec(act); |
| 1435 |
|
| 1436 |
dobj=dorec->obj; dobj_rec=copy_parserec(dorec); |
| 1437 |
if (iorec==NULL) { |
| 1438 |
iobj_rec=make_parserec(0,NULL); |
| 1439 |
iobj=0; |
| 1440 |
} else { |
| 1441 |
iobj=iorec->obj; iobj_rec=copy_parserec(iorec); |
| 1442 |
} |
| 1443 |
|
| 1444 |
clear_stack(); |
| 1445 |
*success=1; |
| 1446 |
supress_debug=!debug_disambig; |
| 1447 |
if (actor!=0 && aver<AGX00) { |
| 1448 |
result=scan_metacommand(2,verbid,dobj,prep,iobj,NULL); |
| 1449 |
if (result==2) {free_all_parserec();return disambig_score;} |
| 1450 |
if (result==-2) {free_all_parserec();return DISAMBIG_SUCC;} |
| 1451 |
} |
| 1452 |
clear_stack(); |
| 1453 |
result=scan_metacommand(actor,verbid,dobj,prep,iobj,NULL); |
| 1454 |
supress_debug=0; |
| 1455 |
switch (result) |
| 1456 |
{ |
| 1457 |
case -2: |
| 1458 |
free_all_parserec(); |
| 1459 |
return DISAMBIG_SUCC; |
| 1460 |
case 0: |
| 1461 |
case 1:break; |
| 1462 |
|
| 1463 |
case 2: |
| 1464 |
free_all_parserec(); |
| 1465 |
return disambig_score; |
| 1466 |
default: |
| 1467 |
writeln("INTERNAL ERROR: Invalid scan_metacommand return value."); |
| 1468 |
} |
| 1469 |
*success=0; |
| 1470 |
free_all_parserec(); |
| 1471 |
return 0; |
| 1472 |
} |
| 1473 |
|
| 1474 |
|
| 1475 |
|
| 1476 |
int check_obj(parse_rec *act, int verbid, |
| 1477 |
parse_rec *dorec, word prep, parse_rec *iorec) |
| 1478 |
{ |
| 1479 |
int result; |
| 1480 |
rbool success; |
| 1481 |
|
| 1482 |
if (iorec==NULL) |
| 1483 |
do_disambig=1; |
| 1484 |
else |
| 1485 |
do_disambig=2; |
| 1486 |
|
| 1487 |
disambig_score=0; |
| 1488 |
if (have_meta) { |
| 1489 |
beforecmd=1; |
| 1490 |
result=objcheck_cycle(&success,act,verbid,dorec,prep,iorec); |
| 1491 |
if (success) return result; |
| 1492 |
} |
| 1493 |
|
| 1494 |
|
| 1495 |
if (verbid<BASE_VERB) |
| 1496 |
switch(verbid) { |
| 1497 |
case 14: |
| 1498 |
case 29: |
| 1499 |
if (do_disambig==2 && genvisible(iorec)) return DISAMBIG_SUCC; |
| 1500 |
|
| 1501 |
case 41: |
| 1502 |
if (do_disambig==1 && it_possess(dobj)) return DISAMBIG_SUCC; |
| 1503 |
break; |
| 1504 |
|
| 1505 |
case 49: |
| 1506 |
if (prep==ext_code[wwith]) { |
| 1507 |
if (do_disambig==1 && tcreat(dobj) ) return DISAMBIG_SUCC; |
| 1508 |
else if (do_disambig==2 && it_possess(iobj) && tnoun(iobj) |
| 1509 |
&& noun[iobj-first_noun].shootable ) |
| 1510 |
return DISAMBIG_SUCC; |
| 1511 |
} else { |
| 1512 |
if (do_disambig==2 && tcreat(iobj)) return DISAMBIG_SUCC; |
| 1513 |
else if (do_disambig==1 && it_possess(dobj) && tnoun(dobj) |
| 1514 |
&& noun[dobj-first_noun].shootable) |
| 1515 |
return DISAMBIG_SUCC; |
| 1516 |
} |
| 1517 |
break; |
| 1518 |
|
| 1519 |
case 26: |
| 1520 |
if (do_disambig==2 && it_possess(iobj)) return DISAMBIG_SUCC; |
| 1521 |
if (do_disambig==1 && tcreat(dobj) && visible(dobj)) |
| 1522 |
return DISAMBIG_SUCC; |
| 1523 |
break; |
| 1524 |
|
| 1525 |
case 51: |
| 1526 |
if (do_disambig==1) |
| 1527 |
if (tnoun(dobj) && visible(dobj) && noun[dobj-first_noun].wearable |
| 1528 |
&& it_loc(dobj)!=1000) |
| 1529 |
return DISAMBIG_SUCC; |
| 1530 |
break; |
| 1531 |
case 33: |
| 1532 |
if (do_disambig==1 && tnoun(dobj) |
| 1533 |
&& visible(dobj) |
| 1534 |
&& noun[dobj-first_noun].location!=1 |
| 1535 |
&& noun[dobj-first_noun].movable) |
| 1536 |
return (player_has(dobj)) ? 499 : DISAMBIG_SUCC; |
| 1537 |
break; |
| 1538 |
case 52: |
| 1539 |
if (do_disambig==1 && it_loc(dobj)==1000) return DISAMBIG_SUCC; |
| 1540 |
break; |
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
case 15: |
| 1545 |
case 17: |
| 1546 |
case 18: |
| 1547 |
if (do_disambig==2 && it_possess(iobj)) return DISAMBIG_SUCC; |
| 1548 |
|
| 1549 |
default: |
| 1550 |
if (do_disambig==1 && genvisible(dorec)) return DISAMBIG_SUCC; |
| 1551 |
if (do_disambig==2 && genvisible(iorec)) return DISAMBIG_SUCC; |
| 1552 |
} |
| 1553 |
|
| 1554 |
if (have_meta && TWO_CYCLE) { |
| 1555 |
beforecmd=0; |
| 1556 |
result=objcheck_cycle(&success,act,verbid,dorec,prep,iorec); |
| 1557 |
if (success) return result; |
| 1558 |
} |
| 1559 |
|
| 1560 |
return disambig_score; |
| 1561 |
} |
| 1562 |
|
| 1563 |
|
| 1564 |
|
| 1565 |
|